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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 27408004: <webview>: Resolve relative paths as chrome-extension: URLs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactor + addressed creis' comments Created 7 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/browser_plugin/browser_plugin_guest.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
629 BrowserPluginGuest::~BrowserPluginGuest() { 629 BrowserPluginGuest::~BrowserPluginGuest() {
630 while (!pending_messages_.empty()) { 630 while (!pending_messages_.empty()) {
631 delete pending_messages_.front(); 631 delete pending_messages_.front();
632 pending_messages_.pop(); 632 pending_messages_.pop();
633 } 633 }
634 } 634 }
635 635
636 // static 636 // static
637 BrowserPluginGuest* BrowserPluginGuest::Create( 637 BrowserPluginGuest* BrowserPluginGuest::Create(
638 int instance_id, 638 int instance_id,
639 SiteInstance* site_instance,
639 WebContentsImpl* web_contents, 640 WebContentsImpl* web_contents,
640 scoped_ptr<base::DictionaryValue> extra_params) { 641 scoped_ptr<base::DictionaryValue> extra_params) {
641 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create")); 642 RecordAction(UserMetricsAction("BrowserPlugin.Guest.Create"));
642 BrowserPluginGuest* guest = NULL; 643 BrowserPluginGuest* guest = NULL;
643 if (factory_) { 644 if (factory_) {
644 guest = factory_->CreateBrowserPluginGuest(instance_id, web_contents); 645 guest = factory_->CreateBrowserPluginGuest(instance_id, web_contents);
645 } else { 646 } else {
646 guest = new BrowserPluginGuest(instance_id, web_contents, NULL, false); 647 guest = new BrowserPluginGuest(instance_id, web_contents, NULL, false);
647 } 648 }
648 guest->extra_attach_params_.reset(extra_params->DeepCopy()); 649 guest->extra_attach_params_.reset(extra_params->DeepCopy());
649 web_contents->SetBrowserPluginGuest(guest); 650 web_contents->SetBrowserPluginGuest(guest);
650 BrowserPluginGuestDelegate* delegate = NULL; 651 BrowserPluginGuestDelegate* delegate = NULL;
651 GetContentClient()->browser()->GuestWebContentsCreated( 652 GetContentClient()->browser()->GuestWebContentsCreated(
652 web_contents, NULL, &delegate, extra_params.Pass()); 653 site_instance, web_contents, NULL, &delegate, extra_params.Pass());
653 guest->SetDelegate(delegate); 654 guest->SetDelegate(delegate);
654 return guest; 655 return guest;
655 } 656 }
656 657
657 // static 658 // static
658 BrowserPluginGuest* BrowserPluginGuest::CreateWithOpener( 659 BrowserPluginGuest* BrowserPluginGuest::CreateWithOpener(
659 int instance_id, 660 int instance_id,
660 WebContentsImpl* web_contents, 661 WebContentsImpl* web_contents,
661 BrowserPluginGuest* opener, 662 BrowserPluginGuest* opener,
662 bool has_render_view) { 663 bool has_render_view) {
663 BrowserPluginGuest* guest = 664 BrowserPluginGuest* guest =
664 new BrowserPluginGuest( 665 new BrowserPluginGuest(
665 instance_id, web_contents, opener, has_render_view); 666 instance_id, web_contents, opener, has_render_view);
666 web_contents->SetBrowserPluginGuest(guest); 667 web_contents->SetBrowserPluginGuest(guest);
667 BrowserPluginGuestDelegate* delegate = NULL; 668 BrowserPluginGuestDelegate* delegate = NULL;
668 GetContentClient()->browser()->GuestWebContentsCreated( 669 GetContentClient()->browser()->GuestWebContentsCreated(
670 opener->GetWebContents()->GetSiteInstance(),
669 web_contents, opener->GetWebContents(), &delegate, 671 web_contents, opener->GetWebContents(), &delegate,
670 scoped_ptr<base::DictionaryValue>()); 672 scoped_ptr<base::DictionaryValue>());
671 guest->SetDelegate(delegate); 673 guest->SetDelegate(delegate);
672 return guest; 674 return guest;
673 } 675 }
674 676
675 RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() { 677 RenderWidgetHostView* BrowserPluginGuest::GetEmbedderRenderWidgetHostView() {
676 return embedder_web_contents_->GetRenderWidgetHostView(); 678 return embedder_web_contents_->GetRenderWidgetHostView();
677 } 679 }
678 680
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 void BrowserPluginGuest::OnLockMouseAck(int instance_id, bool succeeded) { 1334 void BrowserPluginGuest::OnLockMouseAck(int instance_id, bool succeeded) {
1333 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded)); 1335 Send(new ViewMsg_LockMouse_ACK(routing_id(), succeeded));
1334 pending_lock_request_ = false; 1336 pending_lock_request_ = false;
1335 if (succeeded) 1337 if (succeeded)
1336 mouse_locked_ = true; 1338 mouse_locked_ = true;
1337 } 1339 }
1338 1340
1339 void BrowserPluginGuest::OnNavigateGuest( 1341 void BrowserPluginGuest::OnNavigateGuest(
1340 int instance_id, 1342 int instance_id,
1341 const std::string& src) { 1343 const std::string& src) {
1342 GURL url(src); 1344 GURL url = delegate_ ? delegate_->ResolveURL(src) : GURL(src);
1343 // We do not load empty urls in web_contents. 1345 // We do not load empty urls in web_contents.
1344 // If a guest sets empty src attribute after it has navigated to some 1346 // If a guest sets empty src attribute after it has navigated to some
1345 // non-empty page, the action is considered no-op. This empty src navigation 1347 // non-empty page, the action is considered no-op. This empty src navigation
1346 // should never be sent to BrowserPluginGuest (browser process). 1348 // should never be sent to BrowserPluginGuest (browser process).
1347 DCHECK(!src.empty()); 1349 DCHECK(!src.empty());
1348 if (src.empty()) 1350 if (src.empty())
1349 return; 1351 return;
1350 1352
1351 // Do not allow navigating a guest to schemes other than known safe schemes. 1353 // Do not allow navigating a guest to schemes other than known safe schemes.
1352 // This will block the embedder trying to load unwanted schemes, e.g. 1354 // This will block the embedder trying to load unwanted schemes, e.g.
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
1729 request_info.Set(browser_plugin::kRequestMethod, 1731 request_info.Set(browser_plugin::kRequestMethod,
1730 base::Value::CreateStringValue(request_method)); 1732 base::Value::CreateStringValue(request_method));
1731 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); 1733 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url));
1732 1734
1733 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD, 1735 RequestPermission(BROWSER_PLUGIN_PERMISSION_TYPE_DOWNLOAD,
1734 new DownloadRequest(callback), 1736 new DownloadRequest(callback),
1735 request_info); 1737 request_info);
1736 } 1738 }
1737 1739
1738 } // namespace content 1740 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698