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

Side by Side Diff: chrome/browser/chrome_content_browser_client.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 "chrome/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 CHECK(can_be_default || !partition_domain->empty()); 816 CHECK(can_be_default || !partition_domain->empty());
817 } 817 }
818 818
819 content::WebContentsViewDelegate* 819 content::WebContentsViewDelegate*
820 ChromeContentBrowserClient::GetWebContentsViewDelegate( 820 ChromeContentBrowserClient::GetWebContentsViewDelegate(
821 content::WebContents* web_contents) { 821 content::WebContents* web_contents) {
822 return chrome::CreateWebContentsViewDelegate(web_contents); 822 return chrome::CreateWebContentsViewDelegate(web_contents);
823 } 823 }
824 824
825 void ChromeContentBrowserClient::GuestWebContentsCreated( 825 void ChromeContentBrowserClient::GuestWebContentsCreated(
826 SiteInstance* guest_site_instance,
Charlie Reis 2013/10/30 20:42:20 Is this equal to guest_web_contents->GetSiteInstan
Fady Samuel 2013/10/31 17:25:17 Yes, but GuestWebContentsCreated gets called prior
826 WebContents* guest_web_contents, 827 WebContents* guest_web_contents,
827 WebContents* opener_web_contents, 828 WebContents* opener_web_contents,
828 content::BrowserPluginGuestDelegate** guest_delegate, 829 content::BrowserPluginGuestDelegate** guest_delegate,
829 scoped_ptr<base::DictionaryValue> extra_params) { 830 scoped_ptr<base::DictionaryValue> extra_params) {
831 if (!guest_site_instance) {
832 NOTREACHED();
833 return;
834 }
835 GURL guest_site_url = guest_site_instance->GetSiteURL();
836 const std::string& extension_id = guest_site_url.host();
Charlie Reis 2013/10/30 20:42:20 I've lost track-- are we guaranteeing that the gue
Fady Samuel 2013/10/31 17:25:17 For WebUI, this will be extracted from the iframe'
837
830 if (opener_web_contents) { 838 if (opener_web_contents) {
831 GuestView* guest = GuestView::FromWebContents(opener_web_contents); 839 GuestView* guest = GuestView::FromWebContents(opener_web_contents);
832 if (!guest) { 840 if (!guest) {
833 NOTREACHED(); 841 NOTREACHED();
834 return; 842 return;
835 } 843 }
836 844
837 // Create a new GuestView of the same type as the opener. 845 // Create a new GuestView of the same type as the opener.
838 *guest_delegate = 846 *guest_delegate =
839 GuestView::Create(guest_web_contents, guest->GetViewType()); 847 GuestView::Create(guest_web_contents,
848 extension_id,
849 guest->GetViewType());
840 return; 850 return;
841 } 851 }
842 852
843 if (!extra_params) { 853 if (!extra_params) {
844 NOTREACHED(); 854 NOTREACHED();
845 return; 855 return;
846 } 856 }
847 std::string api_type; 857 std::string api_type;
848 extra_params->GetString(guestview::kParameterApi, &api_type); 858 extra_params->GetString(guestview::kParameterApi, &api_type);
849 859
860 if (api_type.empty())
861 return;
862
850 *guest_delegate = 863 *guest_delegate =
851 GuestView::Create(guest_web_contents, 864 GuestView::Create(guest_web_contents,
865 extension_id,
852 GuestView::GetViewTypeFromString(api_type)); 866 GuestView::GetViewTypeFromString(api_type));
853 } 867 }
854 868
855 void ChromeContentBrowserClient::GuestWebContentsAttached( 869 void ChromeContentBrowserClient::GuestWebContentsAttached(
856 WebContents* guest_web_contents, 870 WebContents* guest_web_contents,
857 WebContents* embedder_web_contents, 871 WebContents* embedder_web_contents,
858 const GURL& embedder_frame_url,
859 const base::DictionaryValue& extra_params) { 872 const base::DictionaryValue& extra_params) {
860 Profile* profile = Profile::FromBrowserContext(
861 embedder_web_contents->GetBrowserContext());
862 ExtensionService* service =
863 extensions::ExtensionSystem::Get(profile)->extension_service();
864 if (!service) {
865 NOTREACHED();
866 return;
867 }
868 873
869 // We usually require BrowserPlugins to be hosted by a storage isolated 874 GuestView* guest = GuestView::FromWebContents(guest_web_contents);
870 // extension. We treat WebUI pages as a special case if they host the 875 if (!guest) {
871 // BrowserPlugin in a component extension iframe. In that case, we use the
872 // iframe's URL to determine the extension.
Charlie Reis 2013/10/30 20:42:20 I haven't been able to figure out why it's safe to
Fady Samuel 2013/10/31 17:25:17 See BrowserPluginGuestManager::CreateGuest. This i
873 const GURL& embedder_site_url =
874 embedder_web_contents->GetSiteInstance()->GetSiteURL();
875 const Extension* extension = service->extensions()->GetExtensionOrAppByURL(
876 content::HasWebUIScheme(embedder_site_url) ?
877 embedder_frame_url : embedder_site_url);
878 if (!extension) {
879 // It's ok to return here, since we could be running a browser plugin 876 // It's ok to return here, since we could be running a browser plugin
880 // outside an extension, and don't need to attach a 877 // outside an extension, and don't need to attach a
881 // BrowserPluginGuestDelegate in that case; 878 // BrowserPluginGuestDelegate in that case;
882 // e.g. running with flag --enable-browser-plugin-for-all-view-types. 879 // e.g. running with flag --enable-browser-plugin-for-all-view-types.
883 return; 880 return;
884 } 881 }
885 882 guest->Attach(embedder_web_contents, extra_params);
886 GuestView* guest = GuestView::FromWebContents(guest_web_contents);
887 if (!guest) {
888 NOTREACHED();
889 return;
890 }
891 guest->Attach(embedder_web_contents, extension->id(), extra_params);
892 } 883 }
893 884
894 void ChromeContentBrowserClient::RenderProcessHostCreated( 885 void ChromeContentBrowserClient::RenderProcessHostCreated(
895 content::RenderProcessHost* host) { 886 content::RenderProcessHost* host) {
896 int id = host->GetID(); 887 int id = host->GetID();
897 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); 888 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
898 net::URLRequestContextGetter* context = 889 net::URLRequestContextGetter* context =
899 profile->GetRequestContextForRenderProcess(id); 890 profile->GetRequestContextForRenderProcess(id);
900 891
901 host->AddFilter(new ChromeRenderMessageFilter(id, profile, context)); 892 host->AddFilter(new ChromeRenderMessageFilter(id, profile, context));
(...skipping 1734 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 return IsExtensionOrSharedModuleWhitelisted(url, extension_set, 2627 return IsExtensionOrSharedModuleWhitelisted(url, extension_set,
2637 allowed_file_handle_origins_) || 2628 allowed_file_handle_origins_) ||
2638 IsHostAllowedByCommandLine(url, extension_set, 2629 IsHostAllowedByCommandLine(url, extension_set,
2639 switches::kAllowNaClFileHandleAPI); 2630 switches::kAllowNaClFileHandleAPI);
2640 #else 2631 #else
2641 return false; 2632 return false;
2642 #endif 2633 #endif
2643 } 2634 }
2644 2635
2645 } // namespace chrome 2636 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698