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

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: Comment fix 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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 #include "content/public/browser/child_process_security_policy.h" 119 #include "content/public/browser/child_process_security_policy.h"
121 #include "content/public/browser/render_process_host.h" 120 #include "content/public/browser/render_process_host.h"
122 #include "content/public/browser/render_view_host.h" 121 #include "content/public/browser/render_view_host.h"
123 #include "content/public/browser/resource_context.h" 122 #include "content/public/browser/resource_context.h"
124 #include "content/public/browser/site_instance.h" 123 #include "content/public/browser/site_instance.h"
125 #include "content/public/browser/web_contents.h" 124 #include "content/public/browser/web_contents.h"
126 #include "content/public/browser/web_contents_view.h" 125 #include "content/public/browser/web_contents_view.h"
127 #include "content/public/common/child_process_host.h" 126 #include "content/public/common/child_process_host.h"
128 #include "content/public/common/content_descriptors.h" 127 #include "content/public/common/content_descriptors.h"
129 #include "content/public/common/url_utils.h" 128 #include "content/public/common/url_utils.h"
129 #include "extensions/browser/info_map.h"
130 #include "extensions/browser/view_type_utils.h" 130 #include "extensions/browser/view_type_utils.h"
131 #include "extensions/common/constants.h" 131 #include "extensions/common/constants.h"
132 #include "extensions/common/manifest_handlers/background_info.h" 132 #include "extensions/common/manifest_handlers/background_info.h"
133 #include "extensions/common/switches.h" 133 #include "extensions/common/switches.h"
134 #include "grit/generated_resources.h" 134 #include "grit/generated_resources.h"
135 #include "grit/ui_resources.h" 135 #include "grit/ui_resources.h"
136 #include "net/base/escape.h" 136 #include "net/base/escape.h"
137 #include "net/base/mime_util.h" 137 #include "net/base/mime_util.h"
138 #include "net/cookies/canonical_cookie.h" 138 #include "net/cookies/canonical_cookie.h"
139 #include "net/cookies/cookie_options.h" 139 #include "net/cookies/cookie_options.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 using content::BrowserThread; 244 using content::BrowserThread;
245 using content::BrowserURLHandler; 245 using content::BrowserURLHandler;
246 using content::ChildProcessSecurityPolicy; 246 using content::ChildProcessSecurityPolicy;
247 using content::FileDescriptorInfo; 247 using content::FileDescriptorInfo;
248 using content::QuotaPermissionContext; 248 using content::QuotaPermissionContext;
249 using content::RenderViewHost; 249 using content::RenderViewHost;
250 using content::SiteInstance; 250 using content::SiteInstance;
251 using content::WebContents; 251 using content::WebContents;
252 using extensions::APIPermission; 252 using extensions::APIPermission;
253 using extensions::Extension; 253 using extensions::Extension;
254 using extensions::InfoMap;
254 using extensions::Manifest; 255 using extensions::Manifest;
255 using message_center::NotifierId; 256 using message_center::NotifierId;
256 257
257 namespace { 258 namespace {
258 259
259 // Cached version of the locale so we can return the locale on the I/O 260 // Cached version of the locale so we can return the locale on the I/O
260 // thread. 261 // thread.
261 base::LazyInstance<std::string> g_io_thread_application_locale; 262 base::LazyInstance<std::string> g_io_thread_application_locale;
262 263
263 #if defined(ENABLE_PLUGINS) 264 #if defined(ENABLE_PLUGINS)
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 #if !defined(OS_CHROMEOS) 1261 #if !defined(OS_CHROMEOS)
1261 // We only expect there to be one signin process as we use process-per-site 1262 // We only expect there to be one signin process as we use process-per-site
1262 // for signin URLs. The signin process will be cleared from SigninManager 1263 // for signin URLs. The signin process will be cleared from SigninManager
1263 // when the renderer is destroyed. 1264 // when the renderer is destroyed.
1264 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) { 1265 if (SigninManager::IsWebBasedSigninFlowURL(site_instance->GetSiteURL())) {
1265 SigninManager* signin_manager = 1266 SigninManager* signin_manager =
1266 SigninManagerFactory::GetForProfile(profile); 1267 SigninManagerFactory::GetForProfile(profile);
1267 if (signin_manager) 1268 if (signin_manager)
1268 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID()); 1269 signin_manager->SetSigninProcess(site_instance->GetProcess()->GetID());
1269 BrowserThread::PostTask( 1270 BrowserThread::PostTask(
1270 BrowserThread::IO, FROM_HERE, 1271 BrowserThread::IO,
1271 base::Bind(&ExtensionInfoMap::SetSigninProcess, 1272 FROM_HERE,
1273 base::Bind(&InfoMap::SetSigninProcess,
1272 extensions::ExtensionSystem::Get(profile)->info_map(), 1274 extensions::ExtensionSystem::Get(profile)->info_map(),
1273 site_instance->GetProcess()->GetID())); 1275 site_instance->GetProcess()->GetID()));
1274 } 1276 }
1275 #endif 1277 #endif
1276 1278
1277 ExtensionService* service = 1279 ExtensionService* service =
1278 extensions::ExtensionSystem::Get(profile)->extension_service(); 1280 extensions::ExtensionSystem::Get(profile)->extension_service();
1279 if (!service) 1281 if (!service)
1280 return; 1282 return;
1281 1283
1282 const Extension* extension = service->extensions()->GetExtensionOrAppByURL( 1284 const Extension* extension = service->extensions()->GetExtensionOrAppByURL(
1283 site_instance->GetSiteURL()); 1285 site_instance->GetSiteURL());
1284 if (!extension) 1286 if (!extension)
1285 return; 1287 return;
1286 1288
1287 service->process_map()->Insert(extension->id(), 1289 service->process_map()->Insert(extension->id(),
1288 site_instance->GetProcess()->GetID(), 1290 site_instance->GetProcess()->GetID(),
1289 site_instance->GetId()); 1291 site_instance->GetId());
1290 BrowserThread::PostTask( 1292 BrowserThread::PostTask(
1291 BrowserThread::IO, FROM_HERE, 1293 BrowserThread::IO,
1292 base::Bind(&ExtensionInfoMap::RegisterExtensionProcess, 1294 FROM_HERE,
1295 base::Bind(&InfoMap::RegisterExtensionProcess,
1293 extensions::ExtensionSystem::Get(profile)->info_map(), 1296 extensions::ExtensionSystem::Get(profile)->info_map(),
1294 extension->id(), 1297 extension->id(),
1295 site_instance->GetProcess()->GetID(), 1298 site_instance->GetProcess()->GetID(),
1296 site_instance->GetId())); 1299 site_instance->GetId()));
1297 } 1300 }
1298 1301
1299 void ChromeContentBrowserClient::SiteInstanceDeleting( 1302 void ChromeContentBrowserClient::SiteInstanceDeleting(
1300 SiteInstance* site_instance) { 1303 SiteInstance* site_instance) {
1301 if (!site_instance->HasProcess()) 1304 if (!site_instance->HasProcess())
1302 return; 1305 return;
1303 1306
1304 Profile* profile = Profile::FromBrowserContext( 1307 Profile* profile = Profile::FromBrowserContext(
1305 site_instance->GetBrowserContext()); 1308 site_instance->GetBrowserContext());
1306 ExtensionService* service = 1309 ExtensionService* service =
1307 extensions::ExtensionSystem::Get(profile)->extension_service(); 1310 extensions::ExtensionSystem::Get(profile)->extension_service();
1308 if (!service) 1311 if (!service)
1309 return; 1312 return;
1310 1313
1311 const Extension* extension = service->extensions()->GetExtensionOrAppByURL( 1314 const Extension* extension = service->extensions()->GetExtensionOrAppByURL(
1312 site_instance->GetSiteURL()); 1315 site_instance->GetSiteURL());
1313 if (!extension) 1316 if (!extension)
1314 return; 1317 return;
1315 1318
1316 service->process_map()->Remove(extension->id(), 1319 service->process_map()->Remove(extension->id(),
1317 site_instance->GetProcess()->GetID(), 1320 site_instance->GetProcess()->GetID(),
1318 site_instance->GetId()); 1321 site_instance->GetId());
1319 BrowserThread::PostTask( 1322 BrowserThread::PostTask(
1320 BrowserThread::IO, FROM_HERE, 1323 BrowserThread::IO,
1321 base::Bind(&ExtensionInfoMap::UnregisterExtensionProcess, 1324 FROM_HERE,
1325 base::Bind(&InfoMap::UnregisterExtensionProcess,
1322 extensions::ExtensionSystem::Get(profile)->info_map(), 1326 extensions::ExtensionSystem::Get(profile)->info_map(),
1323 extension->id(), 1327 extension->id(),
1324 site_instance->GetProcess()->GetID(), 1328 site_instance->GetProcess()->GetID(),
1325 site_instance->GetId())); 1329 site_instance->GetId()));
1326 } 1330 }
1327 1331
1328 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation( 1332 bool ChromeContentBrowserClient::ShouldSwapProcessesForNavigation(
1329 SiteInstance* site_instance, 1333 SiteInstance* site_instance,
1330 const GURL& current_url, 1334 const GURL& current_url,
1331 const GURL& new_url) { 1335 const GURL& new_url) {
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 tab_util::GetWebContentsByID(render_process_id, render_view_id); 1890 tab_util::GetWebContentsByID(render_process_id, render_view_id);
1887 if (!contents) { 1891 if (!contents) {
1888 NOTREACHED(); 1892 NOTREACHED();
1889 return; 1893 return;
1890 } 1894 }
1891 1895
1892 // Skip showing the infobar if the request comes from an extension, and that 1896 // Skip showing the infobar if the request comes from an extension, and that
1893 // extension has the 'notify' permission. (If the extension does not have the 1897 // extension has the 'notify' permission. (If the extension does not have the
1894 // permission, the user will still be prompted.) 1898 // permission, the user will still be prompted.)
1895 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); 1899 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
1896 ExtensionInfoMap* extension_info_map = 1900 InfoMap* extension_info_map =
1897 extensions::ExtensionSystem::Get(profile)->info_map(); 1901 extensions::ExtensionSystem::Get(profile)->info_map();
1898 DesktopNotificationService* notification_service = 1902 DesktopNotificationService* notification_service =
1899 DesktopNotificationServiceFactory::GetForProfile(profile); 1903 DesktopNotificationServiceFactory::GetForProfile(profile);
1900 const Extension* extension = NULL; 1904 const Extension* extension = NULL;
1901 if (extension_info_map) { 1905 if (extension_info_map) {
1902 ExtensionSet extensions; 1906 ExtensionSet extensions;
1903 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( 1907 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1904 source_origin, render_process_id, 1908 source_origin, render_process_id,
1905 extensions::APIPermission::kNotification, &extensions); 1909 extensions::APIPermission::kNotification, &extensions);
1906 for (ExtensionSet::const_iterator iter = extensions.begin(); 1910 for (ExtensionSet::const_iterator iter = extensions.begin();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 // Sometimes a notification may be invoked during the shutdown. 1942 // Sometimes a notification may be invoked during the shutdown.
1939 // See http://crbug.com/256638 1943 // See http://crbug.com/256638
1940 if (browser_shutdown::IsTryingToQuit()) 1944 if (browser_shutdown::IsTryingToQuit())
1941 return blink::WebNotificationPresenter::PermissionNotAllowed; 1945 return blink::WebNotificationPresenter::PermissionNotAllowed;
1942 1946
1943 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1947 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1944 1948
1945 DesktopNotificationService* notification_service = 1949 DesktopNotificationService* notification_service =
1946 io_data->GetNotificationService(); 1950 io_data->GetNotificationService();
1947 if (notification_service) { 1951 if (notification_service) {
1948 ExtensionInfoMap* extension_info_map = io_data->GetExtensionInfoMap(); 1952 InfoMap* extension_info_map = io_data->GetExtensionInfoMap();
1949 ExtensionSet extensions; 1953 ExtensionSet extensions;
1950 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( 1954 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin(
1951 source_origin, render_process_id, 1955 source_origin, render_process_id,
1952 extensions::APIPermission::kNotification, &extensions); 1956 extensions::APIPermission::kNotification, &extensions);
1953 for (ExtensionSet::const_iterator iter = extensions.begin(); 1957 for (ExtensionSet::const_iterator iter = extensions.begin();
1954 iter != extensions.end(); ++iter) { 1958 iter != extensions.end(); ++iter) {
1955 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id()); 1959 NotifierId notifier_id(NotifierId::APPLICATION, (*iter)->id());
1956 if (notification_service->IsNotifierEnabled(notifier_id)) 1960 if (notification_service->IsNotifierEnabled(notifier_id))
1957 return blink::WebNotificationPresenter::PermissionAllowed; 1961 return blink::WebNotificationPresenter::PermissionAllowed;
1958 } 1962 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 content::ResourceContext* context, 2033 content::ResourceContext* context,
2030 int render_process_id, 2034 int render_process_id,
2031 bool is_guest, 2035 bool is_guest,
2032 int opener_id, 2036 int opener_id,
2033 bool* no_javascript_access) { 2037 bool* no_javascript_access) {
2034 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2038 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2035 2039
2036 *no_javascript_access = false; 2040 *no_javascript_access = false;
2037 2041
2038 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 2042 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2039 ExtensionInfoMap* map = io_data->GetExtensionInfoMap(); 2043 InfoMap* map = io_data->GetExtensionInfoMap();
2040 2044
2041 // If the opener is trying to create a background window but doesn't have 2045 // If the opener is trying to create a background window but doesn't have
2042 // the appropriate permission, fail the attempt. 2046 // the appropriate permission, fail the attempt.
2043 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { 2047 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
2044 if (!map->SecurityOriginHasAPIPermission( 2048 if (!map->SecurityOriginHasAPIPermission(
2045 source_origin, 2049 source_origin,
2046 render_process_id, 2050 render_process_id,
2047 APIPermission::kBackground)) { 2051 APIPermission::kBackground)) {
2048 return false; 2052 return false;
2049 } 2053 }
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
2626 return IsExtensionOrSharedModuleWhitelisted(url, extension_set, 2630 return IsExtensionOrSharedModuleWhitelisted(url, extension_set,
2627 allowed_file_handle_origins_) || 2631 allowed_file_handle_origins_) ||
2628 IsHostAllowedByCommandLine(url, extension_set, 2632 IsHostAllowedByCommandLine(url, extension_set,
2629 switches::kAllowNaClFileHandleAPI); 2633 switches::kAllowNaClFileHandleAPI);
2630 #else 2634 #else
2631 return false; 2635 return false;
2632 #endif 2636 #endif
2633 } 2637 }
2634 2638
2635 } // namespace chrome 2639 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/apps/ephemeral_app_throttle.cc ('k') | chrome/browser/extensions/api/bookmarks/bookmarks_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698