1 #ifndef BROWSER_WRT_WEB_CONTENTS_H_
2 #define BROWSER_WRT_WEB_CONTENTS_H_
7 #include "base/threading/thread.h"
8 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
9 #include "content/public/browser/context_menu_params.h"
10 #include "content/public/browser/render_frame_host_receiver_set.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "mojo/public/cpp/bindings/associated_remote.h"
13 #include "third_party/blink/public/mojom/choosers/popup_menu.mojom.h"
14 #include "wrt/src/common/wrt.mojom.h"
17 class SelectionControllerEfl;
19 class WebContentsViewAura;
20 class WebContentsViewAuraHelperEfl;
23 class SelectPickerBase;
27 class WRTNativeWindow;
28 class WRTContextMenuController;
29 class WRTWebViewDelegate;
32 : public content::WebContentsObserver,
33 public mojom::WRTBrowser {
35 static void WebContentsCreated(content::WebContents* web_contents);
36 static void WebContentsDeleted(content::WebContents* web_contents);
37 static bool IsObservedWebContents(content::WebContents* web_contents);
38 static WRTWebContents* FromWebContents(content::WebContents* web_contents);
39 static WRTWebContents* FromNativeWindow(WRTNativeWindow* window);
40 static content::WebContents* GetWebContents();
41 static void BindBrowser(
42 mojo::PendingAssociatedReceiver<mojom::WRTBrowser> receiver,
43 content::RenderFrameHost* render_frame_host);
45 virtual ~WRTWebContents();
47 WRTWebContents(const WRTWebContents&) = delete;
48 WRTWebContents& operator=(const WRTWebContents&) = delete;
50 mojom::WRTRenderer* GetRendererInterface();
52 // ContextMenuController or SelectionController related methods
53 void ShowContextMenu(const content::ContextMenuParams& params);
54 void OnSelectionRectReceived(const gfx::Rect& selection_rect) const;
55 void ExecuteEditCommand(const char* command, const char* value);
56 void HideContextMenu();
57 void ResetControllers();
59 void ShowPopupMenuImpl(std::vector<blink::mojom::MenuItemPtr> items,
62 const gfx::Rect& bounds,
63 double item_font_size);
64 bool IsPopupShowing() { return is_popup_showing_; }
65 void HidePopupMenuImpl();
66 void AdjustViewPortHeightToPopupMenu(bool is_popup_menu_visible);
67 void ScrollFocusedNodeIntoView();
69 bool ImePanelEnabled() { return show_ime_panel_; }
70 bool UseFloatingUI() { return ime_is_floating_; }
71 bool UseKeyPadWithoutUserAction() { return use_keypad_without_user_action_; }
74 WRTWebContents(content::WebContents* web_contents);
76 // content::WebContentsObserver
77 void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
78 void RenderViewReady() override;
79 void OnPageScaleFactorChanged(float page_scale_factor) override;
80 void DidFinishNavigation(content::NavigationHandle* navigation_handle) override;
81 void DidFinishLoad(content::RenderFrameHost* render_frame_host,
82 const GURL& validated_url) override;
84 void SetScaledContentSize();
86 content::RenderWidgetHostViewAura* rwhva() const;
87 Evas_Object* evas_object();
88 content::SelectionControllerEfl* GetSelectionController() const;
89 void UpdateContextMenuWithParams(const content::ContextMenuParams& params);
90 void ShowContextMenuInternal(const content::ContextMenuParams& params);
91 void HandleLongPressGesture(const content::ContextMenuParams& params);
93 content::WebContentsViewAura* GetWebContentsViewAura() const;
94 content::WebContentsViewAuraHelperEfl* GetWebContentsViewAuraHelper();
96 #if BUILDFLAG(IS_TIZEN_TV)
97 content::RWHVAuraCommonHelperEfl* GetRWHVAEflHelper();
100 void SetExtraCommandLineSwitches(content::RenderFrameHost* render_frame_host);
101 void SetLongPollingTimeout();
103 // mojom::WRTBrowser:
105 const std::string& internal_id,
106 mojo::PendingRemote<mojom::WRTServiceMessageListener> remote,
107 StartServiceCallback callback) override;
108 void StopService(const std::string& internal_id,
109 StopServiceCallback callback) override;
110 void PlayLinkEffect() override;
111 void DidChangeContentsSize(const gfx::Size& size) override;
112 void DidHandleGestureEventWithContext(bool is_content_editable) override;
114 static std::map<content::WebContents*, std::unique_ptr<WRTWebContents>> map_;
116 content::RenderFrameHostReceiverSet<mojom::WRTBrowser> receivers_;
117 mojo::AssociatedRemote<mojom::WRTRenderer> renderer_interface_;
119 gfx::Size contents_size_;
120 double page_scale_factor_;
121 std::unique_ptr<WRTContextMenuController> context_menu_;
122 std::unique_ptr<SelectPickerBase> select_picker_;
123 std::unique_ptr<WRTWebViewDelegate> web_view_delegate_;
124 base::Thread thread_;
126 bool show_ime_panel_;
127 bool ime_is_floating_;
128 bool use_keypad_without_user_action_;
129 bool is_popup_showing_ = false;
134 #endif // BROWSER_WRT_WEB_CONTENTS_H_