OLD | NEW |
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 #include "content/public/browser/render_view_host.h" | 118 #include "content/public/browser/render_view_host.h" |
119 #include "content/public/browser/resource_context.h" | 119 #include "content/public/browser/resource_context.h" |
120 #include "content/public/browser/site_instance.h" | 120 #include "content/public/browser/site_instance.h" |
121 #include "content/public/browser/web_contents.h" | 121 #include "content/public/browser/web_contents.h" |
122 #include "content/public/browser/web_contents_view.h" | 122 #include "content/public/browser/web_contents_view.h" |
123 #include "content/public/common/child_process_host.h" | 123 #include "content/public/common/child_process_host.h" |
124 #include "content/public/common/content_descriptors.h" | 124 #include "content/public/common/content_descriptors.h" |
125 #include "content/public/common/url_utils.h" | 125 #include "content/public/common/url_utils.h" |
126 #include "extensions/browser/info_map.h" | 126 #include "extensions/browser/info_map.h" |
127 #include "extensions/browser/process_manager.h" | 127 #include "extensions/browser/process_manager.h" |
| 128 #include "extensions/browser/process_map.h" |
128 #include "extensions/browser/view_type_utils.h" | 129 #include "extensions/browser/view_type_utils.h" |
129 #include "extensions/common/constants.h" | 130 #include "extensions/common/constants.h" |
130 #include "extensions/common/extension.h" | 131 #include "extensions/common/extension.h" |
131 #include "extensions/common/extension_set.h" | 132 #include "extensions/common/extension_set.h" |
132 #include "extensions/common/manifest_handlers/background_info.h" | 133 #include "extensions/common/manifest_handlers/background_info.h" |
133 #include "extensions/common/manifest_handlers/shared_module_info.h" | 134 #include "extensions/common/manifest_handlers/shared_module_info.h" |
134 #include "extensions/common/manifest_handlers/web_accessible_resources_info.h" | 135 #include "extensions/common/manifest_handlers/web_accessible_resources_info.h" |
135 #include "extensions/common/permissions/permissions_data.h" | 136 #include "extensions/common/permissions/permissions_data.h" |
136 #include "extensions/common/switches.h" | 137 #include "extensions/common/switches.h" |
137 #include "grit/generated_resources.h" | 138 #include "grit/generated_resources.h" |
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 Profile::FromBrowserContext(process_host->GetBrowserContext()); | 1084 Profile::FromBrowserContext(process_host->GetBrowserContext()); |
1084 ExtensionService* service = | 1085 ExtensionService* service = |
1085 extensions::ExtensionSystem::Get(profile)->extension_service(); | 1086 extensions::ExtensionSystem::Get(profile)->extension_service(); |
1086 if (!service) | 1087 if (!service) |
1087 return true; | 1088 return true; |
1088 const Extension* new_extension = | 1089 const Extension* new_extension = |
1089 service->extensions()->GetExtensionOrAppByURL(url); | 1090 service->extensions()->GetExtensionOrAppByURL(url); |
1090 if (new_extension && | 1091 if (new_extension && |
1091 new_extension->is_hosted_app() && | 1092 new_extension->is_hosted_app() && |
1092 new_extension->id() == extension_misc::kWebStoreAppId && | 1093 new_extension->id() == extension_misc::kWebStoreAppId && |
1093 !service->process_map()->Contains(new_extension->id(), | 1094 !extensions::ProcessMap::Get(profile)-> |
1094 process_host->GetID())) { | 1095 Contains(new_extension->id(), process_host->GetID())) { |
1095 return false; | 1096 return false; |
1096 } | 1097 } |
1097 | 1098 |
1098 return true; | 1099 return true; |
1099 } | 1100 } |
1100 | 1101 |
1101 bool ChromeContentBrowserClient::ShouldAllowOpenURL( | 1102 bool ChromeContentBrowserClient::ShouldAllowOpenURL( |
1102 content::SiteInstance* site_instance, const GURL& url) { | 1103 content::SiteInstance* site_instance, const GURL& url) { |
1103 GURL from_url = site_instance->GetSiteURL(); | 1104 GURL from_url = site_instance->GetSiteURL(); |
1104 // Do not allow pages from the web or other extensions navigate to | 1105 // Do not allow pages from the web or other extensions navigate to |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 } | 1154 } |
1154 | 1155 |
1155 #if !defined(OS_CHROMEOS) | 1156 #if !defined(OS_CHROMEOS) |
1156 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); | 1157 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); |
1157 if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID())) | 1158 if (signin_manager && signin_manager->IsSigninProcess(process_host->GetID())) |
1158 return SigninManager::IsWebBasedSigninFlowURL(site_url); | 1159 return SigninManager::IsWebBasedSigninFlowURL(site_url); |
1159 #endif | 1160 #endif |
1160 | 1161 |
1161 ExtensionService* service = | 1162 ExtensionService* service = |
1162 extensions::ExtensionSystem::Get(profile)->extension_service(); | 1163 extensions::ExtensionSystem::Get(profile)->extension_service(); |
1163 extensions::ProcessMap* process_map = service->process_map(); | 1164 extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile); |
1164 | 1165 |
1165 // Don't allow the Task Manager to share a process with anything else. | 1166 // Don't allow the Task Manager to share a process with anything else. |
1166 // Otherwise it can affect the renderers it is observing. | 1167 // Otherwise it can affect the renderers it is observing. |
1167 // Note: we could create another RenderProcessHostPrivilege bucket for | 1168 // Note: we could create another RenderProcessHostPrivilege bucket for |
1168 // this to allow multiple chrome://tasks instances to share, but that's | 1169 // this to allow multiple chrome://tasks instances to share, but that's |
1169 // a very unlikely case without serious consequences. | 1170 // a very unlikely case without serious consequences. |
1170 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin()) | 1171 if (site_url.GetOrigin() == GURL(chrome::kChromeUITaskManagerURL).GetOrigin()) |
1171 return false; | 1172 return false; |
1172 | 1173 |
1173 // These may be NULL during tests. In that case, just assume any site can | 1174 // These may be NULL during tests. In that case, just assume any site can |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 ExtensionService* service = | 1276 ExtensionService* service = |
1276 extensions::ExtensionSystem::Get(profile)->extension_service(); | 1277 extensions::ExtensionSystem::Get(profile)->extension_service(); |
1277 if (!service) | 1278 if (!service) |
1278 return; | 1279 return; |
1279 | 1280 |
1280 const Extension* extension = service->extensions()->GetExtensionOrAppByURL( | 1281 const Extension* extension = service->extensions()->GetExtensionOrAppByURL( |
1281 site_instance->GetSiteURL()); | 1282 site_instance->GetSiteURL()); |
1282 if (!extension) | 1283 if (!extension) |
1283 return; | 1284 return; |
1284 | 1285 |
1285 service->process_map()->Insert(extension->id(), | 1286 extensions::ProcessMap::Get(profile) |
1286 site_instance->GetProcess()->GetID(), | 1287 ->Insert(extension->id(), |
1287 site_instance->GetId()); | 1288 site_instance->GetProcess()->GetID(), |
| 1289 site_instance->GetId()); |
| 1290 |
1288 BrowserThread::PostTask( | 1291 BrowserThread::PostTask( |
1289 BrowserThread::IO, | 1292 BrowserThread::IO, |
1290 FROM_HERE, | 1293 FROM_HERE, |
1291 base::Bind(&InfoMap::RegisterExtensionProcess, | 1294 base::Bind(&InfoMap::RegisterExtensionProcess, |
1292 extensions::ExtensionSystem::Get(profile)->info_map(), | 1295 extensions::ExtensionSystem::Get(profile)->info_map(), |
1293 extension->id(), | 1296 extension->id(), |
1294 site_instance->GetProcess()->GetID(), | 1297 site_instance->GetProcess()->GetID(), |
1295 site_instance->GetId())); | 1298 site_instance->GetId())); |
1296 } | 1299 } |
1297 | 1300 |
1298 void ChromeContentBrowserClient::SiteInstanceDeleting( | 1301 void ChromeContentBrowserClient::SiteInstanceDeleting( |
1299 SiteInstance* site_instance) { | 1302 SiteInstance* site_instance) { |
1300 if (!site_instance->HasProcess()) | 1303 if (!site_instance->HasProcess()) |
1301 return; | 1304 return; |
1302 | 1305 |
1303 Profile* profile = Profile::FromBrowserContext( | 1306 Profile* profile = Profile::FromBrowserContext( |
1304 site_instance->GetBrowserContext()); | 1307 site_instance->GetBrowserContext()); |
1305 ExtensionService* service = | 1308 ExtensionService* service = |
1306 extensions::ExtensionSystem::Get(profile)->extension_service(); | 1309 extensions::ExtensionSystem::Get(profile)->extension_service(); |
1307 if (!service) | 1310 if (!service) |
1308 return; | 1311 return; |
1309 | 1312 |
1310 const Extension* extension = service->extensions()->GetExtensionOrAppByURL( | 1313 const Extension* extension = service->extensions()->GetExtensionOrAppByURL( |
1311 site_instance->GetSiteURL()); | 1314 site_instance->GetSiteURL()); |
1312 if (!extension) | 1315 if (!extension) |
1313 return; | 1316 return; |
1314 | 1317 |
1315 service->process_map()->Remove(extension->id(), | 1318 extensions::ProcessMap::Get(profile) |
1316 site_instance->GetProcess()->GetID(), | 1319 ->Remove(extension->id(), |
1317 site_instance->GetId()); | 1320 site_instance->GetProcess()->GetID(), |
| 1321 site_instance->GetId()); |
| 1322 |
1318 BrowserThread::PostTask( | 1323 BrowserThread::PostTask( |
1319 BrowserThread::IO, | 1324 BrowserThread::IO, |
1320 FROM_HERE, | 1325 FROM_HERE, |
1321 base::Bind(&InfoMap::UnregisterExtensionProcess, | 1326 base::Bind(&InfoMap::UnregisterExtensionProcess, |
1322 extensions::ExtensionSystem::Get(profile)->info_map(), | 1327 extensions::ExtensionSystem::Get(profile)->info_map(), |
1323 extension->id(), | 1328 extension->id(), |
1324 site_instance->GetProcess()->GetID(), | 1329 site_instance->GetProcess()->GetID(), |
1325 site_instance->GetId())); | 1330 site_instance->GetId())); |
1326 } | 1331 } |
1327 | 1332 |
(...skipping 29 matching lines...) Expand all Loading... |
1357 const Extension* new_extension = | 1362 const Extension* new_extension = |
1358 service->extensions()->GetExtensionOrAppByURL(new_url); | 1363 service->extensions()->GetExtensionOrAppByURL(new_url); |
1359 if (new_extension && | 1364 if (new_extension && |
1360 new_extension->is_hosted_app() && | 1365 new_extension->is_hosted_app() && |
1361 new_extension->id() != extension_misc::kWebStoreAppId) | 1366 new_extension->id() != extension_misc::kWebStoreAppId) |
1362 new_extension = NULL; | 1367 new_extension = NULL; |
1363 | 1368 |
1364 // First do a process check. We should force a BrowsingInstance swap if the | 1369 // First do a process check. We should force a BrowsingInstance swap if the |
1365 // current process doesn't know about new_extension, even if current_extension | 1370 // current process doesn't know about new_extension, even if current_extension |
1366 // is somehow the same as new_extension. | 1371 // is somehow the same as new_extension. |
| 1372 extensions::ProcessMap* process_map = extensions::ProcessMap::Get(profile); |
1367 if (new_extension && | 1373 if (new_extension && |
1368 site_instance->HasProcess() && | 1374 site_instance->HasProcess() && |
1369 !service->process_map()->Contains(new_extension->id(), | 1375 !process_map->Contains( |
1370 site_instance->GetProcess()->GetID())) | 1376 new_extension->id(), site_instance->GetProcess()->GetID())) |
1371 return true; | 1377 return true; |
1372 | 1378 |
1373 // Otherwise, swap BrowsingInstances if current_extension and new_extension | 1379 // Otherwise, swap BrowsingInstances if current_extension and new_extension |
1374 // differ. | 1380 // differ. |
1375 return current_extension != new_extension; | 1381 return current_extension != new_extension; |
1376 } | 1382 } |
1377 | 1383 |
1378 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( | 1384 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( |
1379 content::ResourceContext* resource_context, const GURL& current_url, | 1385 content::ResourceContext* resource_context, const GURL& current_url, |
1380 const GURL& new_url) { | 1386 const GURL& new_url) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1447 kWebRtcDevSwitchNames, | 1453 kWebRtcDevSwitchNames, |
1448 arraysize(kWebRtcDevSwitchNames)); | 1454 arraysize(kWebRtcDevSwitchNames)); |
1449 } | 1455 } |
1450 #endif | 1456 #endif |
1451 | 1457 |
1452 content::RenderProcessHost* process = | 1458 content::RenderProcessHost* process = |
1453 content::RenderProcessHost::FromID(child_process_id); | 1459 content::RenderProcessHost::FromID(child_process_id); |
1454 if (process) { | 1460 if (process) { |
1455 Profile* profile = Profile::FromBrowserContext( | 1461 Profile* profile = Profile::FromBrowserContext( |
1456 process->GetBrowserContext()); | 1462 process->GetBrowserContext()); |
1457 ExtensionService* extension_service = | 1463 |
1458 extensions::ExtensionSystem::Get(profile)->extension_service(); | 1464 if (extensions::ProcessMap::Get(profile)->Contains(process->GetID())) |
1459 if (extension_service) { | 1465 command_line->AppendSwitch(extensions::switches::kExtensionProcess); |
1460 extensions::ProcessMap* process_map = extension_service->process_map(); | |
1461 if (process_map && process_map->Contains(process->GetID())) | |
1462 command_line->AppendSwitch(extensions::switches::kExtensionProcess); | |
1463 } | |
1464 | 1466 |
1465 PrefService* prefs = profile->GetPrefs(); | 1467 PrefService* prefs = profile->GetPrefs(); |
1466 // Currently this pref is only registered if applied via a policy. | 1468 // Currently this pref is only registered if applied via a policy. |
1467 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && | 1469 if (prefs->HasPrefPath(prefs::kDisable3DAPIs) && |
1468 prefs->GetBoolean(prefs::kDisable3DAPIs)) { | 1470 prefs->GetBoolean(prefs::kDisable3DAPIs)) { |
1469 // Turn this policy into a command line switch. | 1471 // Turn this policy into a command line switch. |
1470 command_line->AppendSwitch(switches::kDisable3DAPIs); | 1472 command_line->AppendSwitch(switches::kDisable3DAPIs); |
1471 } | 1473 } |
1472 | 1474 |
1473 // Disable client-side phishing detection in the renderer if it is | 1475 // Disable client-side phishing detection in the renderer if it is |
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2655 // releases of Chrome. Permitting "Unknown" allows these APIs to be used on | 2657 // releases of Chrome. Permitting "Unknown" allows these APIs to be used on |
2656 // Chromium builds as well. | 2658 // Chromium builds as well. |
2657 return channel <= chrome::VersionInfo::CHANNEL_DEV; | 2659 return channel <= chrome::VersionInfo::CHANNEL_DEV; |
2658 #else | 2660 #else |
2659 return false; | 2661 return false; |
2660 #endif | 2662 #endif |
2661 } | 2663 } |
2662 | 2664 |
2663 | 2665 |
2664 } // namespace chrome | 2666 } // namespace chrome |
OLD | NEW |