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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 23530029: Support webview tag when the container extension is embedded in a webUI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fady's comment addressed Created 7 years, 3 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 | Annotate | Revision Log
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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 #include "content/public/browser/child_process_data.h" 119 #include "content/public/browser/child_process_data.h"
120 #include "content/public/browser/child_process_security_policy.h" 120 #include "content/public/browser/child_process_security_policy.h"
121 #include "content/public/browser/render_process_host.h" 121 #include "content/public/browser/render_process_host.h"
122 #include "content/public/browser/render_view_host.h" 122 #include "content/public/browser/render_view_host.h"
123 #include "content/public/browser/resource_context.h" 123 #include "content/public/browser/resource_context.h"
124 #include "content/public/browser/site_instance.h" 124 #include "content/public/browser/site_instance.h"
125 #include "content/public/browser/web_contents.h" 125 #include "content/public/browser/web_contents.h"
126 #include "content/public/browser/web_contents_view.h" 126 #include "content/public/browser/web_contents_view.h"
127 #include "content/public/common/child_process_host.h" 127 #include "content/public/common/child_process_host.h"
128 #include "content/public/common/content_descriptors.h" 128 #include "content/public/common/content_descriptors.h"
129 #include "content/public/common/url_utils.h"
129 #include "extensions/browser/view_type_utils.h" 130 #include "extensions/browser/view_type_utils.h"
130 #include "extensions/common/constants.h" 131 #include "extensions/common/constants.h"
131 #include "extensions/common/switches.h" 132 #include "extensions/common/switches.h"
132 #include "grit/generated_resources.h" 133 #include "grit/generated_resources.h"
133 #include "grit/ui_resources.h" 134 #include "grit/ui_resources.h"
134 #include "net/base/escape.h" 135 #include "net/base/escape.h"
135 #include "net/base/mime_util.h" 136 #include "net/base/mime_util.h"
136 #include "net/cookies/canonical_cookie.h" 137 #include "net/cookies/canonical_cookie.h"
137 #include "net/cookies/cookie_options.h" 138 #include "net/cookies/cookie_options.h"
138 #include "net/ssl/ssl_cert_request_info.h" 139 #include "net/ssl/ssl_cert_request_info.h"
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 return; 790 return;
790 } 791 }
791 std::string api_type; 792 std::string api_type;
792 extra_params->GetString(guestview::kParameterApi, &api_type); 793 extra_params->GetString(guestview::kParameterApi, &api_type);
793 794
794 if (api_type == "adview") { 795 if (api_type == "adview") {
795 *guest_delegate = new AdViewGuest(guest_web_contents); 796 *guest_delegate = new AdViewGuest(guest_web_contents);
796 } else if (api_type == "webview") { 797 } else if (api_type == "webview") {
797 *guest_delegate = new WebViewGuest(guest_web_contents); 798 *guest_delegate = new WebViewGuest(guest_web_contents);
798 } else { 799 } else {
799 NOTREACHED(); 800 // NOTREACHED();
800 } 801 }
801 } 802 }
802 803
803 void ChromeContentBrowserClient::GuestWebContentsAttached( 804 void ChromeContentBrowserClient::GuestWebContentsAttached(
804 WebContents* guest_web_contents, 805 WebContents* guest_web_contents,
805 WebContents* embedder_web_contents, 806 WebContents* embedder_web_contents,
807 const GURL& embedder_frame_url,
806 const base::DictionaryValue& extra_params) { 808 const base::DictionaryValue& extra_params) {
807 Profile* profile = Profile::FromBrowserContext( 809 Profile* profile = Profile::FromBrowserContext(
808 embedder_web_contents->GetBrowserContext()); 810 embedder_web_contents->GetBrowserContext());
809 ExtensionService* service = 811 ExtensionService* service =
810 extensions::ExtensionSystem::Get(profile)->extension_service(); 812 extensions::ExtensionSystem::Get(profile)->extension_service();
811 if (!service) { 813 if (!service) {
812 NOTREACHED(); 814 NOTREACHED();
813 return; 815 return;
814 } 816 }
815 const GURL& url = embedder_web_contents->GetSiteInstance()->GetSiteURL(); 817
816 const Extension* extension = 818 // Only trust |embedder_frame_url| reported by a WebUI renderer.
817 service->extensions()->GetExtensionOrAppByURL(url); 819 const GURL& embedder_site_url =
820 embedder_web_contents->GetSiteInstance()->GetSiteURL();
821 const Extension* extension = service->extensions()->GetExtensionOrAppByURL(
822 content::HasWebUIScheme(embedder_site_url) ?
823 embedder_frame_url : embedder_site_url);
818 if (!extension) { 824 if (!extension) {
819 // It's ok to return here, since we could be running a browser plugin 825 // It's ok to return here, since we could be running a browser plugin
820 // outside an extension, and don't need to attach a 826 // outside an extension, and don't need to attach a
821 // BrowserPluginGuestDelegate in that case; 827 // BrowserPluginGuestDelegate in that case;
822 // e.g. running with flag --enable-browser-plugin-for-all-view-types. 828 // e.g. running with flag --enable-browser-plugin-for-all-view-types.
823 return; 829 return;
824 } 830 }
825 831
826 GuestView* guest = GuestView::FromWebContents(guest_web_contents); 832 GuestView* guest = GuestView::FromWebContents(guest_web_contents);
827 if (!guest) { 833 if (!guest) {
(...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 } 2341 }
2336 return NULL; 2342 return NULL;
2337 } 2343 }
2338 2344
2339 bool ChromeContentBrowserClient::SupportsBrowserPlugin( 2345 bool ChromeContentBrowserClient::SupportsBrowserPlugin(
2340 content::BrowserContext* browser_context, const GURL& site_url) { 2346 content::BrowserContext* browser_context, const GURL& site_url) {
2341 if (CommandLine::ForCurrentProcess()->HasSwitch( 2347 if (CommandLine::ForCurrentProcess()->HasSwitch(
2342 switches::kEnableBrowserPluginForAllViewTypes)) 2348 switches::kEnableBrowserPluginForAllViewTypes))
2343 return true; 2349 return true;
2344 2350
2351 if (content::HasWebUIScheme(site_url))
Fady Samuel 2013/09/12 22:46:46 We should probably do the same check as above here
guohui 2013/09/13 00:04:02 SupportsBrowserPlugin is called before RenderViewH
2352 return true;
2353
2345 Profile* profile = Profile::FromBrowserContext(browser_context); 2354 Profile* profile = Profile::FromBrowserContext(browser_context);
2346 ExtensionService* service = 2355 ExtensionService* service =
2347 extensions::ExtensionSystem::Get(profile)->extension_service(); 2356 extensions::ExtensionSystem::Get(profile)->extension_service();
2348 if (!service) 2357 if (!service)
2349 return false; 2358 return false;
2350 2359
2351 const Extension* extension = 2360 const Extension* extension =
2352 service->extensions()->GetExtensionOrAppByURL(site_url); 2361 service->extensions()->GetExtensionOrAppByURL(site_url);
2353 if (!extension) 2362 if (!extension)
2354 return false; 2363 return false;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 #if defined(USE_NSS) 2545 #if defined(USE_NSS)
2537 crypto::CryptoModuleBlockingPasswordDelegate* 2546 crypto::CryptoModuleBlockingPasswordDelegate*
2538 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 2547 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
2539 const GURL& url) { 2548 const GURL& url) {
2540 return chrome::NewCryptoModuleBlockingDialogDelegate( 2549 return chrome::NewCryptoModuleBlockingDialogDelegate(
2541 chrome::kCryptoModulePasswordKeygen, url.host()); 2550 chrome::kCryptoModulePasswordKeygen, url.host());
2542 } 2551 }
2543 #endif 2552 #endif
2544 2553
2545 } // namespace chrome 2554 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698