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 <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 2247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2258 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { | 2258 content::MediaObserver* ChromeContentBrowserClient::GetMediaObserver() { |
2259 return MediaCaptureDevicesDispatcher::GetInstance(); | 2259 return MediaCaptureDevicesDispatcher::GetInstance(); |
2260 } | 2260 } |
2261 | 2261 |
2262 content::PlatformNotificationService* | 2262 content::PlatformNotificationService* |
2263 ChromeContentBrowserClient::GetPlatformNotificationService() { | 2263 ChromeContentBrowserClient::GetPlatformNotificationService() { |
2264 return PlatformNotificationServiceImpl::GetInstance(); | 2264 return PlatformNotificationServiceImpl::GetInstance(); |
2265 } | 2265 } |
2266 | 2266 |
2267 bool ChromeContentBrowserClient::CanCreateWindow( | 2267 bool ChromeContentBrowserClient::CanCreateWindow( |
| 2268 int opener_render_process_id, |
| 2269 int opener_render_frame_id, |
2268 const GURL& opener_url, | 2270 const GURL& opener_url, |
2269 const GURL& opener_top_level_frame_url, | 2271 const GURL& opener_top_level_frame_url, |
2270 const GURL& source_origin, | 2272 const GURL& source_origin, |
2271 WindowContainerType container_type, | 2273 WindowContainerType container_type, |
2272 const GURL& target_url, | 2274 const GURL& target_url, |
2273 const content::Referrer& referrer, | 2275 const content::Referrer& referrer, |
2274 const std::string& frame_name, | 2276 const std::string& frame_name, |
2275 WindowOpenDisposition disposition, | 2277 WindowOpenDisposition disposition, |
2276 const WebWindowFeatures& features, | 2278 const WebWindowFeatures& features, |
2277 bool user_gesture, | 2279 bool user_gesture, |
2278 bool opener_suppressed, | 2280 bool opener_suppressed, |
2279 content::ResourceContext* context, | 2281 content::ResourceContext* context, |
2280 int render_process_id, | |
2281 int opener_render_view_id, | |
2282 int opener_render_frame_id, | |
2283 bool* no_javascript_access) { | 2282 bool* no_javascript_access) { |
2284 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 2283 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
2285 | 2284 |
2286 *no_javascript_access = false; | 2285 *no_javascript_access = false; |
2287 | 2286 |
2288 // If the opener is trying to create a background window but doesn't have | 2287 // If the opener is trying to create a background window but doesn't have |
2289 // the appropriate permission, fail the attempt. | 2288 // the appropriate permission, fail the attempt. |
2290 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { | 2289 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { |
2291 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2290 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2292 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 2291 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
2293 InfoMap* map = io_data->GetExtensionInfoMap(); | 2292 InfoMap* map = io_data->GetExtensionInfoMap(); |
2294 if (!map->SecurityOriginHasAPIPermission( | 2293 if (!map->SecurityOriginHasAPIPermission(source_origin, |
2295 source_origin, | 2294 opener_render_process_id, |
2296 render_process_id, | 2295 APIPermission::kBackground)) { |
2297 APIPermission::kBackground)) { | |
2298 return false; | 2296 return false; |
2299 } | 2297 } |
2300 | 2298 |
2301 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may | 2299 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may |
2302 // return a recently installed Extension even if this CanCreateWindow call | 2300 // return a recently installed Extension even if this CanCreateWindow call |
2303 // was made by an old copy of the page in a normal web process. That's ok, | 2301 // was made by an old copy of the page in a normal web process. That's ok, |
2304 // because the permission check above would have caused an early return | 2302 // because the permission check above would have caused an early return |
2305 // already. We must use the full URL to find hosted apps, though, and not | 2303 // already. We must use the full URL to find hosted apps, though, and not |
2306 // just the origin. | 2304 // just the origin. |
2307 const Extension* extension = | 2305 const Extension* extension = |
2308 map->extensions().GetExtensionOrAppByURL(opener_url); | 2306 map->extensions().GetExtensionOrAppByURL(opener_url); |
2309 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) | 2307 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) |
2310 *no_javascript_access = true; | 2308 *no_javascript_access = true; |
2311 #endif | 2309 #endif |
2312 | 2310 |
2313 return true; | 2311 return true; |
2314 } | 2312 } |
2315 | 2313 |
2316 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2314 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2317 if (extensions::WebViewRendererState::GetInstance()->IsGuest( | 2315 if (extensions::WebViewRendererState::GetInstance()->IsGuest( |
2318 render_process_id)) { | 2316 opener_render_process_id)) { |
2319 return true; | 2317 return true; |
2320 } | 2318 } |
2321 | 2319 |
2322 if (target_url.SchemeIs(extensions::kExtensionScheme)) { | 2320 if (target_url.SchemeIs(extensions::kExtensionScheme)) { |
2323 // Intentionally duplicating |io_data| and |map| code from above because we | 2321 // Intentionally duplicating |io_data| and |map| code from above because we |
2324 // want to reduce calls to retrieve them as this function is a SYNC IPC | 2322 // want to reduce calls to retrieve them as this function is a SYNC IPC |
2325 // handler. | 2323 // handler. |
2326 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 2324 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
2327 InfoMap* map = io_data->GetExtensionInfoMap(); | 2325 InfoMap* map = io_data->GetExtensionInfoMap(); |
2328 const Extension* extension = | 2326 const Extension* extension = |
(...skipping 18 matching lines...) Expand all Loading... |
2347 | 2345 |
2348 HostContentSettingsMap* content_settings = | 2346 HostContentSettingsMap* content_settings = |
2349 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap(); | 2347 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap(); |
2350 | 2348 |
2351 #if BUILDFLAG(ENABLE_PLUGINS) | 2349 #if BUILDFLAG(ENABLE_PLUGINS) |
2352 if (FlashDownloadInterception::ShouldStopFlashDownloadAction( | 2350 if (FlashDownloadInterception::ShouldStopFlashDownloadAction( |
2353 content_settings, opener_top_level_frame_url, target_url, | 2351 content_settings, opener_top_level_frame_url, target_url, |
2354 user_gesture)) { | 2352 user_gesture)) { |
2355 BrowserThread::PostTask( | 2353 BrowserThread::PostTask( |
2356 BrowserThread::UI, FROM_HERE, | 2354 BrowserThread::UI, FROM_HERE, |
2357 base::Bind(&HandleFlashDownloadActionOnUIThread, render_process_id, | 2355 base::Bind(&HandleFlashDownloadActionOnUIThread, |
2358 opener_render_frame_id, opener_top_level_frame_url)); | 2356 opener_render_process_id, opener_render_frame_id, |
| 2357 opener_top_level_frame_url)); |
2359 return false; | 2358 return false; |
2360 } | 2359 } |
2361 #endif | 2360 #endif |
2362 | 2361 |
2363 BlockedWindowParams blocked_params(target_url, | 2362 BlockedWindowParams blocked_params( |
2364 referrer, | 2363 target_url, referrer, frame_name, disposition, features, user_gesture, |
2365 frame_name, | 2364 opener_suppressed, opener_render_process_id, opener_render_frame_id); |
2366 disposition, | |
2367 features, | |
2368 user_gesture, | |
2369 opener_suppressed, | |
2370 render_process_id, | |
2371 opener_render_frame_id); | |
2372 | 2365 |
2373 if (!user_gesture && | 2366 if (!user_gesture && |
2374 !base::CommandLine::ForCurrentProcess()->HasSwitch( | 2367 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
2375 switches::kDisablePopupBlocking)) { | 2368 switches::kDisablePopupBlocking)) { |
2376 if (content_settings->GetContentSetting(opener_top_level_frame_url, | 2369 if (content_settings->GetContentSetting(opener_top_level_frame_url, |
2377 opener_top_level_frame_url, | 2370 opener_top_level_frame_url, |
2378 CONTENT_SETTINGS_TYPE_POPUPS, | 2371 CONTENT_SETTINGS_TYPE_POPUPS, |
2379 std::string()) != | 2372 std::string()) != |
2380 CONTENT_SETTING_ALLOW) { | 2373 CONTENT_SETTING_ALLOW) { |
2381 BrowserThread::PostTask(BrowserThread::UI, | 2374 BrowserThread::PostTask(BrowserThread::UI, |
2382 FROM_HERE, | 2375 FROM_HERE, |
2383 base::Bind(&HandleBlockedPopupOnUIThread, | 2376 base::Bind(&HandleBlockedPopupOnUIThread, |
2384 blocked_params)); | 2377 blocked_params)); |
2385 return false; | 2378 return false; |
2386 } | 2379 } |
2387 } | 2380 } |
2388 | 2381 |
2389 #if BUILDFLAG(ANDROID_JAVA_UI) | 2382 #if BUILDFLAG(ANDROID_JAVA_UI) |
2390 if (SingleTabModeTabHelper::IsRegistered(render_process_id, | 2383 if (SingleTabModeTabHelper::IsRegistered(opener_render_process_id, |
2391 opener_render_view_id)) { | 2384 opener_render_frame_id)) { |
2392 BrowserThread::PostTask(BrowserThread::UI, | 2385 BrowserThread::PostTask(BrowserThread::UI, |
2393 FROM_HERE, | 2386 FROM_HERE, |
2394 base::Bind(&HandleSingleTabModeBlockOnUIThread, | 2387 base::Bind(&HandleSingleTabModeBlockOnUIThread, |
2395 blocked_params)); | 2388 blocked_params)); |
2396 return false; | 2389 return false; |
2397 } | 2390 } |
2398 #endif | 2391 #endif |
2399 | 2392 |
2400 return true; | 2393 return true; |
2401 } | 2394 } |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3371 bool ChromeContentBrowserClient::ShouldRedirectDOMStorageTaskRunner() { | 3364 bool ChromeContentBrowserClient::ShouldRedirectDOMStorageTaskRunner() { |
3372 return variations::GetVariationParamValue( | 3365 return variations::GetVariationParamValue( |
3373 "BrowserScheduler", "RedirectDOMStorageTaskRunner") == "true"; | 3366 "BrowserScheduler", "RedirectDOMStorageTaskRunner") == "true"; |
3374 } | 3367 } |
3375 | 3368 |
3376 bool ChromeContentBrowserClient:: | 3369 bool ChromeContentBrowserClient:: |
3377 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { | 3370 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { |
3378 return variations::GetVariationParamValue( | 3371 return variations::GetVariationParamValue( |
3379 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; | 3372 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; |
3380 } | 3373 } |
OLD | NEW |