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

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

Issue 9837074: Make it so that allow_js_access: false can be used with background pages created by window.open. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 months 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 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 1252 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
1253 DesktopNotificationService* service = 1253 DesktopNotificationService* service =
1254 DesktopNotificationServiceFactory::GetForProfile(profile); 1254 DesktopNotificationServiceFactory::GetForProfile(profile);
1255 service->CancelDesktopNotification( 1255 service->CancelDesktopNotification(
1256 render_process_id, render_view_id, notification_id); 1256 render_process_id, render_view_id, notification_id);
1257 #else 1257 #else
1258 NOTIMPLEMENTED(); 1258 NOTIMPLEMENTED();
1259 #endif 1259 #endif
1260 } 1260 }
1261 1261
1262 bool ChromeContentBrowserClient::CanCreateWindow( 1262 content::ContentBrowserClient::CanCreateWindowResult
1263 ChromeContentBrowserClient::CanCreateWindow(
1263 const GURL& opener_url, 1264 const GURL& opener_url,
1264 const GURL& source_origin, 1265 const GURL& source_origin,
1265 WindowContainerType container_type, 1266 WindowContainerType container_type,
1266 content::ResourceContext* context, 1267 content::ResourceContext* context,
1267 int render_process_id) { 1268 int render_process_id) {
1268 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1269 // If the opener is trying to create a background window but doesn't have 1270 // If the opener is trying to create a background window but doesn't have
1270 // the appropriate permission, fail the attempt. 1271 // the appropriate permission, fail the attempt.
1271 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { 1272 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
1272 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1273 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1273 ExtensionInfoMap* map = io_data->GetExtensionInfoMap(); 1274 ExtensionInfoMap* map = io_data->GetExtensionInfoMap();
1274 1275
1275 // If the opener is not allowed to script its background window, then return 1276 if (!map->SecurityOriginHasAPIPermission(
1276 // false so that the window.open call returns null. In this case, only 1277 source_origin, render_process_id, ExtensionAPIPermission::kBackground)) {
Andrew T Wilson (Slow) 2012/03/26 15:28:10 nit: 80 chars
Mihai Parparita -not on Chrome 2012/03/27 01:16:07 Done.
1277 // the manifest is permitted to create a background window. 1278 return CANNOT_CREATE_WINDOW;
1279 }
1280
1278 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may 1281 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
1279 // return a recently installed Extension even if this CanCreateWindow call 1282 // return a recently installed Extension even if this CanCreateWindow call
1280 // was made by an old copy of the page in a normal web process. That's ok, 1283 // was made by an old copy of the page in a normal web process. That's ok,
1281 // because the permission check below will still fail. We must use the 1284 // because the permission check above would have caused an early return
1282 // full URL to find hosted apps, though, and not just the origin. 1285 // already. We must use the full URL to find hosted apps, though, and not
1286 // just the origin.
1283 const Extension* extension = map->extensions().GetExtensionOrAppByURL( 1287 const Extension* extension = map->extensions().GetExtensionOrAppByURL(
1284 ExtensionURLInfo(opener_url)); 1288 ExtensionURLInfo(opener_url));
1285 if (extension && !extension->allow_background_js_access()) 1289 if (extension && !extension->allow_background_js_access())
1286 return false; 1290 return CAN_CREATE_WINDOW_NO_JS_ACCESS;
1287
1288 return map->SecurityOriginHasAPIPermission(
1289 source_origin, render_process_id, ExtensionAPIPermission::kBackground);
1290 } 1291 }
1291 return true; 1292 return CAN_CREATE_WINDOW;
1292 } 1293 }
1293 1294
1294 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( 1295 std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
1295 const GURL& url, content::ResourceContext* context) { 1296 const GURL& url, content::ResourceContext* context) {
1296 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1297 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1297 // Check if it's an extension-created worker, in which case we want to use 1298 // Check if it's an extension-created worker, in which case we want to use
1298 // the name of the extension. 1299 // the name of the extension.
1299 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1300 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1300 const Extension* extension = 1301 const Extension* extension =
1301 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); 1302 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 #if defined(USE_NSS) 1633 #if defined(USE_NSS)
1633 crypto::CryptoModuleBlockingPasswordDelegate* 1634 crypto::CryptoModuleBlockingPasswordDelegate*
1634 ChromeContentBrowserClient::GetCryptoPasswordDelegate( 1635 ChromeContentBrowserClient::GetCryptoPasswordDelegate(
1635 const GURL& url) { 1636 const GURL& url) {
1636 return browser::NewCryptoModuleBlockingDialogDelegate( 1637 return browser::NewCryptoModuleBlockingDialogDelegate(
1637 browser::kCryptoModulePasswordKeygen, url.host()); 1638 browser::kCryptoModulePasswordKeygen, url.host());
1638 } 1639 }
1639 #endif 1640 #endif
1640 1641
1641 } // namespace chrome 1642 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698