frame.mojom 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // Copyright 2020 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. module android_webview.mojom;
  5. import "mojo/public/mojom/base/string16.mojom";
  6. import "mojo/public/mojom/base/time.mojom";
  7. import "skia/public/mojom/skcolor.mojom";
  8. import "ui/gfx/geometry/mojom/geometry.mojom";
  9. import "url/mojom/url.mojom";
  10. enum HitTestDataType{
  11. // Default type where nothing we are interested in is hit.
  12. // |extra_data_for_type| will be empty. All other values should be emtpy
  13. // except the special case described below.
  14. // For special case of invalid or javascript scheme url that would
  15. // otherwise be type an LINK type, |href| will contain the javascript
  16. // string in the href attribute, and |anchor_text| and |img_src| contain
  17. // their normal values for the respective type.
  18. kUnknown = 0,
  19. // Special case urls for kSrcLink below. Each type corresponds to a
  20. // different prefix in content url_constants. |extra_data_for_type| will
  21. // contain the url but with the prefix removed. |href| will contain the
  22. // exact href attribute string. Other fields are the same as kSrcLink.
  23. kPhone = 2,
  24. kGeo = 3,
  25. kEmail = 4,
  26. // Hit on a pure image (without links). |extra_data_for_type|, |href|,
  27. // and |anchor_text| will be empty. |img_src| will contain the absolute
  28. // source url of the image.
  29. kImage = 5,
  30. // Hit on a link with valid and non-javascript url and without embedded
  31. // image. |extra_data_for_type| and |href| will be the valid absolute url
  32. // of the link. |anchor_text| will contain the anchor text if the link is
  33. // an anchor tag. |img_src| will be empty.
  34. // Note 1: If the link url is invalid or javascript scheme, then the type
  35. // will be UNKNOWN_TYPE.
  36. // Note 2: Note that this matches SRC_ANCHOR_TYPE in the public WebView
  37. // Java API, but the actual tag can be something other than <a>, such as
  38. // <link> or <area>.
  39. // Note 3: |href| is not the raw attribute string, but the absolute link
  40. // url.
  41. kSrcLink = 7,
  42. // Same as kSrcLink except the link contains an image. |img_src| and
  43. // |extra_data_for_type| will contain the absolute valid url of the image
  44. // source. |href| will be the valid absolute url of the link. |anchor_text|
  45. // will be empty. All notes from kSrcLink apply.
  46. kSrcImageLink = 8,
  47. // Hit on an editable text input element. All other values will be empty.
  48. kEditText = 9,
  49. };
  50. // Holds all hit test data needed by public WebView APIs.
  51. // The Java counter part to this is AwContents.HitTestData.
  52. struct HitTestData {
  53. // The type of the hit test.
  54. HitTestDataType type;
  55. // The extra type of the hit test.
  56. string extra_data_for_type;
  57. // The valid absolute url of the link.
  58. mojo_base.mojom.String16 href;
  59. // The anchor text of the link
  60. mojo_base.mojom.String16 anchor_text;
  61. // The valid absolute url of the image source.
  62. url.mojom.Url img_src;
  63. };
  64. // Similar to blink::mojom::LocalMainFrame. This interface adds additional
  65. // things that webview needs from the main frame.
  66. interface LocalMainFrame {
  67. // Sets the initial page scale. This overrides initial scale set by
  68. // the meta viewport tag.
  69. SetInitialPageScale(double page_scale_factor);
  70. // Sets the zoom factor for text only. Used in layout modes other than
  71. // Text Autosizing.
  72. SetTextZoomFactor(float zoom_factor);
  73. // Do hit test at the given webview coordinate. "Webview" coordinates are
  74. // physical pixel values with the 0,0 at the top left of the current displayed
  75. // view (ie 0,0 is not the top left of the page if the page is scrolled).
  76. // AwRenderViewHostExt::OnUpdateHitTestData receives the result of the hit
  77. // test via AwViewHostMsg_UpdateHitTestData IPC message.
  78. HitTest(gfx.mojom.PointF touch_center, gfx.mojom.SizeF touch_area);
  79. // Requests for the renderer to determine if the document contains any image
  80. // elements.
  81. DocumentHasImage() => (bool has_images);
  82. // Resets Blink WebView scrolling and scale state. We need to call this
  83. // method whenever we want to guarantee that page's scale will be recalculated
  84. // by Blink.
  85. ResetScrollAndScaleState();
  86. // Tells Blink to smooth scroll to the specified location within |duration|
  87. // miliseconds.
  88. SmoothScroll(
  89. int32 target_x, int32 target_y, mojo_base.mojom.TimeDelta duration);
  90. };
  91. // Similar to blink::mojom::FrameHost. Implemented in Browser, this
  92. // interface defines frame-specific methods that will be invoked from the
  93. // renderer process (e.g. AwRenderFrameExt).
  94. interface FrameHost {
  95. // Response to AwViewMsg_DoHitTest.
  96. UpdateHitTestData(HitTestData data);
  97. // Calls whenever the contents size (as seen by RenderView) is changed.
  98. ContentsSizeChanged(gfx.mojom.Size contents_size);
  99. // Calls immediately before a top level navigation is initiated within Blink.
  100. // There are some exlusions, the most important ones are it is not sent
  101. // when creating a popup window, and not sent for application initiated
  102. // navigations. See AwContentRendererClient::HandleNavigation for all
  103. // cornercases. This is sent before updating the NavigationController state
  104. // or creating a URLRequest for the main frame resource.
  105. [Sync]
  106. ShouldOverrideUrlLoading(mojo_base.mojom.String16 url,
  107. bool has_user_gesture, bool is_redirect,
  108. bool is_outermost_main_frame)
  109. => (bool result);
  110. };