OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 5 #ifndef EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 6 #define EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 // Sets the transparency of the guest. | 77 // Sets the transparency of the guest. |
78 void SetAllowTransparency(bool allow); | 78 void SetAllowTransparency(bool allow); |
79 | 79 |
80 // Loads a data URL with a specified base URL and virtual URL. | 80 // Loads a data URL with a specified base URL and virtual URL. |
81 bool LoadDataWithBaseURL(const std::string& data_url, | 81 bool LoadDataWithBaseURL(const std::string& data_url, |
82 const std::string& base_url, | 82 const std::string& base_url, |
83 const std::string& virtual_url, | 83 const std::string& virtual_url, |
84 std::string* error); | 84 std::string* error); |
85 | 85 |
86 // GuestViewBase implementation. | 86 // GuestViewBase implementation. |
87 virtual const char* GetAPINamespace() const override; | 87 const char* GetAPINamespace() const override; |
88 virtual int GetTaskPrefix() const override; | 88 int GetTaskPrefix() const override; |
89 virtual void CreateWebContents( | 89 void CreateWebContents(const std::string& embedder_extension_id, |
90 const std::string& embedder_extension_id, | 90 int embedder_render_process_id, |
91 int embedder_render_process_id, | 91 const GURL& embedder_site_url, |
92 const GURL& embedder_site_url, | 92 const base::DictionaryValue& create_params, |
93 const base::DictionaryValue& create_params, | 93 const WebContentsCreatedCallback& callback) override; |
94 const WebContentsCreatedCallback& callback) override; | 94 void DidAttachToEmbedder() override; |
95 virtual void DidAttachToEmbedder() override; | 95 void DidInitialize() override; |
96 virtual void DidInitialize() override; | 96 void DidStopLoading() override; |
97 virtual void DidStopLoading() override; | 97 void EmbedderDestroyed() override; |
98 virtual void EmbedderDestroyed() override; | 98 void GuestDestroyed() override; |
99 virtual void GuestDestroyed() override; | 99 void GuestReady() override; |
100 virtual void GuestReady() override; | 100 void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size, |
101 virtual void GuestSizeChangedDueToAutoSize( | 101 const gfx::Size& new_size) override; |
102 const gfx::Size& old_size, | 102 bool IsAutoSizeSupported() const override; |
103 const gfx::Size& new_size) override; | 103 bool IsDragAndDropEnabled() const override; |
104 virtual bool IsAutoSizeSupported() const override; | 104 void WillAttachToEmbedder() override; |
105 virtual bool IsDragAndDropEnabled() const override; | 105 void WillDestroy() override; |
106 virtual void WillAttachToEmbedder() override; | |
107 virtual void WillDestroy() override; | |
108 | 106 |
109 // WebContentsDelegate implementation. | 107 // WebContentsDelegate implementation. |
110 virtual bool AddMessageToConsole(content::WebContents* source, | 108 bool AddMessageToConsole(content::WebContents* source, |
111 int32 level, | 109 int32 level, |
112 const base::string16& message, | 110 const base::string16& message, |
113 int32 line_no, | 111 int32 line_no, |
114 const base::string16& source_id) override; | 112 const base::string16& source_id) override; |
115 virtual void LoadProgressChanged(content::WebContents* source, | 113 void LoadProgressChanged(content::WebContents* source, |
116 double progress) override; | 114 double progress) override; |
117 virtual void CloseContents(content::WebContents* source) override; | 115 void CloseContents(content::WebContents* source) override; |
118 virtual void FindReply(content::WebContents* source, | 116 void FindReply(content::WebContents* source, |
119 int request_id, | 117 int request_id, |
120 int number_of_matches, | 118 int number_of_matches, |
121 const gfx::Rect& selection_rect, | 119 const gfx::Rect& selection_rect, |
122 int active_match_ordinal, | 120 int active_match_ordinal, |
123 bool final_update) override; | 121 bool final_update) override; |
124 virtual bool HandleContextMenu( | 122 bool HandleContextMenu(const content::ContextMenuParams& params) override; |
125 const content::ContextMenuParams& params) override; | 123 void HandleKeyboardEvent( |
126 virtual void HandleKeyboardEvent( | |
127 content::WebContents* source, | 124 content::WebContents* source, |
128 const content::NativeWebKeyboardEvent& event) override; | 125 const content::NativeWebKeyboardEvent& event) override; |
129 virtual void RendererResponsive(content::WebContents* source) override; | 126 void RendererResponsive(content::WebContents* source) override; |
130 virtual void RendererUnresponsive(content::WebContents* source) override; | 127 void RendererUnresponsive(content::WebContents* source) override; |
131 virtual void RequestMediaAccessPermission( | 128 void RequestMediaAccessPermission( |
132 content::WebContents* source, | 129 content::WebContents* source, |
133 const content::MediaStreamRequest& request, | 130 const content::MediaStreamRequest& request, |
134 const content::MediaResponseCallback& callback) override; | 131 const content::MediaResponseCallback& callback) override; |
135 virtual bool CheckMediaAccessPermission( | 132 bool CheckMediaAccessPermission(content::WebContents* source, |
136 content::WebContents* source, | 133 const GURL& security_origin, |
137 const GURL& security_origin, | 134 content::MediaStreamType type) override; |
138 content::MediaStreamType type) override; | 135 void CanDownload(content::RenderViewHost* render_view_host, |
139 virtual void CanDownload(content::RenderViewHost* render_view_host, | 136 const GURL& url, |
140 const GURL& url, | 137 const std::string& request_method, |
141 const std::string& request_method, | 138 const base::Callback<void(bool)>& callback) override; |
142 const base::Callback<void(bool)>& callback) override; | 139 content::JavaScriptDialogManager* GetJavaScriptDialogManager() override; |
143 virtual content::JavaScriptDialogManager* | 140 content::ColorChooser* OpenColorChooser( |
144 GetJavaScriptDialogManager() override; | |
145 virtual content::ColorChooser* OpenColorChooser( | |
146 content::WebContents* web_contents, | 141 content::WebContents* web_contents, |
147 SkColor color, | 142 SkColor color, |
148 const std::vector<content::ColorSuggestion>& suggestions) override; | 143 const std::vector<content::ColorSuggestion>& suggestions) override; |
149 virtual void AddNewContents(content::WebContents* source, | 144 void AddNewContents(content::WebContents* source, |
150 content::WebContents* new_contents, | 145 content::WebContents* new_contents, |
151 WindowOpenDisposition disposition, | 146 WindowOpenDisposition disposition, |
152 const gfx::Rect& initial_pos, | 147 const gfx::Rect& initial_pos, |
153 bool user_gesture, | 148 bool user_gesture, |
154 bool* was_blocked) override; | 149 bool* was_blocked) override; |
155 virtual content::WebContents* OpenURLFromTab( | 150 content::WebContents* OpenURLFromTab( |
156 content::WebContents* source, | 151 content::WebContents* source, |
157 const content::OpenURLParams& params) override; | 152 const content::OpenURLParams& params) override; |
158 virtual void WebContentsCreated(content::WebContents* source_contents, | 153 void WebContentsCreated(content::WebContents* source_contents, |
159 int opener_render_frame_id, | 154 int opener_render_frame_id, |
160 const base::string16& frame_name, | 155 const base::string16& frame_name, |
161 const GURL& target_url, | 156 const GURL& target_url, |
162 content::WebContents* new_contents) override; | 157 content::WebContents* new_contents) override; |
163 | 158 |
164 // BrowserPluginGuestDelegate implementation. | 159 // BrowserPluginGuestDelegate implementation. |
165 virtual content::WebContents* CreateNewGuestWindow( | 160 content::WebContents* CreateNewGuestWindow( |
166 const content::WebContents::CreateParams& create_params) override; | 161 const content::WebContents::CreateParams& create_params) override; |
167 virtual void RequestPointerLockPermission( | 162 void RequestPointerLockPermission( |
168 bool user_gesture, | 163 bool user_gesture, |
169 bool last_unlocked_by_target, | 164 bool last_unlocked_by_target, |
170 const base::Callback<void(bool)>& callback) override; | 165 const base::Callback<void(bool)>& callback) override; |
171 // NotificationObserver implementation. | 166 // NotificationObserver implementation. |
172 virtual void Observe(int type, | 167 void Observe(int type, |
173 const content::NotificationSource& source, | 168 const content::NotificationSource& source, |
174 const content::NotificationDetails& details) override; | 169 const content::NotificationDetails& details) override; |
175 | 170 |
176 // Returns the current zoom factor. | 171 // Returns the current zoom factor. |
177 double GetZoom(); | 172 double GetZoom(); |
178 | 173 |
179 // Begin or continue a find request. | 174 // Begin or continue a find request. |
180 void StartFinding(const base::string16& search_text, | 175 void StartFinding(const base::string16& search_text, |
181 const blink::WebFindOptions& options, | 176 const blink::WebFindOptions& options, |
182 scoped_refptr<WebViewInternalFindFunction> find_function); | 177 scoped_refptr<WebViewInternalFindFunction> find_function); |
183 | 178 |
184 // Conclude a find request to clear highlighting. | 179 // Conclude a find request to clear highlighting. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 uint32 removal_mask, | 232 uint32 removal_mask, |
238 const base::Closure& callback); | 233 const base::Closure& callback); |
239 | 234 |
240 ScriptExecutor* script_executor() { return script_executor_.get(); } | 235 ScriptExecutor* script_executor() { return script_executor_.get(); } |
241 | 236 |
242 private: | 237 private: |
243 friend class WebViewPermissionHelper; | 238 friend class WebViewPermissionHelper; |
244 WebViewGuest(content::BrowserContext* browser_context, | 239 WebViewGuest(content::BrowserContext* browser_context, |
245 int guest_instance_id); | 240 int guest_instance_id); |
246 | 241 |
247 virtual ~WebViewGuest(); | 242 ~WebViewGuest() override; |
248 | 243 |
249 void AttachWebViewHelpers(content::WebContents* contents); | 244 void AttachWebViewHelpers(content::WebContents* contents); |
250 | 245 |
251 void OnWebViewNewWindowResponse(int new_window_instance_id, | 246 void OnWebViewNewWindowResponse(int new_window_instance_id, |
252 bool allow, | 247 bool allow, |
253 const std::string& user_input); | 248 const std::string& user_input); |
254 | 249 |
255 // WebContentsObserver implementation. | 250 // WebContentsObserver implementation. |
256 virtual void DidCommitProvisionalLoadForFrame( | 251 void DidCommitProvisionalLoadForFrame( |
257 content::RenderFrameHost* render_frame_host, | 252 content::RenderFrameHost* render_frame_host, |
258 const GURL& url, | 253 const GURL& url, |
259 ui::PageTransition transition_type) override; | 254 ui::PageTransition transition_type) override; |
260 virtual void DidFailProvisionalLoad( | 255 void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, |
261 content::RenderFrameHost* render_frame_host, | 256 const GURL& validated_url, |
262 const GURL& validated_url, | 257 int error_code, |
263 int error_code, | 258 const base::string16& error_description) override; |
264 const base::string16& error_description) override; | 259 void DidStartProvisionalLoadForFrame( |
265 virtual void DidStartProvisionalLoadForFrame( | |
266 content::RenderFrameHost* render_frame_host, | 260 content::RenderFrameHost* render_frame_host, |
267 const GURL& validated_url, | 261 const GURL& validated_url, |
268 bool is_error_page, | 262 bool is_error_page, |
269 bool is_iframe_srcdoc) override; | 263 bool is_iframe_srcdoc) override; |
270 virtual void DocumentLoadedInFrame( | 264 void DocumentLoadedInFrame( |
271 content::RenderFrameHost* render_frame_host) override; | 265 content::RenderFrameHost* render_frame_host) override; |
272 virtual bool OnMessageReceived( | 266 bool OnMessageReceived(const IPC::Message& message, |
273 const IPC::Message& message, | 267 content::RenderFrameHost* render_frame_host) override; |
274 content::RenderFrameHost* render_frame_host) override; | 268 void RenderProcessGone(base::TerminationStatus status) override; |
275 virtual void RenderProcessGone(base::TerminationStatus status) override; | 269 void UserAgentOverrideSet(const std::string& user_agent) override; |
276 virtual void UserAgentOverrideSet(const std::string& user_agent) override; | |
277 | 270 |
278 // Informs the embedder of a frame name change. | 271 // Informs the embedder of a frame name change. |
279 void ReportFrameNameChange(const std::string& name); | 272 void ReportFrameNameChange(const std::string& name); |
280 | 273 |
281 // Called after the load handler is called in the guest's main frame. | 274 // Called after the load handler is called in the guest's main frame. |
282 void LoadHandlerCalled(); | 275 void LoadHandlerCalled(); |
283 | 276 |
284 // Called when a redirect notification occurs. | 277 // Called when a redirect notification occurs. |
285 void LoadRedirect(const GURL& old_url, | 278 void LoadRedirect(const GURL& old_url, |
286 const GURL& new_url, | 279 const GURL& new_url, |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 // This is used to ensure pending tasks will not fire after this object is | 365 // This is used to ensure pending tasks will not fire after this object is |
373 // destroyed. | 366 // destroyed. |
374 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_; | 367 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_; |
375 | 368 |
376 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); | 369 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); |
377 }; | 370 }; |
378 | 371 |
379 } // namespace extensions | 372 } // namespace extensions |
380 | 373 |
381 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ | 374 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ |
OLD | NEW |