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

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

Issue 383213007: ifdef more extensions code to be used only when extensions are enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments, lint Created 6 years, 5 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
« no previous file with comments | « no previous file | chrome/browser/media/protected_media_identifier_permission_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 return true; 1415 return true;
1416 1416
1417 // Otherwise, swap BrowsingInstances if current_extension and new_extension 1417 // Otherwise, swap BrowsingInstances if current_extension and new_extension
1418 // differ. 1418 // differ.
1419 return current_extension != new_extension; 1419 return current_extension != new_extension;
1420 } 1420 }
1421 1421
1422 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect( 1422 bool ChromeContentBrowserClient::ShouldSwapProcessesForRedirect(
1423 content::ResourceContext* resource_context, const GURL& current_url, 1423 content::ResourceContext* resource_context, const GURL& current_url,
1424 const GURL& new_url) { 1424 const GURL& new_url) {
1425 #if defined(ENABLE_EXTENSIONS)
1425 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 1426 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
1426 return extensions::CrossesExtensionProcessBoundary( 1427 return extensions::CrossesExtensionProcessBoundary(
1427 io_data->GetExtensionInfoMap()->extensions(), 1428 io_data->GetExtensionInfoMap()->extensions(),
1428 current_url, new_url, false); 1429 current_url, new_url, false);
1430 #else
1431 return false;
1432 #endif
1429 } 1433 }
1430 1434
1431 bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) { 1435 bool ChromeContentBrowserClient::ShouldAssignSiteForURL(const GURL& url) {
1432 return !url.SchemeIs(chrome::kChromeNativeScheme); 1436 return !url.SchemeIs(chrome::kChromeNativeScheme);
1433 } 1437 }
1434 1438
1435 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName( 1439 std::string ChromeContentBrowserClient::GetCanonicalEncodingNameByAliasName(
1436 const std::string& alias_name) { 1440 const std::string& alias_name) {
1437 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name); 1441 return CharacterEncoding::GetCanonicalEncodingNameByAliasName(alias_name);
1438 } 1442 }
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
1863 1867
1864 process_map.insert(std::pair<int, int>(i->first, i->second)); 1868 process_map.insert(std::pair<int, int>(i->first, i->second));
1865 1869
1866 if (WebViewRendererState::GetInstance()->IsGuest(i->first)) 1870 if (WebViewRendererState::GetInstance()->IsGuest(i->first))
1867 has_web_view_guest = true; 1871 has_web_view_guest = true;
1868 } 1872 }
1869 if (!has_web_view_guest) { 1873 if (!has_web_view_guest) {
1870 FileSystemAccessed(url, render_frames, callback, allow); 1874 FileSystemAccessed(url, render_frames, callback, allow);
1871 return; 1875 return;
1872 } 1876 }
1873 DCHECK(process_map.size() == 1); 1877 DCHECK_EQ(1U, process_map.size());
1874 it = process_map.begin(); 1878 it = process_map.begin();
1875 BrowserThread::PostTask( 1879 BrowserThread::PostTask(
1876 BrowserThread::UI, 1880 BrowserThread::UI,
1877 FROM_HERE, 1881 FROM_HERE,
1878 base::Bind(&ChromeContentBrowserClient:: 1882 base::Bind(&ChromeContentBrowserClient::
1879 RequestFileSystemPermissionOnUIThread, 1883 RequestFileSystemPermissionOnUIThread,
1880 it->first, 1884 it->first,
1881 it->second, 1885 it->second,
1882 url, 1886 url,
1883 allow, 1887 allow,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 i->first, i->second, url, name, !allow)); 1944 i->first, i->second, url, name, !allow));
1941 } 1945 }
1942 1946
1943 return allow; 1947 return allow;
1944 } 1948 }
1945 1949
1946 net::URLRequestContext* 1950 net::URLRequestContext*
1947 ChromeContentBrowserClient::OverrideRequestContextForURL( 1951 ChromeContentBrowserClient::OverrideRequestContextForURL(
1948 const GURL& url, content::ResourceContext* context) { 1952 const GURL& url, content::ResourceContext* context) {
1949 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 1953 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
1954 #if defined(ENABLE_EXTENSIONS)
1950 if (url.SchemeIs(extensions::kExtensionScheme)) { 1955 if (url.SchemeIs(extensions::kExtensionScheme)) {
1951 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 1956 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
1952 return io_data->extensions_request_context(); 1957 return io_data->extensions_request_context();
1953 } 1958 }
1959 #endif
1954 1960
1955 return NULL; 1961 return NULL;
1956 } 1962 }
1957 1963
1958 QuotaPermissionContext* 1964 QuotaPermissionContext*
1959 ChromeContentBrowserClient::CreateQuotaPermissionContext() { 1965 ChromeContentBrowserClient::CreateQuotaPermissionContext() {
1960 return new ChromeQuotaPermissionContext(); 1966 return new ChromeQuotaPermissionContext();
1961 } 1967 }
1962 1968
1963 void ChromeContentBrowserClient::AllowCertificateError( 1969 void ChromeContentBrowserClient::AllowCertificateError(
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2249 bool user_gesture, 2255 bool user_gesture,
2250 bool opener_suppressed, 2256 bool opener_suppressed,
2251 content::ResourceContext* context, 2257 content::ResourceContext* context,
2252 int render_process_id, 2258 int render_process_id,
2253 int opener_id, 2259 int opener_id,
2254 bool* no_javascript_access) { 2260 bool* no_javascript_access) {
2255 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2261 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2256 2262
2257 *no_javascript_access = false; 2263 *no_javascript_access = false;
2258 2264
2259 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2260 InfoMap* map = io_data->GetExtensionInfoMap();
2261
2262 // If the opener is trying to create a background window but doesn't have 2265 // If the opener is trying to create a background window but doesn't have
2263 // the appropriate permission, fail the attempt. 2266 // the appropriate permission, fail the attempt.
2264 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) { 2267 if (container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) {
2268 #if defined(ENABLE_EXTENSIONS)
2269 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2270 InfoMap* map = io_data->GetExtensionInfoMap();
2265 if (!map->SecurityOriginHasAPIPermission( 2271 if (!map->SecurityOriginHasAPIPermission(
2266 source_origin, 2272 source_origin,
2267 render_process_id, 2273 render_process_id,
2268 APIPermission::kBackground)) { 2274 APIPermission::kBackground)) {
2269 return false; 2275 return false;
2270 } 2276 }
2271 2277
2272 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may 2278 // Note: this use of GetExtensionOrAppByURL is safe but imperfect. It may
2273 // return a recently installed Extension even if this CanCreateWindow call 2279 // return a recently installed Extension even if this CanCreateWindow call
2274 // was made by an old copy of the page in a normal web process. That's ok, 2280 // was made by an old copy of the page in a normal web process. That's ok,
2275 // because the permission check above would have caused an early return 2281 // because the permission check above would have caused an early return
2276 // already. We must use the full URL to find hosted apps, though, and not 2282 // already. We must use the full URL to find hosted apps, though, and not
2277 // just the origin. 2283 // just the origin.
2278 const Extension* extension = 2284 const Extension* extension =
2279 map->extensions().GetExtensionOrAppByURL(opener_url); 2285 map->extensions().GetExtensionOrAppByURL(opener_url);
2280 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension)) 2286 if (extension && !extensions::BackgroundInfo::AllowJSAccess(extension))
2281 *no_javascript_access = true; 2287 *no_javascript_access = true;
2288 #endif
2282 2289
2283 return true; 2290 return true;
2284 } 2291 }
2285 2292
2286 #if defined(ENABLE_EXTENSIONS) 2293 #if defined(ENABLE_EXTENSIONS)
2287 if (WebViewRendererState::GetInstance()->IsGuest(render_process_id)) 2294 if (WebViewRendererState::GetInstance()->IsGuest(render_process_id))
2288 return true; 2295 return true;
2289 #endif 2296 #endif
2290 2297
2291 HostContentSettingsMap* content_settings = 2298 HostContentSettingsMap* content_settings =
2292 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap(); 2299 ProfileIOData::FromResourceContext(context)->GetHostContentSettingsMap();
2293 BlockedWindowParams blocked_params(target_url, 2300 BlockedWindowParams blocked_params(target_url,
2294 referrer, 2301 referrer,
2295 disposition, 2302 disposition,
2296 features, 2303 features,
2297 user_gesture, 2304 user_gesture,
2298 opener_suppressed, 2305 opener_suppressed,
2299 render_process_id, 2306 render_process_id,
2300 opener_id); 2307 opener_id);
2301 2308
2302 if (!user_gesture && !CommandLine::ForCurrentProcess()->HasSwitch( 2309 if (!user_gesture && !CommandLine::ForCurrentProcess()->HasSwitch(
2303 switches::kDisablePopupBlocking)) { 2310 switches::kDisablePopupBlocking)) {
2304 if (content_settings->GetContentSetting(opener_top_level_frame_url, 2311 if (content_settings->GetContentSetting(opener_top_level_frame_url,
2305 opener_top_level_frame_url, 2312 opener_top_level_frame_url,
2306 CONTENT_SETTINGS_TYPE_POPUPS, 2313 CONTENT_SETTINGS_TYPE_POPUPS,
2307 std::string()) != 2314 std::string()) !=
2308 CONTENT_SETTING_ALLOW) { 2315 CONTENT_SETTING_ALLOW) {
2309 BrowserThread::PostTask(BrowserThread::UI, 2316 BrowserThread::PostTask(BrowserThread::UI,
2310 FROM_HERE, 2317 FROM_HERE,
(...skipping 12 matching lines...) Expand all
2323 return false; 2330 return false;
2324 } 2331 }
2325 #endif 2332 #endif
2326 2333
2327 return true; 2334 return true;
2328 } 2335 }
2329 2336
2330 std::string ChromeContentBrowserClient::GetWorkerProcessTitle( 2337 std::string ChromeContentBrowserClient::GetWorkerProcessTitle(
2331 const GURL& url, content::ResourceContext* context) { 2338 const GURL& url, content::ResourceContext* context) {
2332 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2339 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2340 #if defined(ENABLE_EXTENSIONS)
2333 // Check if it's an extension-created worker, in which case we want to use 2341 // Check if it's an extension-created worker, in which case we want to use
2334 // the name of the extension. 2342 // the name of the extension.
2335 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); 2343 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
2336 const Extension* extension = 2344 const Extension* extension =
2337 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host()); 2345 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
2338 return extension ? extension->name() : std::string(); 2346 return extension ? extension->name() : std::string();
2347 #else
2348 return std::string();
2349 #endif
2339 } 2350 }
2340 2351
2341 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() { 2352 void ChromeContentBrowserClient::ResourceDispatcherHostCreated() {
2342 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 2353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
2343 prerender_tracker_ = g_browser_process->prerender_tracker(); 2354 prerender_tracker_ = g_browser_process->prerender_tracker();
2344 return g_browser_process->ResourceDispatcherHostCreated(); 2355 return g_browser_process->ResourceDispatcherHostCreated();
2345 } 2356 }
2346 2357
2347 // TODO(tommi): Rename from Get to Create. 2358 // TODO(tommi): Rename from Get to Create.
2348 content::SpeechRecognitionManagerDelegate* 2359 content::SpeechRecognitionManagerDelegate*
(...skipping 547 matching lines...) Expand 10 before | Expand all | Expand 10 after
2896 switches::kDisableWebRtcEncryption, 2907 switches::kDisableWebRtcEncryption,
2897 }; 2908 };
2898 to_command_line->CopySwitchesFrom(from_command_line, 2909 to_command_line->CopySwitchesFrom(from_command_line,
2899 kWebRtcDevSwitchNames, 2910 kWebRtcDevSwitchNames,
2900 arraysize(kWebRtcDevSwitchNames)); 2911 arraysize(kWebRtcDevSwitchNames));
2901 } 2912 }
2902 } 2913 }
2903 #endif // defined(ENABLE_WEBRTC) 2914 #endif // defined(ENABLE_WEBRTC)
2904 2915
2905 } // namespace chrome 2916 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/media/protected_media_identifier_permission_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698