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

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

Issue 845363004: <webview>, <appview> and <extensionoptions> can run in a detached state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 years, 11 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 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 // static 210 // static
211 int WebViewGuest::GetViewInstanceId(WebContents* contents) { 211 int WebViewGuest::GetViewInstanceId(WebContents* contents) {
212 auto guest = FromWebContents(contents); 212 auto guest = FromWebContents(contents);
213 if (!guest) 213 if (!guest)
214 return guestview::kInstanceIDNone; 214 return guestview::kInstanceIDNone;
215 215
216 return guest->view_instance_id(); 216 return guest->view_instance_id();
217 } 217 }
218 218
219 const char* WebViewGuest::GetAPINamespace() const { 219 bool WebViewGuest::CanRunInDetachedState() const {
220 return webview::kAPINamespace; 220 return true;
221 }
222
223 int WebViewGuest::GetTaskPrefix() const {
224 return IDS_EXTENSION_TASK_MANAGER_WEBVIEW_TAG_PREFIX;
225 } 221 }
226 222
227 void WebViewGuest::CreateWebContents( 223 void WebViewGuest::CreateWebContents(
228 const base::DictionaryValue& create_params, 224 const base::DictionaryValue& create_params,
229 const WebContentsCreatedCallback& callback) { 225 const WebContentsCreatedCallback& callback) {
230 content::RenderProcessHost* owner_render_process_host = 226 content::RenderProcessHost* owner_render_process_host =
231 owner_web_contents()->GetRenderProcessHost(); 227 owner_web_contents()->GetRenderProcessHost();
232 std::string storage_partition_id; 228 std::string storage_partition_id;
233 bool persist_storage = false; 229 bool persist_storage = false;
234 ParsePartitionParam(create_params, &storage_partition_id, &persist_storage); 230 ParsePartitionParam(create_params, &storage_partition_id, &persist_storage);
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 292
297 rules_registry_id_ = GetOrGenerateRulesRegistryID( 293 rules_registry_id_ = GetOrGenerateRulesRegistryID(
298 owner_web_contents()->GetRenderProcessHost()->GetID(), 294 owner_web_contents()->GetRenderProcessHost()->GetID(),
299 view_instance_id()); 295 view_instance_id());
300 296
301 // We must install the mapping from guests to WebViews prior to resuming 297 // We must install the mapping from guests to WebViews prior to resuming
302 // suspended resource loads so that the WebRequest API will catch resource 298 // suspended resource loads so that the WebRequest API will catch resource
303 // requests. 299 // requests.
304 PushWebViewStateToIOThread(); 300 PushWebViewStateToIOThread();
305 301
306 // TODO(fsamuel): Once <webview> can run in a detached state, call 302 ApplyAttributes(create_params);
307 // ApplyAttributes here.
308 } 303 }
309 304
310 void WebViewGuest::AttachWebViewHelpers(WebContents* contents) { 305 void WebViewGuest::AttachWebViewHelpers(WebContents* contents) {
311 if (web_view_guest_delegate_) 306 if (web_view_guest_delegate_)
312 web_view_guest_delegate_->OnAttachWebViewHelpers(contents); 307 web_view_guest_delegate_->OnAttachWebViewHelpers(contents);
313 web_view_permission_helper_.reset(new WebViewPermissionHelper(this)); 308 web_view_permission_helper_.reset(new WebViewPermissionHelper(this));
314 } 309 }
315 310
316 void WebViewGuest::DidStopLoading() { 311 void WebViewGuest::DidStopLoading() {
317 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 312 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
(...skipping 13 matching lines...) Expand all
331 content::BrowserThread::IO, 326 content::BrowserThread::IO,
332 FROM_HERE, 327 FROM_HERE,
333 base::Bind( 328 base::Bind(
334 &RemoveWebViewEventListenersOnIOThread, 329 &RemoveWebViewEventListenersOnIOThread,
335 browser_context(), 330 browser_context(),
336 owner_extension_id(), 331 owner_extension_id(),
337 owner_web_contents()->GetRenderProcessHost()->GetID(), 332 owner_web_contents()->GetRenderProcessHost()->GetID(),
338 view_instance_id())); 333 view_instance_id()));
339 } 334 }
340 335
336 const char* WebViewGuest::GetAPINamespace() const {
337 return webview::kAPINamespace;
338 }
339
340 int WebViewGuest::GetTaskPrefix() const {
341 return IDS_EXTENSION_TASK_MANAGER_WEBVIEW_TAG_PREFIX;
342 }
343
341 void WebViewGuest::GuestDestroyed() { 344 void WebViewGuest::GuestDestroyed() {
342 // Clean up custom context menu items for this guest. 345 // Clean up custom context menu items for this guest.
343 if (web_view_guest_delegate_) 346 if (web_view_guest_delegate_)
344 web_view_guest_delegate_->OnGuestDestroyed(); 347 web_view_guest_delegate_->OnGuestDestroyed();
345 RemoveWebViewStateFromIOThread(web_contents()); 348 RemoveWebViewStateFromIOThread(web_contents());
346 } 349 }
347 350
348 void WebViewGuest::GuestReady() { 351 void WebViewGuest::GuestReady() {
349 // The guest RenderView should always live in an isolated guest process. 352 // The guest RenderView should always live in an isolated guest process.
350 CHECK(web_contents()->GetRenderProcessHost()->IsIsolatedGuest()); 353 CHECK(web_contents()->GetRenderProcessHost()->IsIsolatedGuest());
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 const std::string& name) { 477 const std::string& name) {
475 if (!is_top_level) 478 if (!is_top_level)
476 return; 479 return;
477 480
478 if (name_ == name) 481 if (name_ == name)
479 return; 482 return;
480 483
481 ReportFrameNameChange(name); 484 ReportFrameNameChange(name);
482 } 485 }
483 486
484 bool WebViewGuest::CanRunInDetachedState() const {
485 return false;
486 }
487
488 void WebViewGuest::CreateNewGuestWebViewWindow( 487 void WebViewGuest::CreateNewGuestWebViewWindow(
489 const content::OpenURLParams& params) { 488 const content::OpenURLParams& params) {
490 GuestViewManager* guest_manager = 489 GuestViewManager* guest_manager =
491 GuestViewManager::FromBrowserContext(browser_context()); 490 GuestViewManager::FromBrowserContext(browser_context());
492 // Set the attach params to use the same partition as the opener. 491 // Set the attach params to use the same partition as the opener.
493 // We pull the partition information from the site's URL, which is of the 492 // We pull the partition information from the site's URL, which is of the
494 // form guest://site/{persist}?{partition_name}. 493 // form guest://site/{persist}?{partition_name}.
495 const GURL& site_url = web_contents()->GetSiteInstance()->GetSiteURL(); 494 const GURL& site_url = web_contents()->GetSiteInstance()->GetSiteURL();
496 const std::string storage_partition_id = 495 const std::string storage_partition_id =
497 GetStoragePartitionIdFromSiteURL(site_url); 496 GetStoragePartitionIdFromSiteURL(site_url);
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1236 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(), 1235 WebViewGuest::From(owner_web_contents()->GetRenderProcessHost()->GetID(),
1237 new_window_instance_id); 1236 new_window_instance_id);
1238 if (!guest) 1237 if (!guest)
1239 return; 1238 return;
1240 1239
1241 if (!allow) 1240 if (!allow)
1242 guest->Destroy(); 1241 guest->Destroy();
1243 } 1242 }
1244 1243
1245 } // namespace extensions 1244 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/guest_view/web_view/web_view_guest.h ('k') | extensions/renderer/resources/guest_view/app_view.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698