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

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

Issue 63933003: Moved ExtensionInfoMap and ExtensionsQuotaService to extensions/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup 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 | 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 17 matching lines...) Expand all
28 #include "chrome/browser/chrome_quota_permission_context.h" 28 #include "chrome/browser/chrome_quota_permission_context.h"
29 #include "chrome/browser/content_settings/content_settings_utils.h" 29 #include "chrome/browser/content_settings/content_settings_utils.h"
30 #include "chrome/browser/content_settings/cookie_settings.h" 30 #include "chrome/browser/content_settings/cookie_settings.h"
31 #include "chrome/browser/content_settings/host_content_settings_map.h" 31 #include "chrome/browser/content_settings/host_content_settings_map.h"
32 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 32 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
33 #include "chrome/browser/defaults.h" 33 #include "chrome/browser/defaults.h"
34 #include "chrome/browser/download/download_prefs.h" 34 #include "chrome/browser/download/download_prefs.h"
35 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 35 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" 36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h"
37 #include "chrome/browser/extensions/extension_host.h" 37 #include "chrome/browser/extensions/extension_host.h"
38 #include "chrome/browser/extensions/extension_info_map.h"
39 #include "chrome/browser/extensions/extension_process_manager.h" 38 #include "chrome/browser/extensions/extension_process_manager.h"
40 #include "chrome/browser/extensions/extension_service.h" 39 #include "chrome/browser/extensions/extension_service.h"
41 #include "chrome/browser/extensions/extension_system.h" 40 #include "chrome/browser/extensions/extension_system.h"
42 #include "chrome/browser/extensions/extension_web_ui.h" 41 #include "chrome/browser/extensions/extension_web_ui.h"
43 #include "chrome/browser/extensions/extension_webkit_preferences.h" 42 #include "chrome/browser/extensions/extension_webkit_preferences.h"
44 #include "chrome/browser/extensions/suggest_permission_util.h" 43 #include "chrome/browser/extensions/suggest_permission_util.h"
45 #include "chrome/browser/geolocation/chrome_access_token_store.h" 44 #include "chrome/browser/geolocation/chrome_access_token_store.h"
46 #include "chrome/browser/google/google_util.h" 45 #include "chrome/browser/google/google_util.h"
47 #include "chrome/browser/guestview/adview/adview_guest.h" 46 #include "chrome/browser/guestview/adview/adview_guest.h"
48 #include "chrome/browser/guestview/guestview_constants.h" 47 #include "chrome/browser/guestview/guestview_constants.h"
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 #include "content/public/browser/child_process_security_policy.h" 122 #include "content/public/browser/child_process_security_policy.h"
124 #include "content/public/browser/render_process_host.h" 123 #include "content/public/browser/render_process_host.h"
125 #include "content/public/browser/render_view_host.h" 124 #include "content/public/browser/render_view_host.h"
126 #include "content/public/browser/resource_context.h" 125 #include "content/public/browser/resource_context.h"
127 #include "content/public/browser/site_instance.h" 126 #include "content/public/browser/site_instance.h"
128 #include "content/public/browser/web_contents.h" 127 #include "content/public/browser/web_contents.h"
129 #include "content/public/browser/web_contents_view.h" 128 #include "content/public/browser/web_contents_view.h"
130 #include "content/public/common/child_process_host.h" 129 #include "content/public/common/child_process_host.h"
131 #include "content/public/common/content_descriptors.h" 130 #include "content/public/common/content_descriptors.h"
132 #include "content/public/common/url_utils.h" 131 #include "content/public/common/url_utils.h"
132 #include "extensions/browser/info_map.h"
133 #include "extensions/browser/view_type_utils.h" 133 #include "extensions/browser/view_type_utils.h"
134 #include "extensions/common/constants.h" 134 #include "extensions/common/constants.h"
135 #include "extensions/common/switches.h" 135 #include "extensions/common/switches.h"
136 #include "grit/generated_resources.h" 136 #include "grit/generated_resources.h"
137 #include "grit/ui_resources.h" 137 #include "grit/ui_resources.h"
138 #include "net/base/escape.h" 138 #include "net/base/escape.h"
139 #include "net/base/mime_util.h" 139 #include "net/base/mime_util.h"
140 #include "net/cookies/canonical_cookie.h" 140 #include "net/cookies/canonical_cookie.h"
141 #include "net/cookies/cookie_options.h" 141 #include "net/cookies/cookie_options.h"
142 #include "net/ssl/ssl_cert_request_info.h" 142 #include "net/ssl/ssl_cert_request_info.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 using content::BrowserThread; 246 using content::BrowserThread;
247 using content::BrowserURLHandler; 247 using content::BrowserURLHandler;
248 using content::ChildProcessSecurityPolicy; 248 using content::ChildProcessSecurityPolicy;
249 using content::FileDescriptorInfo; 249 using content::FileDescriptorInfo;
250 using content::QuotaPermissionContext; 250 using content::QuotaPermissionContext;
251 using content::RenderViewHost; 251 using content::RenderViewHost;
252 using content::SiteInstance; 252 using content::SiteInstance;
253 using content::WebContents; 253 using content::WebContents;
254 using extensions::APIPermission; 254 using extensions::APIPermission;
255 using extensions::Extension; 255 using extensions::Extension;
256 using extensions::InfoMap;
256 using extensions::Manifest; 257 using extensions::Manifest;
257 using message_center::NotifierId; 258 using message_center::NotifierId;
258 259
259 namespace { 260 namespace {
260 261
261 // Cached version of the locale so we can return the locale on the I/O 262 // Cached version of the locale so we can return the locale on the I/O
262 // thread. 263 // thread.
263 base::LazyInstance<std::string> g_io_thread_application_locale; 264 base::LazyInstance<std::string> g_io_thread_application_locale;
264 265
265 #if defined(ENABLE_PLUGINS) 266 #if defined(ENABLE_PLUGINS)
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 #if !defined(OS_CHROMEOS) 1263 #if !defined(OS_CHROMEOS)
1263 // We only expect there to be one signin process as we use process-per-site 1264 // We only expect there to be one signin process as we use process-per-site
1264 // for signin URLs. The signin process will be cleared from SigninManager 1265 // for signin URLs. The signin process will be cleared from SigninManager
1265 // when the renderer is destroyed. 1266 // when the renderer is destroyed.
1266 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) { 1267 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) {
1267 SigninManager* signin_manager = 1268 SigninManager* signin_manager =
1268 SigninManagerFactory::GetForProfile(profile); 1269 SigninManagerFactory::GetForProfile(profile);
1269 if (signin_manager) 1270 if (signin_manager)
1270 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID()); 1271 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID());
1271 BrowserThread::PostTask( 1272 BrowserThread::PostTask(
1272 BrowserThread::IO, FROM_HERE, 1273 BrowserThread::IO,
1273 base::Bind(&ExtensionInfoMap::SetSigninProcess, 1274 FROM_HERE,
1275 base::Bind(&InfoMap::SetSigninProcess,
1274 extensions::ExtensionSystem::Get(profile)->info_map(), 1276 extensions::ExtensionSystem::Get(profile)->info_map(),
1275 site_instance->GetProcess()->GetID())); 1277 site_instance->GetProcess()->GetID()));
1276 } 1278 }
1277 #endif 1279 #endif
1278 1280
1279 ExtensionService* service = 1281 ExtensionService* service =
1280 extensions::ExtensionSystem::Get(profile)->extension_service(); 1282 extensions::ExtensionSystem::Get(profile)->extension_service();
1281 if (!service) 1283 if (!service)
1282 return; 1284 return;
1283 1285
1284 const Extension* extension = service->extensions()->GetExtensionOrAppByURL( 1286 const Extension* extension = service->extensions()->GetExtensionOrAppByURL(
1285 site_instance->GetSiteURL()); 1287 site_instance->GetSiteURL());
1286 if (!extension) 1288 if (!extension)
1287 return; 1289 return;
1288 1290
1289 service->process_map()->Insert(extension->id(), 1291 service->process_map()->Insert(extension->id(),
1290 site_instance->GetProcess()->GetID(), 1292 site_instance->GetProcess()->GetID(),
1291 site_instance->GetId()); 1293 site_instance->GetId());
1292 BrowserThread::PostTask( 1294 BrowserThread::PostTask(
1293 BrowserThread::IO, FROM_HERE, 1295 BrowserThread::IO,
1294 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, 1296 FROM_HERE,
1297 base::Bind(&InfoMap::RegisterExtensionProcess,
1295 extensions::ExtensionSystem::Get(profile)->info_map(), 1298 extensions::ExtensionSystem::Get(profile)->info_map(),
1296 extension->id(), 1299 extension->id(),
1297 site_instance->GetProcess()->GetID(), 1300 site_instance->GetProcess()->GetID(),
1298 site_instance->GetId())); 1301 site_instance->GetId()));
1299 } 1302 }
1300 1303
1301 void ChromeContentBrowserClient::SiteInstanceDeleting( 1304 void ChromeContentBrowserClient::SiteInstanceDeleting(
1302 SiteInstance* site_instance) { 1305 SiteInstance* site_instance) {
1303 if (!site_instance->HasProcess()) 1306 if (!site_instance->HasProcess())
1304 return; 1307 return;
1305 1308
1306 Profile* profile = Profile::FromBrowserContext( 1309 Profile* profile = Profile::FromBrowserContext(
1307 site_instance->GetBrowserContext()); 1310 site_instance->GetBrowserContext());
1308 ExtensionService* service = 1311 ExtensionService* service =
1309 extensions::ExtensionSystem::Get(profile)->extension_service(); 1312 extensions::ExtensionSystem::Get(profile)->extension_service();
1310 if (!service) 1313 if (!service)
1311 return; 1314 return;
1312 1315
1313 const Extension* extension = service->extensions()->GetExtensionOrAppByURL( 1316 const Extension* extension = service->extensions()->GetExtensionOrAppByURL(
1314 site_instance->GetSiteURL()); 1317 site_instance->GetSiteURL());
1315 if (!extension) 1318 if (!extension)
1316 return; 1319 return;
1317 1320
1318 service->process_map()->Remove(extension->id(), 1321 service->process_map()->Remove(extension->id(),
1319 site_instance->GetProcess()->GetID(), 1322 site_instance->GetProcess()->GetID(),
1320 site_instance->GetId()); 1323 site_instance->GetId());
1321 BrowserThread::PostTask( 1324 BrowserThread::PostTask(
1322 BrowserThread::IO, FROM_HERE, 1325 BrowserThread::IO,
1323 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 1326 FROM_HERE,
1327 base::Bind(&InfoMap::UnregisterExtensionProcess,
1324 extensions::ExtensionSystem::Get(profile)->info_map(), 1328 extensions::ExtensionSystem::Get(profile)->info_map(),
1325 extension->id(), 1329 extension->id(),
1326 site_instance->GetProcess()->GetID(), 1330 site_instance->GetProcess()->GetID(),
1327 site_instance->GetId())); 1331 site_instance->GetId()));
1328 } 1332 }
1329 1333
1330 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( 1334 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
1331 SiteInstance* site_instance, 1335 SiteInstance* site_instance,
1332 const GURL& current_url, 1336 const GURL& current_url,
1333 const GURL& new_url) { 1337 const GURL& new_url) {
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 tab_util::GetWebContentsByID(render_process_id, render_view_id); 1893 tab_util::GetWebContentsByID(render_process_id, render_view_id);
1890 if (!contents) { 1894 if (!contents) {
1891 NOTREACHED(); 1895 NOTREACHED();
1892 return; 1896 return;
1893 } 1897 }
1894 1898
1895 // Skip showing the infobar if the request comes from an extension, and that 1899 // Skip showing the infobar if the request comes from an extension, and that
1896 // extension has the 'notify' permission. (If the extension does not have the 1900 // extension has the 'notify' permission. (If the extension does not have the
1897 // permission, the user will still be prompted.) 1901 // permission, the user will still be prompted.)
1898 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 1902 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
1899 ExtensionInfoMap* extension_info_map = 1903 InfoMap* extension_info_map =
1900 extensions::ExtensionSystem::Get(profile)->info_map(); 1904 extensions::ExtensionSystem::Get(profile)->info_map();
1901 DesktopNotificationService* notification_service = 1905 DesktopNotificationService* notification_service =
1902 DesktopNotificationServiceFactory::GetForProfile(profile); 1906 DesktopNotificationServiceFactory::GetForProfile(profile);
1903 const Extension* extension = NULL; 1907 const Extension* extension = NULL;
1904 if (extension_info_map) { 1908 if (extension_info_map) {
1905 ExtensionSet extensions; 1909 ExtensionSet extensions;
1906 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( 1910 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1907 source_origin, render_process_id, 1911 source_origin, render_process_id,
1908 extensions::APIPermission::kNotification, &extensions); 1912 extensions::APIPermission::kNotification, &extensions);
1909 for (ExtensionSet::const_iterator iter = extensions.begin(); 1913 for (ExtensionSet::const_iterator iter = extensions.begin();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 // Sometimes a notification may be invoked during the shutdown. 1945 // Sometimes a notification may be invoked during the shutdown.
1942 // See http://crbug.com/256638 1946 // See http://crbug.com/256638
1943 if (browser_shutdown::IsTryingToQuit()) 1947 if (browser_shutdown::IsTryingToQuit())
1944 return blink::WebNotificationPresenter::PermissionNotAllowed; 1948 return blink::WebNotificationPresenter::PermissionNotAllowed;
1945 1949
1946 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1950 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1947 1951
1948 DesktopNotificationService* notification_service = 1952 DesktopNotificationService* notification_service =
1949 io_data->GetNotificationService(); 1953 io_data->GetNotificationService();
1950 if (notification_service) { 1954 if (notification_service) {
1951 ExtensionInfoMap* extension_info_map = io_data->GetExtensionInfoMap(); 1955 InfoMap* extension_info_map = io_data->GetExtensionInfoMap();
1952 ExtensionSet extensions; 1956 ExtensionSet extensions;
1953 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( 1957 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1954 source_origin, render_process_id, 1958 source_origin, render_process_id,
1955 extensions::APIPermission::kNotification, &extensions); 1959 extensions::APIPermission::kNotification, &extensions);
1956 for (ExtensionSet::const_iterator iter = extensions.begin(); 1960 for (ExtensionSet::const_iterator iter = extensions.begin();
1957 iter != extensions.end(); ++iter) { 1961 iter != extensions.end(); ++iter) {
1958 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id()); 1962 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id());
1959 if (notification_service->IsNotifierEnabled(notifier_id)) 1963 if (notification_service->IsNotifierEnabled(notifier_id))
1960 return blink::WebNotificationPresenter::PermissionAllowed; 1964 return blink::WebNotificationPresenter::PermissionAllowed;
1961 } 1965 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2032 content::ResourceContext* context, 2036 content::ResourceContext* context,
2033 int render_process_id, 2037 int render_process_id,
2034 bool is_guest, 2038 bool is_guest,
2035 int opener_id, 2039 int opener_id,
2036 bool* no_javascript_access) { 2040 bool* no_javascript_access) {
2037 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2041 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2038 2042
2039 *no_javascript_access = false; 2043 *no_javascript_access = false;
2040 2044
2041 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 2045 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2042 ExtensionInfoMap* map = io_data->GetExtensionInfoMap(); 2046 InfoMap* map = io_data->GetExtensionInfoMap();
2043 2047
2044 // If the opener is trying to create a background window but doesn't have 2048 // If the opener is trying to create a background window but doesn't have
2045 // the appropriate permission, fail the attempt. 2049 // the appropriate permission, fail the attempt.
2046 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { 2050 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
2047 if (!map->SecurityOriginHasAPIPermission( 2051 if (!map->SecurityOriginHasAPIPermission(
2048 source_origin, 2052 source_origin,
2049 render_process_id, 2053 render_process_id,
2050 APIPermission::kBackground)) { 2054 APIPermission::kBackground)) {
2051 return false; 2055 return false;
2052 } 2056 }
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
2644 return IsExtensionOrSharedModuleWhitelisted(url, extension_set, 2648 return IsExtensionOrSharedModuleWhitelisted(url, extension_set,
2645 allowed_file_handle_origins_) || 2649 allowed_file_handle_origins_) ||
2646 IsHostAllowedByCommandLine(url, extension_set, 2650 IsHostAllowedByCommandLine(url, extension_set,
2647 switches::kAllowNaClFileHandleAPI); 2651 switches::kAllowNaClFileHandleAPI);
2648 #else 2652 #else
2649 return false; 2653 return false;
2650 #endif 2654 #endif
2651 } 2655 }
2652 2656
2653 } // namespace chrome 2657 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698