Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: extensions/browser/guest_view/web_view/web_view_guest.h

Issue 1392343002: Reduce the public method footprint of GuestViewBase and derived types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Reverted reordering in cc files. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 // Sets the transparency of the guest. 107 // Sets the transparency of the guest.
108 void SetAllowTransparency(bool allow); 108 void SetAllowTransparency(bool allow);
109 bool allow_transparency() const { return allow_transparency_; } 109 bool allow_transparency() const { return allow_transparency_; }
110 110
111 // Loads a data URL with a specified base URL and virtual URL. 111 // Loads a data URL with a specified base URL and virtual URL.
112 bool LoadDataWithBaseURL(const std::string& data_url, 112 bool LoadDataWithBaseURL(const std::string& data_url,
113 const std::string& base_url, 113 const std::string& base_url,
114 const std::string& virtual_url, 114 const std::string& virtual_url,
115 std::string* error); 115 std::string* error);
116 116
117 // GuestViewBase implementation.
118 bool CanRunInDetachedState() const override;
119 void CreateWebContents(const base::DictionaryValue& create_params,
120 const WebContentsCreatedCallback& callback) override;
121 void DidAttachToEmbedder() override;
122 void DidDropLink(const GURL& url) override;
123 void DidInitialize(const base::DictionaryValue& create_params) override;
124 void FindReply(content::WebContents* source,
125 int request_id,
126 int number_of_matches,
127 const gfx::Rect& selection_rect,
128 int active_match_ordinal,
129 bool final_update) override;
130 void GuestViewDidStopLoading() override;
131 void EmbedderFullscreenToggled(bool entered_fullscreen) override;
132 const char* GetAPINamespace() const override;
133 int GetTaskPrefix() const override;
134 void GuestDestroyed() override;
135 void GuestReady() override;
136 void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
137 const gfx::Size& new_size) override;
138 void GuestZoomChanged(double old_zoom_level, double new_zoom_level) override;
139 bool IsAutoSizeSupported() const override;
140 void SignalWhenReady(const base::Closure& callback) override;
141 bool ShouldHandleFindRequestsForEmbedder() const override;
142 void WillAttachToEmbedder() override;
143 void WillDestroy() override;
144
145 // WebContentsDelegate implementation.
146 bool AddMessageToConsole(content::WebContents* source,
147 int32 level,
148 const base::string16& message,
149 int32 line_no,
150 const base::string16& source_id) override;
151 void LoadProgressChanged(content::WebContents* source,
152 double progress) override;
153 void CloseContents(content::WebContents* source) override;
154 bool HandleContextMenu(const content::ContextMenuParams& params) override;
155 void HandleKeyboardEvent(
156 content::WebContents* source,
157 const content::NativeWebKeyboardEvent& event) override;
158 bool PreHandleGestureEvent(content::WebContents* source,
159 const blink::WebGestureEvent& event) override;
160 void RendererResponsive(content::WebContents* source) override;
161 void RendererUnresponsive(content::WebContents* source) override;
162 void RequestMediaAccessPermission(
163 content::WebContents* source,
164 const content::MediaStreamRequest& request,
165 const content::MediaResponseCallback& callback) override;
166 void RequestPointerLockPermission(
167 bool user_gesture,
168 bool last_unlocked_by_target,
169 const base::Callback<void(bool)>& callback) override;
170 bool CheckMediaAccessPermission(content::WebContents* source,
171 const GURL& security_origin,
172 content::MediaStreamType type) override;
173 void CanDownload(const GURL& url,
174 const std::string& request_method,
175 const base::Callback<void(bool)>& callback) override;
176 content::JavaScriptDialogManager* GetJavaScriptDialogManager(
177 content::WebContents* source) override;
178 void AddNewContents(content::WebContents* source,
179 content::WebContents* new_contents,
180 WindowOpenDisposition disposition,
181 const gfx::Rect& initial_rect,
182 bool user_gesture,
183 bool* was_blocked) override;
184 content::WebContents* OpenURLFromTab(
185 content::WebContents* source,
186 const content::OpenURLParams& params) override;
187 void WebContentsCreated(content::WebContents* source_contents,
188 int opener_render_frame_id,
189 const std::string& frame_name,
190 const GURL& target_url,
191 content::WebContents* new_contents) override;
192 void EnterFullscreenModeForTab(content::WebContents* web_contents,
193 const GURL& origin) override;
194 void ExitFullscreenModeForTab(content::WebContents* web_contents) override;
195 bool IsFullscreenForTabOrPending(
196 const content::WebContents* web_contents) const override;
197
198 // NotificationObserver implementation.
199 void Observe(int type,
200 const content::NotificationSource& source,
201 const content::NotificationDetails& details) override;
202
203 // Begin or continue a find request. 117 // Begin or continue a find request.
204 void StartFindInternal( 118 void StartFind(const base::string16& search_text,
205 const base::string16& search_text, 119 const blink::WebFindOptions& options,
206 const blink::WebFindOptions& options, 120 scoped_refptr<WebViewInternalFindFunction> find_function);
207 scoped_refptr<WebViewInternalFindFunction> find_function);
208 121
209 // Conclude a find request to clear highlighting. 122 // Conclude a find request to clear highlighting.
210 void StopFindingInternal(content::StopFindAction); 123 void StopFinding(content::StopFindAction);
211 124
212 // If possible, navigate the guest to |relative_index| entries away from the 125 // If possible, navigate the guest to |relative_index| entries away from the
213 // current navigation entry. Returns true on success. 126 // current navigation entry. Returns true on success.
214 bool Go(int relative_index); 127 bool Go(int relative_index);
215 128
216 // Reload the guest. 129 // Reload the guest.
217 void Reload(); 130 void Reload();
218 131
219 using PermissionResponseCallback =
220 base::Callback<void(bool /* allow */,
221 const std::string& /* user_input */)>;
222 int RequestPermission(
223 WebViewPermissionType permission_type,
224 const base::DictionaryValue& request_info,
225 const PermissionResponseCallback& callback,
226 bool allowed_by_default);
227
228 // Requests Geolocation Permission from the embedder.
229 void RequestGeolocationPermission(int bridge_id,
230 const GURL& requesting_frame,
231 bool user_gesture,
232 const base::Callback<void(bool)>& callback);
233 void CancelGeolocationPermissionRequest(int bridge_id);
234
235 // Called when file system access is requested by the guest content using the
236 // HTML5 file system API in main thread, or a worker thread.
237 // The request is plumbed through the <webview> permission request API. The
238 // request will be:
239 // - Allowed if the embedder explicitly allowed it.
240 // - Denied if the embedder explicitly denied.
241 // - Determined by the guest's content settings if the embedder does not
242 // perform an explicit action.
243 void RequestFileSystemPermission(const GURL& url,
244 bool allowed_by_default,
245 const base::Callback<void(bool)>& callback);
246
247 // Overrides the user agent for this guest. 132 // Overrides the user agent for this guest.
248 // This affects subsequent guest navigations. 133 // This affects subsequent guest navigations.
249 void SetUserAgentOverride(const std::string& user_agent_override); 134 void SetUserAgentOverride(const std::string& user_agent_override);
250 135
251 // Stop loading the guest. 136 // Stop loading the guest.
252 void Stop(); 137 void Stop();
253 138
254 // Kill the guest process. 139 // Kill the guest process.
255 void Terminate(); 140 void Terminate();
256 141
257 // Clears data in the storage partition of this guest. 142 // Clears data in the storage partition of this guest.
258 // 143 //
259 // Partition data that are newer than |removal_since| will be removed. 144 // Partition data that are newer than |removal_since| will be removed.
260 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. 145 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask.
261 bool ClearData(const base::Time remove_since, 146 bool ClearData(const base::Time remove_since,
262 uint32 removal_mask, 147 uint32 removal_mask,
263 const base::Closure& callback); 148 const base::Closure& callback);
264 149
265 ScriptExecutor* script_executor() { return script_executor_.get(); } 150 ScriptExecutor* script_executor() { return script_executor_.get(); }
266 151
267 scoped_ptr<WebViewGuestDelegate> SetDelegateForTesting(
268 scoped_ptr<WebViewGuestDelegate> delegate) {
269 web_view_guest_delegate_.swap(delegate);
270 return delegate.Pass();
271 }
272
273 private: 152 private:
274 friend class WebViewPermissionHelper; 153 friend class WebViewPermissionHelper;
275 154
276 explicit WebViewGuest(content::WebContents* owner_web_contents); 155 explicit WebViewGuest(content::WebContents* owner_web_contents);
277 156
278 ~WebViewGuest() override; 157 ~WebViewGuest() override;
279 158
280 void ClearDataInternal(const base::Time remove_since, 159 void ClearDataInternal(const base::Time remove_since,
281 uint32 removal_mask, 160 uint32 removal_mask,
282 const base::Closure& callback); 161 const base::Closure& callback);
283 162
284 void OnWebViewNewWindowResponse(int new_window_instance_id, 163 void OnWebViewNewWindowResponse(int new_window_instance_id,
285 bool allow, 164 bool allow,
286 const std::string& user_input); 165 const std::string& user_input);
287 166
288 void OnFullscreenPermissionDecided(bool allowed, 167 void OnFullscreenPermissionDecided(bool allowed,
289 const std::string& user_input); 168 const std::string& user_input);
290 bool GuestMadeEmbedderFullscreen() const; 169 bool GuestMadeEmbedderFullscreen() const;
291 void SetFullscreenState(bool is_fullscreen); 170 void SetFullscreenState(bool is_fullscreen);
292 171
172 // GuestViewBase implementation.
173 bool CanRunInDetachedState() const final;
174 void CreateWebContents(const base::DictionaryValue& create_params,
175 const WebContentsCreatedCallback& callback) final;
176 void DidAttachToEmbedder() final;
177 void DidDropLink(const GURL& url) final;
178 void DidInitialize(const base::DictionaryValue& create_params) final;
179 void EmbedderFullscreenToggled(bool entered_fullscreen) final;
180 void FindReply(content::WebContents* source,
181 int request_id,
182 int number_of_matches,
183 const gfx::Rect& selection_rect,
184 int active_match_ordinal,
185 bool final_update) final;
186 const char* GetAPINamespace() const final;
187 int GetTaskPrefix() const final;
188 void GuestDestroyed() final;
189 void GuestReady() final;
190 void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
191 const gfx::Size& new_size) final;
192 void GuestViewDidStopLoading() final;
193 void GuestZoomChanged(double old_zoom_level, double new_zoom_level) final;
194 bool IsAutoSizeSupported() const final;
195 void SetContextMenuPosition(const gfx::Point& position) final;
196 void SignalWhenReady(const base::Closure& callback) final;
197 bool ShouldHandleFindRequestsForEmbedder() const final;
198 void WillAttachToEmbedder() final;
199 void WillDestroy() final;
200
201 // NotificationObserver implementation.
202 void Observe(int type,
203 const content::NotificationSource& source,
204 const content::NotificationDetails& details) final;
205
206 // WebContentsDelegate implementation.
207 bool AddMessageToConsole(content::WebContents* source,
208 int32 level,
209 const base::string16& message,
210 int32 line_no,
211 const base::string16& source_id) final;
212 void CloseContents(content::WebContents* source) final;
213 bool HandleContextMenu(const content::ContextMenuParams& params) final;
214 void HandleKeyboardEvent(content::WebContents* source,
215 const content::NativeWebKeyboardEvent& event) final;
216 void LoadProgressChanged(content::WebContents* source, double progress) final;
217 bool PreHandleGestureEvent(content::WebContents* source,
218 const blink::WebGestureEvent& event) final;
219 void RendererResponsive(content::WebContents* source) final;
220 void RendererUnresponsive(content::WebContents* source) final;
221 void RequestMediaAccessPermission(
222 content::WebContents* source,
223 const content::MediaStreamRequest& request,
224 const content::MediaResponseCallback& callback) final;
225 void RequestPointerLockPermission(
226 bool user_gesture,
227 bool last_unlocked_by_target,
228 const base::Callback<void(bool)>& callback) final;
229 bool CheckMediaAccessPermission(content::WebContents* source,
230 const GURL& security_origin,
231 content::MediaStreamType type) final;
232 void CanDownload(const GURL& url,
233 const std::string& request_method,
234 const base::Callback<void(bool)>& callback) final;
235 content::JavaScriptDialogManager* GetJavaScriptDialogManager(
236 content::WebContents* source) final;
237 void AddNewContents(content::WebContents* source,
238 content::WebContents* new_contents,
239 WindowOpenDisposition disposition,
240 const gfx::Rect& initial_rect,
241 bool user_gesture,
242 bool* was_blocked) final;
243 content::WebContents* OpenURLFromTab(
244 content::WebContents* source,
245 const content::OpenURLParams& params) final;
246 void WebContentsCreated(content::WebContents* source_contents,
247 int opener_render_frame_id,
248 const std::string& frame_name,
249 const GURL& target_url,
250 content::WebContents* new_contents) final;
251 void EnterFullscreenModeForTab(content::WebContents* web_contents,
252 const GURL& origin) final;
253 void ExitFullscreenModeForTab(content::WebContents* web_contents) final;
254 bool IsFullscreenForTabOrPending(
255 const content::WebContents* web_contents) const final;
256
293 // WebContentsObserver implementation. 257 // WebContentsObserver implementation.
294 void DidCommitProvisionalLoadForFrame( 258 void DidCommitProvisionalLoadForFrame(
295 content::RenderFrameHost* render_frame_host, 259 content::RenderFrameHost* render_frame_host,
296 const GURL& url, 260 const GURL& url,
297 ui::PageTransition transition_type) override; 261 ui::PageTransition transition_type) final;
298 void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, 262 void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host,
299 const GURL& validated_url, 263 const GURL& validated_url,
300 int error_code, 264 int error_code,
301 const base::string16& error_description, 265 const base::string16& error_description,
302 bool was_ignored_by_handler) override; 266 bool was_ignored_by_handler) final;
303 void DidStartProvisionalLoadForFrame( 267 void DidStartProvisionalLoadForFrame(
304 content::RenderFrameHost* render_frame_host, 268 content::RenderFrameHost* render_frame_host,
305 const GURL& validated_url, 269 const GURL& validated_url,
306 bool is_error_page, 270 bool is_error_page,
307 bool is_iframe_srcdoc) override; 271 bool is_iframe_srcdoc) final;
308 void RenderProcessGone(base::TerminationStatus status) override; 272 void RenderProcessGone(base::TerminationStatus status) final;
309 void UserAgentOverrideSet(const std::string& user_agent) override; 273 void UserAgentOverrideSet(const std::string& user_agent) final;
310 void FrameNameChanged(content::RenderFrameHost* render_frame_host, 274 void FrameNameChanged(content::RenderFrameHost* render_frame_host,
311 const std::string& name) override; 275 const std::string& name) final;
312 276
313 // Informs the embedder of a frame name change. 277 // Informs the embedder of a frame name change.
314 void ReportFrameNameChange(const std::string& name); 278 void ReportFrameNameChange(const std::string& name);
315 279
316 // Called after the load handler is called in the guest's main frame. 280 // Called after the load handler is called in the guest's main frame.
317 void LoadHandlerCalled(); 281 void LoadHandlerCalled();
318 282
319 // Called when a redirect notification occurs. 283 // Called when a redirect notification occurs.
320 void LoadRedirect(const GURL& old_url, 284 void LoadRedirect(const GURL& old_url,
321 const GURL& new_url, 285 const GURL& new_url,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 // Creates a new guest window owned by this WebViewGuest. 317 // Creates a new guest window owned by this WebViewGuest.
354 void CreateNewGuestWebViewWindow(const content::OpenURLParams& params); 318 void CreateNewGuestWebViewWindow(const content::OpenURLParams& params);
355 319
356 void NewGuestWebViewCallback(const content::OpenURLParams& params, 320 void NewGuestWebViewCallback(const content::OpenURLParams& params,
357 content::WebContents* guest_web_contents); 321 content::WebContents* guest_web_contents);
358 322
359 bool HandleKeyboardShortcuts(const content::NativeWebKeyboardEvent& event); 323 bool HandleKeyboardShortcuts(const content::NativeWebKeyboardEvent& event);
360 324
361 void ApplyAttributes(const base::DictionaryValue& params); 325 void ApplyAttributes(const base::DictionaryValue& params);
362 326
363 void SetContextMenuPosition(const gfx::Point& position) override;
364
365 // Identifies the set of rules registries belonging to this guest. 327 // Identifies the set of rules registries belonging to this guest.
366 int rules_registry_id_; 328 int rules_registry_id_;
367 329
368 // Handles find requests and replies for the webview find API. 330 // Handles find requests and replies for the webview find API.
369 WebViewFindHelper find_helper_; 331 WebViewFindHelper find_helper_;
370 332
371 base::ObserverList<ScriptExecutionObserver> script_observers_; 333 base::ObserverList<ScriptExecutionObserver> script_observers_;
372 scoped_ptr<ScriptExecutor> script_executor_; 334 scoped_ptr<ScriptExecutor> script_executor_;
373 335
374 content::NotificationRegistrar notification_registrar_; 336 content::NotificationRegistrar notification_registrar_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // This is used to ensure pending tasks will not fire after this object is 383 // This is used to ensure pending tasks will not fire after this object is
422 // destroyed. 384 // destroyed.
423 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_; 385 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_;
424 386
425 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); 387 DISALLOW_COPY_AND_ASSIGN(WebViewGuest);
426 }; 388 };
427 389
428 } // namespace extensions 390 } // namespace extensions
429 391
430 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ 392 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698