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

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: 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 StartFindInternal(
Fady Samuel 2015/10/09 22:35:19 Internal things should not be public? Why are thes
paulmeyer 2015/10/16 21:13:03 I originally named these without the "Internal" su
Fady Samuel 2015/10/16 21:17:29 Yea, I'd name them back if possible.
paulmeyer 2015/10/21 19:45:13 I discovered while renaming that StopFinding() col
205 const base::string16& search_text, 119 const base::string16& search_text,
206 const blink::WebFindOptions& options, 120 const blink::WebFindOptions& options,
207 scoped_refptr<WebViewInternalFindFunction> find_function); 121 scoped_refptr<WebViewInternalFindFunction> find_function);
208 122
209 // Conclude a find request to clear highlighting. 123 // Conclude a find request to clear highlighting.
210 void StopFindingInternal(content::StopFindAction); 124 void StopFindingInternal(content::StopFindAction);
211 125
212 // If possible, navigate the guest to |relative_index| entries away from the 126 // If possible, navigate the guest to |relative_index| entries away from the
213 // current navigation entry. Returns true on success. 127 // current navigation entry. Returns true on success.
214 bool Go(int relative_index); 128 bool Go(int relative_index);
215 129
216 // Reload the guest. 130 // Reload the guest.
217 void Reload(); 131 void Reload();
218 132
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. 133 // Overrides the user agent for this guest.
248 // This affects subsequent guest navigations. 134 // This affects subsequent guest navigations.
249 void SetUserAgentOverride(const std::string& user_agent_override); 135 void SetUserAgentOverride(const std::string& user_agent_override);
250 136
251 // Stop loading the guest. 137 // Stop loading the guest.
252 void Stop(); 138 void Stop();
253 139
254 // Kill the guest process. 140 // Kill the guest process.
255 void Terminate(); 141 void Terminate();
256 142
257 // Clears data in the storage partition of this guest. 143 // Clears data in the storage partition of this guest.
258 // 144 //
259 // Partition data that are newer than |removal_since| will be removed. 145 // Partition data that are newer than |removal_since| will be removed.
260 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask. 146 // |removal_mask| corresponds to bitmask in StoragePartition::RemoveDataMask.
261 bool ClearData(const base::Time remove_since, 147 bool ClearData(const base::Time remove_since,
262 uint32 removal_mask, 148 uint32 removal_mask,
263 const base::Closure& callback); 149 const base::Closure& callback);
264 150
265 ScriptExecutor* script_executor() { return script_executor_.get(); } 151 ScriptExecutor* script_executor() { return script_executor_.get(); }
Fady Samuel 2015/10/10 01:02:12 Does this need to be public?
paulmeyer 2015/10/16 21:13:03 Yes, since it is also called in web_view_internal_
Fady Samuel 2015/10/16 21:17:28 Acknowledged.
266 152
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: 153 private:
274 friend class WebViewPermissionHelper; 154 friend class WebViewPermissionHelper;
275 155
276 explicit WebViewGuest(content::WebContents* owner_web_contents); 156 explicit WebViewGuest(content::WebContents* owner_web_contents);
277 157
278 ~WebViewGuest() override; 158 ~WebViewGuest() override;
279 159
280 void ClearDataInternal(const base::Time remove_since, 160 void ClearDataInternal(const base::Time remove_since,
281 uint32 removal_mask, 161 uint32 removal_mask,
282 const base::Closure& callback); 162 const base::Closure& callback);
283 163
284 void OnWebViewNewWindowResponse(int new_window_instance_id, 164 void OnWebViewNewWindowResponse(int new_window_instance_id,
285 bool allow, 165 bool allow,
286 const std::string& user_input); 166 const std::string& user_input);
287 167
288 void OnFullscreenPermissionDecided(bool allowed, 168 void OnFullscreenPermissionDecided(bool allowed,
289 const std::string& user_input); 169 const std::string& user_input);
290 bool GuestMadeEmbedderFullscreen() const; 170 bool GuestMadeEmbedderFullscreen() const;
291 void SetFullscreenState(bool is_fullscreen); 171 void SetFullscreenState(bool is_fullscreen);
292 172
173 // GuestViewBase implementation.
174 bool CanRunInDetachedState() const final;
175 void CreateWebContents(const base::DictionaryValue& create_params,
176 const WebContentsCreatedCallback& callback) final;
177 void DidAttachToEmbedder() final;
178 void DidDropLink(const GURL& url) final;
179 void DidInitialize(const base::DictionaryValue& create_params) final;
180 void EmbedderFullscreenToggled(bool entered_fullscreen) final;
181 void FindReply(content::WebContents* source,
182 int request_id,
183 int number_of_matches,
184 const gfx::Rect& selection_rect,
185 int active_match_ordinal,
186 bool final_update) final;
187 const char* GetAPINamespace() const final;
188 int GetTaskPrefix() const final;
189 void GuestDestroyed() final;
190 void GuestReady() final;
191 void GuestSizeChangedDueToAutoSize(const gfx::Size& old_size,
192 const gfx::Size& new_size) final;
193 void GuestViewDidStopLoading() final;
194 void GuestZoomChanged(double old_zoom_level, double new_zoom_level) final;
195 bool IsAutoSizeSupported() const final;
196 void SetContextMenuPosition(const gfx::Point& position) final;
197 void SignalWhenReady(const base::Closure& callback) final;
198 bool ShouldHandleFindRequestsForEmbedder() const final;
199 void WillAttachToEmbedder() final;
200 void WillDestroy() final;
201
202 // NotificationObserver implementation.
203 void Observe(int type,
204 const content::NotificationSource& source,
205 const content::NotificationDetails& details) final;
206
207 // WebContentsDelegate implementation.
208 bool AddMessageToConsole(content::WebContents* source,
209 int32 level,
210 const base::string16& message,
211 int32 line_no,
212 const base::string16& source_id) final;
213 void CloseContents(content::WebContents* source) final;
214 bool HandleContextMenu(const content::ContextMenuParams& params) final;
215 void HandleKeyboardEvent(content::WebContents* source,
216 const content::NativeWebKeyboardEvent& event) final;
217 void LoadProgressChanged(content::WebContents* source, double progress) final;
218 bool PreHandleGestureEvent(content::WebContents* source,
219 const blink::WebGestureEvent& event) final;
220 void RendererResponsive(content::WebContents* source) final;
221 void RendererUnresponsive(content::WebContents* source) final;
222 void RequestMediaAccessPermission(
223 content::WebContents* source,
224 const content::MediaStreamRequest& request,
225 const content::MediaResponseCallback& callback) final;
226 void RequestPointerLockPermission(
227 bool user_gesture,
228 bool last_unlocked_by_target,
229 const base::Callback<void(bool)>& callback) final;
230 bool CheckMediaAccessPermission(content::WebContents* source,
231 const GURL& security_origin,
232 content::MediaStreamType type) final;
233 void CanDownload(const GURL& url,
234 const std::string& request_method,
235 const base::Callback<void(bool)>& callback) final;
236 content::JavaScriptDialogManager* GetJavaScriptDialogManager(
237 content::WebContents* source) final;
238 void AddNewContents(content::WebContents* source,
239 content::WebContents* new_contents,
240 WindowOpenDisposition disposition,
241 const gfx::Rect& initial_rect,
242 bool user_gesture,
243 bool* was_blocked) final;
244 content::WebContents* OpenURLFromTab(
245 content::WebContents* source,
246 const content::OpenURLParams& params) final;
247 void WebContentsCreated(content::WebContents* source_contents,
248 int opener_render_frame_id,
249 const std::string& frame_name,
250 const GURL& target_url,
251 content::WebContents* new_contents) final;
252 void EnterFullscreenModeForTab(content::WebContents* web_contents,
253 const GURL& origin) final;
254 void ExitFullscreenModeForTab(content::WebContents* web_contents) final;
255 bool IsFullscreenForTabOrPending(
256 const content::WebContents* web_contents) const final;
257
293 // WebContentsObserver implementation. 258 // WebContentsObserver implementation.
294 void DidCommitProvisionalLoadForFrame( 259 void DidCommitProvisionalLoadForFrame(
295 content::RenderFrameHost* render_frame_host, 260 content::RenderFrameHost* render_frame_host,
296 const GURL& url, 261 const GURL& url,
297 ui::PageTransition transition_type) override; 262 ui::PageTransition transition_type) final;
298 void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host, 263 void DidFailProvisionalLoad(content::RenderFrameHost* render_frame_host,
299 const GURL& validated_url, 264 const GURL& validated_url,
300 int error_code, 265 int error_code,
301 const base::string16& error_description, 266 const base::string16& error_description,
302 bool was_ignored_by_handler) override; 267 bool was_ignored_by_handler) final;
303 void DidStartProvisionalLoadForFrame( 268 void DidStartProvisionalLoadForFrame(
304 content::RenderFrameHost* render_frame_host, 269 content::RenderFrameHost* render_frame_host,
305 const GURL& validated_url, 270 const GURL& validated_url,
306 bool is_error_page, 271 bool is_error_page,
307 bool is_iframe_srcdoc) override; 272 bool is_iframe_srcdoc) final;
308 void RenderProcessGone(base::TerminationStatus status) override; 273 void RenderProcessGone(base::TerminationStatus status) final;
309 void UserAgentOverrideSet(const std::string& user_agent) override; 274 void UserAgentOverrideSet(const std::string& user_agent) final;
310 void FrameNameChanged(content::RenderFrameHost* render_frame_host, 275 void FrameNameChanged(content::RenderFrameHost* render_frame_host,
311 const std::string& name) override; 276 const std::string& name) final;
312 277
313 // Informs the embedder of a frame name change. 278 // Informs the embedder of a frame name change.
314 void ReportFrameNameChange(const std::string& name); 279 void ReportFrameNameChange(const std::string& name);
315 280
316 // Called after the load handler is called in the guest's main frame. 281 // Called after the load handler is called in the guest's main frame.
317 void LoadHandlerCalled(); 282 void LoadHandlerCalled();
318 283
319 // Called when a redirect notification occurs. 284 // Called when a redirect notification occurs.
320 void LoadRedirect(const GURL& old_url, 285 void LoadRedirect(const GURL& old_url,
321 const GURL& new_url, 286 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. 318 // Creates a new guest window owned by this WebViewGuest.
354 void CreateNewGuestWebViewWindow(const content::OpenURLParams& params); 319 void CreateNewGuestWebViewWindow(const content::OpenURLParams& params);
355 320
356 void NewGuestWebViewCallback(const content::OpenURLParams& params, 321 void NewGuestWebViewCallback(const content::OpenURLParams& params,
357 content::WebContents* guest_web_contents); 322 content::WebContents* guest_web_contents);
358 323
359 bool HandleKeyboardShortcuts(const content::NativeWebKeyboardEvent& event); 324 bool HandleKeyboardShortcuts(const content::NativeWebKeyboardEvent& event);
360 325
361 void ApplyAttributes(const base::DictionaryValue& params); 326 void ApplyAttributes(const base::DictionaryValue& params);
362 327
363 void SetContextMenuPosition(const gfx::Point& position) override;
364
365 // Identifies the set of rules registries belonging to this guest. 328 // Identifies the set of rules registries belonging to this guest.
366 int rules_registry_id_; 329 int rules_registry_id_;
367 330
368 // Handles find requests and replies for the webview find API. 331 // Handles find requests and replies for the webview find API.
369 WebViewFindHelper find_helper_; 332 WebViewFindHelper find_helper_;
370 333
371 base::ObserverList<ScriptExecutionObserver> script_observers_; 334 base::ObserverList<ScriptExecutionObserver> script_observers_;
372 scoped_ptr<ScriptExecutor> script_executor_; 335 scoped_ptr<ScriptExecutor> script_executor_;
373 336
374 content::NotificationRegistrar notification_registrar_; 337 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 384 // This is used to ensure pending tasks will not fire after this object is
422 // destroyed. 385 // destroyed.
423 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_; 386 base::WeakPtrFactory<WebViewGuest> weak_ptr_factory_;
424 387
425 DISALLOW_COPY_AND_ASSIGN(WebViewGuest); 388 DISALLOW_COPY_AND_ASSIGN(WebViewGuest);
426 }; 389 };
427 390
428 } // namespace extensions 391 } // namespace extensions
429 392
430 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_ 393 #endif // EXTENSIONS_BROWSER_GUEST_VIEW_WEB_VIEW_WEB_VIEW_GUEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698