[email protected] | b165655 | 2014-06-09 19:59:38 | [diff] [blame] | 1 | // Copyright 2014 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 | |||||
5 | #ifndef ANDROID_WEBVIEW_RENDERER_AW_RENDER_FRAME_EXT_H_ | ||||
6 | #define ANDROID_WEBVIEW_RENDERER_AW_RENDER_FRAME_EXT_H_ | ||||
7 | |||||
Dave Tapuska | 046559c8 | 2020-11-06 18:15:09 | [diff] [blame] | 8 | #include "android_webview/common/mojom/frame.mojom.h" |
avi | de7d5c2 | 2015-12-20 05:48:44 | [diff] [blame] | 9 | #include "base/macros.h" |
[email protected] | b165655 | 2014-06-09 19:59:38 | [diff] [blame] | 10 | #include "content/public/renderer/render_frame_observer.h" |
Dave Tapuska | 046559c8 | 2020-11-06 18:15:09 | [diff] [blame] | 11 | #include "mojo/public/cpp/bindings/associated_receiver.h" |
Gyuyoung Kim | 009ecd0 | 2020-12-11 23:27:52 | [diff] [blame] | 12 | #include "mojo/public/cpp/bindings/associated_remote.h" |
Dave Tapuska | 046559c8 | 2020-11-06 18:15:09 | [diff] [blame] | 13 | #include "mojo/public/cpp/bindings/pending_associated_receiver.h" |
Ken Rockot | 0aad7ec | 2018-07-31 15:58:44 | [diff] [blame] | 14 | #include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h" |
Tao Bai | 1d5460a | 2017-08-10 01:02:23 | [diff] [blame] | 15 | #include "third_party/skia/include/core/SkColor.h" |
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 16 | #include "ui/gfx/geometry/point_f.h" |
17 | #include "ui/gfx/geometry/size.h" | ||||
18 | #include "ui/gfx/geometry/size_f.h" | ||||
avi | 0363eb92 | 2016-03-10 23:53:46 | [diff] [blame] | 19 | #include "url/origin.h" |
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 20 | |
21 | namespace blink { | ||||
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 22 | class WebFrameWidget; |
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 23 | class WebView; |
24 | } | ||||
[email protected] | b165655 | 2014-06-09 19:59:38 | [diff] [blame] | 25 | |
26 | namespace android_webview { | ||||
27 | |||||
28 | // Render process side of AwRenderViewHostExt, this provides cross-process | ||||
29 | // implementation of miscellaneous WebView functions that we need to poke | ||||
30 | // WebKit directly to implement (and that aren't needed in the chrome app). | ||||
Dave Tapuska | 046559c8 | 2020-11-06 18:15:09 | [diff] [blame] | 31 | class AwRenderFrameExt : public content::RenderFrameObserver, |
32 | mojom::LocalMainFrame { | ||||
[email protected] | b165655 | 2014-06-09 19:59:38 | [diff] [blame] | 33 | public: |
Christian O. Andersson | 822effcf | 2019-01-25 17:00:25 | [diff] [blame] | 34 | explicit AwRenderFrameExt(content::RenderFrame* render_frame); |
35 | |||||
36 | static AwRenderFrameExt* FromRenderFrame(content::RenderFrame* render_frame); | ||||
37 | |||||
[email protected] | b165655 | 2014-06-09 19:59:38 | [diff] [blame] | 38 | private: |
dcheng | 9f9f934 | 2015-02-04 01:50:17 | [diff] [blame] | 39 | ~AwRenderFrameExt() override; |
[email protected] | b165655 | 2014-06-09 19:59:38 | [diff] [blame] | 40 | |
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 41 | // RenderFrameObserver: |
Ken Rockot | 0aad7ec | 2018-07-31 15:58:44 | [diff] [blame] | 42 | bool OnAssociatedInterfaceRequestForFrame( |
Tao Bai | 1d5460a | 2017-08-10 01:02:23 | [diff] [blame] | 43 | const std::string& interface_name, |
Ken Rockot | 0aad7ec | 2018-07-31 15:58:44 | [diff] [blame] | 44 | mojo::ScopedInterfaceEndpointHandle* handle) override; |
Dmitry Gozman | 02dd827 | 2020-06-09 20:01:23 | [diff] [blame] | 45 | void DidCommitProvisionalLoad(ui::PageTransition transition) override; |
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 46 | |
47 | bool OnMessageReceived(const IPC::Message& message) override; | ||||
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 48 | void FocusedElementChanged(const blink::WebElement& element) override; |
xjz | 694b50a9 | 2016-06-07 21:49:37 | [diff] [blame] | 49 | void OnDestruct() override; |
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 50 | |
Sergio Villar Senin | 2127d7b | 2019-07-31 17:29:58 | [diff] [blame] | 51 | void OnSmoothScroll(int target_x, int target_y, base::TimeDelta duration); |
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 52 | |
Dave Tapuska | 046559c8 | 2020-11-06 18:15:09 | [diff] [blame] | 53 | // mojom::LocalMainFrame overrides: |
54 | void SetBackgroundColor(SkColor c) override; | ||||
Gyuyoung Kim | 53ebffc1 | 2020-12-12 05:36:33 | [diff] [blame^] | 55 | void SetInitialPageScale(double page_scale_factor) override; |
Gyuyoung Kim | b808611 | 2020-12-12 02:03:15 | [diff] [blame] | 56 | void SetTextZoomFactor(float zoom_factor) override; |
Gyuyoung Kim | 71d2d28 | 2020-12-02 22:31:30 | [diff] [blame] | 57 | void HitTest(const gfx::PointF& touch_center, |
58 | const gfx::SizeF& touch_area) override; | ||||
Gyuyoung Kim | ddb9bd5 | 2020-12-03 02:19:42 | [diff] [blame] | 59 | void DocumentHasImage(DocumentHasImageCallback callback) override; |
Gyuyoung Kim | c4b48b96 | 2020-12-12 03:08:58 | [diff] [blame] | 60 | void ResetScrollAndScaleState() override; |
Dave Tapuska | 046559c8 | 2020-11-06 18:15:09 | [diff] [blame] | 61 | |
62 | void BindLocalMainFrame( | ||||
63 | mojo::PendingAssociatedReceiver<mojom::LocalMainFrame> pending_receiver); | ||||
64 | |||||
Gyuyoung Kim | 009ecd0 | 2020-12-11 23:27:52 | [diff] [blame] | 65 | const mojo::AssociatedRemote<mojom::FrameHost>& GetFrameHost(); |
66 | |||||
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 67 | blink::WebView* GetWebView(); |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 68 | blink::WebFrameWidget* GetWebFrameWidget(); |
hush | 28fab0866 | 2016-01-14 18:42:51 | [diff] [blame] | 69 | |
avi | 0363eb92 | 2016-03-10 23:53:46 | [diff] [blame] | 70 | url::Origin last_origin_; |
71 | |||||
Ken Rockot | 0aad7ec | 2018-07-31 15:58:44 | [diff] [blame] | 72 | blink::AssociatedInterfaceRegistry registry_; |
Dave Tapuska | 046559c8 | 2020-11-06 18:15:09 | [diff] [blame] | 73 | mojo::AssociatedReceiver<mojom::LocalMainFrame> local_main_frame_receiver_{ |
74 | this}; | ||||
Tao Bai | 1d5460a | 2017-08-10 01:02:23 | [diff] [blame] | 75 | |
Gyuyoung Kim | 009ecd0 | 2020-12-11 23:27:52 | [diff] [blame] | 76 | mojo::AssociatedRemote<mojom::FrameHost> frame_host_remote_; |
77 | |||||
[email protected] | b165655 | 2014-06-09 19:59:38 | [diff] [blame] | 78 | DISALLOW_COPY_AND_ASSIGN(AwRenderFrameExt); |
79 | }; | ||||
80 | |||||
fanjinsong | db647e04 | 2017-06-09 20:26:45 | [diff] [blame] | 81 | } // namespace android_webview |
[email protected] | b165655 | 2014-06-09 19:59:38 | [diff] [blame] | 82 | |
83 | #endif // ANDROID_WEBVIEW_RENDERER_AW_RENDER_FRAME_EXT_H_ |