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

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

Issue 2506183002: Make window.open() IPCs be frame-based (Closed)
Patch Set: Compile fix. Created 4 years 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
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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 2260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2271 ChromeContentBrowserClient::GetPlatformNotificationService() { 2271 ChromeContentBrowserClient::GetPlatformNotificationService() {
2272 #if defined(ENABLE_NOTIFICATIONS) 2272 #if defined(ENABLE_NOTIFICATIONS)
2273 return PlatformNotificationServiceImpl::GetInstance(); 2273 return PlatformNotificationServiceImpl::GetInstance();
2274 #else 2274 #else
2275 NOTIMPLEMENTED(); 2275 NOTIMPLEMENTED();
2276 return NULL; 2276 return NULL;
2277 #endif 2277 #endif
2278 } 2278 }
2279 2279
2280 bool ChromeContentBrowserClient::CanCreateWindow( 2280 bool ChromeContentBrowserClient::CanCreateWindow(
2281 int opener_render_process_id,
2282 int opener_render_frame_id,
2281 const GURL& opener_url, 2283 const GURL& opener_url,
2282 const GURL& opener_top_level_frame_url, 2284 const GURL& opener_top_level_frame_url,
2283 const GURL& source_origin, 2285 const GURL& source_origin,
2284 WindowContainerType container_type, 2286 WindowContainerType container_type,
2285 const GURL& target_url, 2287 const GURL& target_url,
2286 const content::Referrer& referrer, 2288 const content::Referrer& referrer,
2287 const std::string& frame_name, 2289 const std::string& frame_name,
2288 WindowOpenDisposition disposition, 2290 WindowOpenDisposition disposition,
2289 const WebWindowFeatures& features, 2291 const WebWindowFeatures& features,
2290 bool user_gesture, 2292 bool user_gesture,
2291 bool opener_suppressed, 2293 bool opener_suppressed,
2292 content::ResourceContext* context, 2294 content::ResourceContext* context,
2293 int render_process_id,
2294 int opener_render_view_id,
2295 int opener_render_frame_id,
2296 bool* no_javascript_access) { 2295 bool* no_javascript_access) {
2297 DCHECK_CURRENTLY_ON(BrowserThread::IO); 2296 DCHECK_CURRENTLY_ON(BrowserThread::IO);
2298 2297
2299 *no_javascript_access = false; 2298 *no_javascript_access = false;
2300 2299
2301 // If the opener is trying to create a background window but doesn't have 2300 // If the opener is trying to create a background window but doesn't have
2302 // the appropriate permission, fail the attempt. 2301 // the appropriate permission, fail the attempt.
2303 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { 2302 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
2304 #if BUILDFLAG(ENABLE_EXTENSIONS) 2303 #if BUILDFLAG(ENABLE_EXTENSIONS)
2305 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 2304 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2306 InfoMap* map = io_data->GetExtensionInfoMap(); 2305 InfoMap* map = io_data->GetExtensionInfoMap();
2307 if (!map->SecurityOriginHasAPIPermission( 2306 if (!map->SecurityOriginHasAPIPermission(source_origin,
2308 source_origin, 2307 opener_render_process_id,
2309 render_process_id, 2308 APIPermission::kBackground)) {
2310 APIPermission::kBackground)) {
2311 return false; 2309 return false;
2312 } 2310 }
2313 2311
2314 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may 2312 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
2315 // return a recently installed Extension even if this CanCreateWindow call 2313 // return a recently installed Extension even if this CanCreateWindow call
2316 // was made by an old copy of the page in a normal web process. That's ok, 2314 // was made by an old copy of the page in a normal web process. That's ok,
2317 // because the permission check above would have caused an early return 2315 // because the permission check above would have caused an early return
2318 // already. We must use the full URL to find hosted apps, though, and not 2316 // already. We must use the full URL to find hosted apps, though, and not
2319 // just the origin. 2317 // just the origin.
2320 const Extension* extension = 2318 const Extension* extension =
2321 map->extensions().GetExtensionOrAppByURL(opener_url); 2319 map->extensions().GetExtensionOrAppByURL(opener_url);
2322 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) 2320 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension))
2323 *no_javascript_access = true; 2321 *no_javascript_access = true;
2324 #endif 2322 #endif
2325 2323
2326 return true; 2324 return true;
2327 } 2325 }
2328 2326
2329 #if BUILDFLAG(ENABLE_EXTENSIONS) 2327 #if BUILDFLAG(ENABLE_EXTENSIONS)
2330 if (extensions::WebViewRendererState::GetInstance()->IsGuest( 2328 if (extensions::WebViewRendererState::GetInstance()->IsGuest(
2331 render_process_id)) { 2329 opener_render_process_id)) {
2332 return true; 2330 return true;
2333 } 2331 }
2334 2332
2335 if (target_url.SchemeIs(extensions::kExtensionScheme) || 2333 if (target_url.SchemeIs(extensions::kExtensionScheme) ||
2336 target_url.SchemeIs(extensions::kExtensionResourceScheme)) { 2334 target_url.SchemeIs(extensions::kExtensionResourceScheme)) {
2337 // Intentionally duplicating |io_data| and |map| code from above because we 2335 // Intentionally duplicating |io_data| and |map| code from above because we
2338 // want to reduce calls to retrieve them as this function is a SYNC IPC 2336 // want to reduce calls to retrieve them as this function is a SYNC IPC
2339 // handler. 2337 // handler.
2340 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 2338 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2341 InfoMap* map = io_data->GetExtensionInfoMap(); 2339 InfoMap* map = io_data->GetExtensionInfoMap();
(...skipping 18 matching lines...) Expand all
2360 2358
2361 HostContentSettingsMap* content_settings = 2359 HostContentSettingsMap* content_settings =
2362 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap(); 2360 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap();
2363 2361
2364 #if BUILDFLAG(ENABLE_PLUGINS) 2362 #if BUILDFLAG(ENABLE_PLUGINS)
2365 if (FlashDownloadInterception::ShouldStopFlashDownloadAction( 2363 if (FlashDownloadInterception::ShouldStopFlashDownloadAction(
2366 content_settings, opener_top_level_frame_url, target_url, 2364 content_settings, opener_top_level_frame_url, target_url,
2367 user_gesture)) { 2365 user_gesture)) {
2368 BrowserThread::PostTask( 2366 BrowserThread::PostTask(
2369 BrowserThread::UI, FROM_HERE, 2367 BrowserThread::UI, FROM_HERE,
2370 base::Bind(&HandleFlashDownloadActionOnUIThread, render_process_id, 2368 base::Bind(&HandleFlashDownloadActionOnUIThread,
2371 opener_render_frame_id, opener_top_level_frame_url)); 2369 opener_render_process_id, opener_render_frame_id,
2370 opener_top_level_frame_url));
2372 return false; 2371 return false;
2373 } 2372 }
2374 #endif 2373 #endif
2375 2374
2376 BlockedWindowParams blocked_params(target_url, 2375 BlockedWindowParams blocked_params(
2377 referrer, 2376 target_url, referrer, frame_name, disposition, features, user_gesture,
2378 frame_name, 2377 opener_suppressed, opener_render_process_id, opener_render_frame_id);
2379 disposition,
2380 features,
2381 user_gesture,
2382 opener_suppressed,
2383 render_process_id,
2384 opener_render_frame_id);
2385 2378
2386 if (!user_gesture && 2379 if (!user_gesture &&
2387 !base::CommandLine::ForCurrentProcess()->HasSwitch( 2380 !base::CommandLine::ForCurrentProcess()->HasSwitch(
2388 switches::kDisablePopupBlocking)) { 2381 switches::kDisablePopupBlocking)) {
2389 if (content_settings->GetContentSetting(opener_top_level_frame_url, 2382 if (content_settings->GetContentSetting(opener_top_level_frame_url,
2390 opener_top_level_frame_url, 2383 opener_top_level_frame_url,
2391 CONTENT_SETTINGS_TYPE_POPUPS, 2384 CONTENT_SETTINGS_TYPE_POPUPS,
2392 std::string()) != 2385 std::string()) !=
2393 CONTENT_SETTING_ALLOW) { 2386 CONTENT_SETTING_ALLOW) {
2394 BrowserThread::PostTask(BrowserThread::UI, 2387 BrowserThread::PostTask(BrowserThread::UI,
2395 FROM_HERE, 2388 FROM_HERE,
2396 base::Bind(&HandleBlockedPopupOnUIThread, 2389 base::Bind(&HandleBlockedPopupOnUIThread,
2397 blocked_params)); 2390 blocked_params));
2398 return false; 2391 return false;
2399 } 2392 }
2400 } 2393 }
2401 2394
2402 #if BUILDFLAG(ANDROID_JAVA_UI) 2395 #if BUILDFLAG(ANDROID_JAVA_UI)
2403 if (SingleTabModeTabHelper::IsRegistered(render_process_id, 2396 if (SingleTabModeTabHelper::IsRegistered(opener_render_process_id,
2404 opener_render_view_id)) { 2397 opener_render_frame_id)) {
2405 BrowserThread::PostTask(BrowserThread::UI, 2398 BrowserThread::PostTask(BrowserThread::UI,
2406 FROM_HERE, 2399 FROM_HERE,
2407 base::Bind(&HandleSingleTabModeBlockOnUIThread, 2400 base::Bind(&HandleSingleTabModeBlockOnUIThread,
2408 blocked_params)); 2401 blocked_params));
2409 return false; 2402 return false;
2410 } 2403 }
2411 #endif 2404 #endif
2412 2405
2413 return true; 2406 return true;
2414 } 2407 }
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
3314 render_frame_host, std::move(source), std::move(request)); 3307 render_frame_host, std::move(source), std::move(request));
3315 #else 3308 #else
3316 // Chrome's media remoting implementation depends on the Media Router 3309 // Chrome's media remoting implementation depends on the Media Router
3317 // infrastructure to identify remote sinks and provide the user interface for 3310 // infrastructure to identify remote sinks and provide the user interface for
3318 // sink selection. In the case where the Media Router is not present, simply 3311 // sink selection. In the case where the Media Router is not present, simply
3319 // drop the interface request. This will prevent code paths for media remoting 3312 // drop the interface request. This will prevent code paths for media remoting
3320 // in the renderer process from activating. 3313 // in the renderer process from activating.
3321 #endif 3314 #endif
3322 } 3315 }
3323 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING) 3316 #endif // BUILDFLAG(ENABLE_MEDIA_REMOTING)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698