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 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1408 return true; | 1408 return true; |
1409 | 1409 |
1410 // Otherwise, swap BrowsingInstances if current_extension and new_extension | 1410 // Otherwise, swap BrowsingInstances if current_extension and new_extension |
1411 // differ. | 1411 // differ. |
1412 return current_extension != new_extension; | 1412 return current_extension != new_extension; |
1413 } | 1413 } |
1414 | 1414 |
1415 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( | 1415 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( |
1416 content::ResourceContext* resource_context, const GURL& current_url, | 1416 content::ResourceContext* resource_context, const GURL& current_url, |
1417 const GURL& new_url) { | 1417 const GURL& new_url) { |
1418 #if defined(ENABLE_EXTENSIONS) | |
1418 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); | 1419 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); |
1419 return extensions::CrossesExtensionProcessBoundary( | 1420 return extensions::CrossesExtensionProcessBoundary( |
1420 io_data->GetExtensionInfoMap()->extensions(), | 1421 io_data->GetExtensionInfoMap()->extensions(), |
1421 current_url, new_url, false); | 1422 current_url, new_url, false); |
1423 #else | |
1424 return false; | |
1425 #endif | |
1422 } | 1426 } |
1423 | 1427 |
1424 bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) { | 1428 bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) { |
1425 return !url.SchemeIs(chrome::kChromeNativeScheme); | 1429 return !url.SchemeIs(chrome::kChromeNativeScheme); |
1426 } | 1430 } |
1427 | 1431 |
1428 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( | 1432 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( |
1429 const std::string& alias_name) { | 1433 const std::string& alias_name) { |
1430 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); | 1434 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); |
1431 } | 1435 } |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1933 i->first, i->second, url, name, !allow)); | 1937 i->first, i->second, url, name, !allow)); |
1934 } | 1938 } |
1935 | 1939 |
1936 return allow; | 1940 return allow; |
1937 } | 1941 } |
1938 | 1942 |
1939 net::URLRequestContext* | 1943 net::URLRequestContext* |
1940 ChromeContentBrowserClient::OverrideRequestContextForURL( | 1944 ChromeContentBrowserClient::OverrideRequestContextForURL( |
1941 const GURL& url, content::ResourceContext* context) { | 1945 const GURL& url, content::ResourceContext* context) { |
1942 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1946 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
1947 #if defined(ENABLE_EXTENSIONS) | |
1943 if (url.SchemeIs(extensions::kExtensionScheme)) { | 1948 if (url.SchemeIs(extensions::kExtensionScheme)) { |
1944 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1949 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
1945 return io_data->extensions_request_context(); | 1950 return io_data->extensions_request_context(); |
1946 } | 1951 } |
1952 #endif | |
1947 | 1953 |
1948 return NULL; | 1954 return NULL; |
1949 } | 1955 } |
1950 | 1956 |
1951 QuotaPermissionContext* | 1957 QuotaPermissionContext* |
1952 ChromeContentBrowserClient::CreateQuotaPermissionContext() { | 1958 ChromeContentBrowserClient::CreateQuotaPermissionContext() { |
1953 return new ChromeQuotaPermissionContext(); | 1959 return new ChromeQuotaPermissionContext(); |
1954 } | 1960 } |
1955 | 1961 |
1956 void ChromeContentBrowserClient::AllowCertificateError( | 1962 void ChromeContentBrowserClient::AllowCertificateError( |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2242 bool user_gesture, | 2248 bool user_gesture, |
2243 bool opener_suppressed, | 2249 bool opener_suppressed, |
2244 content::ResourceContext* context, | 2250 content::ResourceContext* context, |
2245 int render_process_id, | 2251 int render_process_id, |
2246 int opener_id, | 2252 int opener_id, |
2247 bool* no_javascript_access) { | 2253 bool* no_javascript_access) { |
2248 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2254 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
2249 | 2255 |
2250 *no_javascript_access = false; | 2256 *no_javascript_access = false; |
2251 | 2257 |
2258 #if defined(ENABLE_EXTENSIONS) | |
2252 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 2259 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
Tom Sepez
2014/07/14 16:12:43
nit: can these declarations move into the #if bloc
Lei Zhang
2014/07/14 21:26:06
Thanks, done.
| |
2253 InfoMap* map = io_data->GetExtensionInfoMap(); | 2260 InfoMap* map = io_data->GetExtensionInfoMap(); |
2261 #endif | |
2254 | 2262 |
2255 // If the opener is trying to create a background window but doesn't have | 2263 // If the opener is trying to create a background window but doesn't have |
2256 // the appropriate permission, fail the attempt. | 2264 // the appropriate permission, fail the attempt. |
2257 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { | 2265 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
2266 #if defined(ENABLE_EXTENSIONS) | |
2258 if (!map->SecurityOriginHasAPIPermission( | 2267 if (!map->SecurityOriginHasAPIPermission( |
2259 source_origin, | 2268 source_origin, |
2260 render_process_id, | 2269 render_process_id, |
2261 APIPermission::kBackground)) { | 2270 APIPermission::kBackground)) { |
2262 return false; | 2271 return false; |
2263 } | 2272 } |
2264 | 2273 |
2265 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may | 2274 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may |
2266 // return a recently installed Extension even if this CanCreateWindow call | 2275 // return a recently installed Extension even if this CanCreateWindow call |
2267 // was made by an old copy of the page in a normal web process. That's ok, | 2276 // was made by an old copy of the page in a normal web process. That's ok, |
2268 // because the permission check above would have caused an early return | 2277 // because the permission check above would have caused an early return |
2269 // already. We must use the full URL to find hosted apps, though, and not | 2278 // already. We must use the full URL to find hosted apps, though, and not |
2270 // just the origin. | 2279 // just the origin. |
2271 const Extension* extension = | 2280 const Extension* extension = |
2272 map->extensions().GetExtensionOrAppByURL(opener_url); | 2281 map->extensions().GetExtensionOrAppByURL(opener_url); |
2273 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) | 2282 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) |
2274 *no_javascript_access = true; | 2283 *no_javascript_access = true; |
2284 #endif | |
2275 | 2285 |
2276 return true; | 2286 return true; |
2277 } | 2287 } |
2278 | 2288 |
2279 #if defined(ENABLE_EXTENSIONS) | 2289 #if defined(ENABLE_EXTENSIONS) |
2280 if (WebViewRendererState::GetInstance()->IsGuest(render_process_id)) | 2290 if (WebViewRendererState::GetInstance()->IsGuest(render_process_id)) |
2281 return true; | 2291 return true; |
2282 #endif | 2292 #endif |
2283 | 2293 |
2284 HostContentSettingsMap* content_settings = | 2294 HostContentSettingsMap* content_settings = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2316 return false; | 2326 return false; |
2317 } | 2327 } |
2318 #endif | 2328 #endif |
2319 | 2329 |
2320 return true; | 2330 return true; |
2321 } | 2331 } |
2322 | 2332 |
2323 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( | 2333 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( |
2324 const GURL& url, content::ResourceContext* context) { | 2334 const GURL& url, content::ResourceContext* context) { |
2325 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 2335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
2336 #if defined(ENABLE_EXTENSIONS) | |
2326 // Check if it's an extension-created worker, in which case we want to use | 2337 // Check if it's an extension-created worker, in which case we want to use |
2327 // the name of the extension. | 2338 // the name of the extension. |
2328 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 2339 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
2329 const Extension* extension = | 2340 const Extension* extension = |
2330 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); | 2341 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); |
2331 return extension ? extension->name() : std::string(); | 2342 return extension ? extension->name() : std::string(); |
2343 #else | |
2344 return std::string(); | |
2345 #endif | |
2332 } | 2346 } |
2333 | 2347 |
2334 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { | 2348 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { |
2335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2336 prerender_tracker_ = g_browser_process->prerender_tracker(); | 2350 prerender_tracker_ = g_browser_process->prerender_tracker(); |
2337 return g_browser_process->ResourceDispatcherHostCreated(); | 2351 return g_browser_process->ResourceDispatcherHostCreated(); |
2338 } | 2352 } |
2339 | 2353 |
2340 // TODO(tommi): Rename from Get to Create. | 2354 // TODO(tommi): Rename from Get to Create. |
2341 content::SpeechRecognitionManagerDelegate* | 2355 content::SpeechRecognitionManagerDelegate* |
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2889 switches::kDisableWebRtcEncryption, | 2903 switches::kDisableWebRtcEncryption, |
2890 }; | 2904 }; |
2891 to_command_line->CopySwitchesFrom(from_command_line, | 2905 to_command_line->CopySwitchesFrom(from_command_line, |
2892 kWebRtcDevSwitchNames, | 2906 kWebRtcDevSwitchNames, |
2893 arraysize(kWebRtcDevSwitchNames)); | 2907 arraysize(kWebRtcDevSwitchNames)); |
2894 } | 2908 } |
2895 } | 2909 } |
2896 #endif // defined(ENABLE_WEBRTC) | 2910 #endif // defined(ENABLE_WEBRTC) |
2897 | 2911 |
2898 } // namespace chrome | 2912 } // namespace chrome |
OLD | NEW |