| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 #include "chrome/browser/ui/chrome_select_file_policy.h" | 83 #include "chrome/browser/ui/chrome_select_file_policy.h" |
| 84 #include "chrome/browser/ui/sync/sync_promo_ui.h" | 84 #include "chrome/browser/ui/sync/sync_promo_ui.h" |
| 85 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" | 85 #include "chrome/browser/ui/tab_contents/chrome_web_contents_view_delegate.h" |
| 86 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" | 86 #include "chrome/browser/ui/webui/chrome_web_ui_controller_factory.h" |
| 87 #include "chrome/common/chrome_constants.h" | 87 #include "chrome/common/chrome_constants.h" |
| 88 #include "chrome/common/chrome_paths.h" | 88 #include "chrome/common/chrome_paths.h" |
| 89 #include "chrome/common/chrome_switches.h" | 89 #include "chrome/common/chrome_switches.h" |
| 90 #include "chrome/common/chrome_version_info.h" | 90 #include "chrome/common/chrome_version_info.h" |
| 91 #include "chrome/common/env_vars.h" | 91 #include "chrome/common/env_vars.h" |
| 92 #include "chrome/common/extensions/extension_process_policy.h" | 92 #include "chrome/common/extensions/extension_process_policy.h" |
| 93 #include "chrome/common/extensions/extension_set.h" | |
| 94 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" | 93 #include "chrome/common/extensions/manifest_handlers/app_isolation_info.h" |
| 95 #include "chrome/common/extensions/permissions/socket_permission.h" | 94 #include "chrome/common/extensions/permissions/socket_permission.h" |
| 96 #include "chrome/common/extensions/web_accessible_resources_handler.h" | 95 #include "chrome/common/extensions/web_accessible_resources_handler.h" |
| 97 #include "chrome/common/logging_chrome.h" | 96 #include "chrome/common/logging_chrome.h" |
| 98 #include "chrome/common/pepper_permission_util.h" | 97 #include "chrome/common/pepper_permission_util.h" |
| 99 #include "chrome/common/pref_names.h" | 98 #include "chrome/common/pref_names.h" |
| 100 #include "chrome/common/render_messages.h" | 99 #include "chrome/common/render_messages.h" |
| 101 #include "chrome/common/url_constants.h" | 100 #include "chrome/common/url_constants.h" |
| 102 #include "chrome/installer/util/google_update_settings.h" | 101 #include "chrome/installer/util/google_update_settings.h" |
| 103 #include "chromeos/chromeos_constants.h" | 102 #include "chromeos/chromeos_constants.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 121 #include "content/public/browser/web_contents.h" | 120 #include "content/public/browser/web_contents.h" |
| 122 #include "content/public/browser/web_contents_view.h" | 121 #include "content/public/browser/web_contents_view.h" |
| 123 #include "content/public/common/child_process_host.h" | 122 #include "content/public/common/child_process_host.h" |
| 124 #include "content/public/common/content_descriptors.h" | 123 #include "content/public/common/content_descriptors.h" |
| 125 #include "content/public/common/url_utils.h" | 124 #include "content/public/common/url_utils.h" |
| 126 #include "extensions/browser/info_map.h" | 125 #include "extensions/browser/info_map.h" |
| 127 #include "extensions/browser/process_manager.h" | 126 #include "extensions/browser/process_manager.h" |
| 128 #include "extensions/browser/view_type_utils.h" | 127 #include "extensions/browser/view_type_utils.h" |
| 129 #include "extensions/common/constants.h" | 128 #include "extensions/common/constants.h" |
| 130 #include "extensions/common/extension.h" | 129 #include "extensions/common/extension.h" |
| 130 #include "extensions/common/extension_set.h" |
| 131 #include "extensions/common/manifest_handlers/background_info.h" | 131 #include "extensions/common/manifest_handlers/background_info.h" |
| 132 #include "extensions/common/manifest_handlers/shared_module_info.h" | 132 #include "extensions/common/manifest_handlers/shared_module_info.h" |
| 133 #include "extensions/common/permissions/permissions_data.h" | 133 #include "extensions/common/permissions/permissions_data.h" |
| 134 #include "extensions/common/switches.h" | 134 #include "extensions/common/switches.h" |
| 135 #include "grit/generated_resources.h" | 135 #include "grit/generated_resources.h" |
| 136 #include "grit/ui_resources.h" | 136 #include "grit/ui_resources.h" |
| 137 #include "net/base/mime_util.h" | 137 #include "net/base/mime_util.h" |
| 138 #include "net/cookies/canonical_cookie.h" | 138 #include "net/cookies/canonical_cookie.h" |
| 139 #include "net/cookies/cookie_options.h" | 139 #include "net/cookies/cookie_options.h" |
| 140 #include "net/ssl/ssl_cert_request_info.h" | 140 #include "net/ssl/ssl_cert_request_info.h" |
| (...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 // Skip showing the infobar if the request comes from an extension, and that | 1890 // Skip showing the infobar if the request comes from an extension, and that |
| 1891 // extension has the 'notify' permission. (If the extension does not have the | 1891 // extension has the 'notify' permission. (If the extension does not have the |
| 1892 // permission, the user will still be prompted.) | 1892 // permission, the user will still be prompted.) |
| 1893 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 1893 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 1894 InfoMap* extension_info_map = | 1894 InfoMap* extension_info_map = |
| 1895 extensions::ExtensionSystem::Get(profile)->info_map(); | 1895 extensions::ExtensionSystem::Get(profile)->info_map(); |
| 1896 DesktopNotificationService* notification_service = | 1896 DesktopNotificationService* notification_service = |
| 1897 DesktopNotificationServiceFactory::GetForProfile(profile); | 1897 DesktopNotificationServiceFactory::GetForProfile(profile); |
| 1898 const Extension* extension = NULL; | 1898 const Extension* extension = NULL; |
| 1899 if (extension_info_map) { | 1899 if (extension_info_map) { |
| 1900 ExtensionSet extensions; | 1900 extensions::ExtensionSet extensions; |
| 1901 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( | 1901 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( |
| 1902 source_origin, render_process_id, | 1902 source_origin, render_process_id, |
| 1903 extensions::APIPermission::kNotification, &extensions); | 1903 extensions::APIPermission::kNotification, &extensions); |
| 1904 for (ExtensionSet::const_iterator iter = extensions.begin(); | 1904 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); |
| 1905 iter != extensions.end(); ++iter) { | 1905 iter != extensions.end(); ++iter) { |
| 1906 if (notification_service->IsNotifierEnabled(NotifierId( | 1906 if (notification_service->IsNotifierEnabled(NotifierId( |
| 1907 NotifierId::APPLICATION, (*iter)->id()))) { | 1907 NotifierId::APPLICATION, (*iter)->id()))) { |
| 1908 extension = iter->get(); | 1908 extension = iter->get(); |
| 1909 break; | 1909 break; |
| 1910 } | 1910 } |
| 1911 } | 1911 } |
| 1912 } | 1912 } |
| 1913 RenderViewHost* rvh = | 1913 RenderViewHost* rvh = |
| 1914 RenderViewHost::FromID(render_process_id, render_view_id); | 1914 RenderViewHost::FromID(render_process_id, render_view_id); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1933 int render_process_id) { | 1933 int render_process_id) { |
| 1934 #if defined(ENABLE_NOTIFICATIONS) | 1934 #if defined(ENABLE_NOTIFICATIONS) |
| 1935 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 1935 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 1936 | 1936 |
| 1937 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 1937 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| 1938 InfoMap* extension_info_map = io_data->GetExtensionInfoMap(); | 1938 InfoMap* extension_info_map = io_data->GetExtensionInfoMap(); |
| 1939 | 1939 |
| 1940 // We want to see if there is an extension that hasn't been manually disabled | 1940 // We want to see if there is an extension that hasn't been manually disabled |
| 1941 // that has the notifications permission and applies to this security origin. | 1941 // that has the notifications permission and applies to this security origin. |
| 1942 // First, get the list of extensions with permission for the origin. | 1942 // First, get the list of extensions with permission for the origin. |
| 1943 ExtensionSet extensions; | 1943 extensions::ExtensionSet extensions; |
| 1944 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( | 1944 extension_info_map->GetExtensionsWithAPIPermissionForSecurityOrigin( |
| 1945 source_origin, render_process_id, | 1945 source_origin, render_process_id, |
| 1946 extensions::APIPermission::kNotification, &extensions); | 1946 extensions::APIPermission::kNotification, &extensions); |
| 1947 for (ExtensionSet::const_iterator iter = extensions.begin(); | 1947 for (extensions::ExtensionSet::const_iterator iter = extensions.begin(); |
| 1948 iter != extensions.end(); ++iter) { | 1948 iter != extensions.end(); ++iter) { |
| 1949 // Then, check to see if it's been disabled by the user. | 1949 // Then, check to see if it's been disabled by the user. |
| 1950 if (!extension_info_map->AreNotificationsDisabled((*iter)->id())) | 1950 if (!extension_info_map->AreNotificationsDisabled((*iter)->id())) |
| 1951 return blink::WebNotificationPresenter::PermissionAllowed; | 1951 return blink::WebNotificationPresenter::PermissionAllowed; |
| 1952 } | 1952 } |
| 1953 | 1953 |
| 1954 // No enabled extensions exist, so check the normal host content settings. | 1954 // No enabled extensions exist, so check the normal host content settings. |
| 1955 HostContentSettingsMap* host_content_settings_map = | 1955 HostContentSettingsMap* host_content_settings_map = |
| 1956 io_data->GetHostContentSettingsMap(); | 1956 io_data->GetHostContentSettingsMap(); |
| 1957 ContentSetting setting = host_content_settings_map->GetContentSetting( | 1957 ContentSetting setting = host_content_settings_map->GetContentSetting( |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2422 extension->HasAPIPermission(APIPermission::kAdView); | 2422 extension->HasAPIPermission(APIPermission::kAdView); |
| 2423 } | 2423 } |
| 2424 | 2424 |
| 2425 bool ChromeContentBrowserClient::AllowPepperSocketAPI( | 2425 bool ChromeContentBrowserClient::AllowPepperSocketAPI( |
| 2426 content::BrowserContext* browser_context, | 2426 content::BrowserContext* browser_context, |
| 2427 const GURL& url, | 2427 const GURL& url, |
| 2428 bool private_api, | 2428 bool private_api, |
| 2429 const content::SocketPermissionRequest* params) { | 2429 const content::SocketPermissionRequest* params) { |
| 2430 #if defined(ENABLE_PLUGINS) | 2430 #if defined(ENABLE_PLUGINS) |
| 2431 Profile* profile = Profile::FromBrowserContext(browser_context); | 2431 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 2432 const ExtensionSet* extension_set = NULL; | 2432 const extensions::ExtensionSet* extension_set = NULL; |
| 2433 if (profile) { | 2433 if (profile) { |
| 2434 extension_set = extensions::ExtensionSystem::Get(profile)-> | 2434 extension_set = extensions::ExtensionSystem::Get(profile)-> |
| 2435 extension_service()->extensions(); | 2435 extension_service()->extensions(); |
| 2436 } | 2436 } |
| 2437 | 2437 |
| 2438 if (private_api) { | 2438 if (private_api) { |
| 2439 // Access to private socket APIs is controlled by the whitelist. | 2439 // Access to private socket APIs is controlled by the whitelist. |
| 2440 if (IsExtensionOrSharedModuleWhitelisted(url, extension_set, | 2440 if (IsExtensionOrSharedModuleWhitelisted(url, extension_set, |
| 2441 allowed_socket_origins_)) { | 2441 allowed_socket_origins_)) { |
| 2442 return true; | 2442 return true; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2606 return; | 2606 return; |
| 2607 } | 2607 } |
| 2608 } | 2608 } |
| 2609 #endif | 2609 #endif |
| 2610 | 2610 |
| 2611 bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( | 2611 bool ChromeContentBrowserClient::IsPluginAllowedToCallRequestOSFileHandle( |
| 2612 content::BrowserContext* browser_context, | 2612 content::BrowserContext* browser_context, |
| 2613 const GURL& url) { | 2613 const GURL& url) { |
| 2614 #if defined(ENABLE_PLUGINS) | 2614 #if defined(ENABLE_PLUGINS) |
| 2615 Profile* profile = Profile::FromBrowserContext(browser_context); | 2615 Profile* profile = Profile::FromBrowserContext(browser_context); |
| 2616 const ExtensionSet* extension_set = NULL; | 2616 const extensions::ExtensionSet* extension_set = NULL; |
| 2617 if (profile) { | 2617 if (profile) { |
| 2618 extension_set = extensions::ExtensionSystem::Get(profile)-> | 2618 extension_set = extensions::ExtensionSystem::Get(profile)-> |
| 2619 extension_service()->extensions(); | 2619 extension_service()->extensions(); |
| 2620 } | 2620 } |
| 2621 // TODO(teravest): Populate allowed_file_handle_origins_ when FileIO is moved | 2621 // TODO(teravest): Populate allowed_file_handle_origins_ when FileIO is moved |
| 2622 // from the renderer to the browser. | 2622 // from the renderer to the browser. |
| 2623 return IsExtensionOrSharedModuleWhitelisted(url, extension_set, | 2623 return IsExtensionOrSharedModuleWhitelisted(url, extension_set, |
| 2624 allowed_file_handle_origins_) || | 2624 allowed_file_handle_origins_) || |
| 2625 IsHostAllowedByCommandLine(url, extension_set, | 2625 IsHostAllowedByCommandLine(url, extension_set, |
| 2626 switches::kAllowNaClFileHandleAPI); | 2626 switches::kAllowNaClFileHandleAPI); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2639 | 2639 |
| 2640 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 2640 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 2641 return channel <= chrome::VersionInfo::CHANNEL_DEV; | 2641 return channel <= chrome::VersionInfo::CHANNEL_DEV; |
| 2642 #else | 2642 #else |
| 2643 return false; | 2643 return false; |
| 2644 #endif | 2644 #endif |
| 2645 } | 2645 } |
| 2646 | 2646 |
| 2647 | 2647 |
| 2648 } // namespace chrome | 2648 } // namespace chrome |
| OLD | NEW |