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 17 matching lines...) Expand all Loading... |
28 #include "base/threading/thread_task_runner_handle.h" | 28 #include "base/threading/thread_task_runner_handle.h" |
29 #include "build/build_config.h" | 29 #include "build/build_config.h" |
30 #include "chrome/browser/after_startup_task_utils.h" | 30 #include "chrome/browser/after_startup_task_utils.h" |
31 #include "chrome/browser/apps/app_url_redirector.h" | 31 #include "chrome/browser/apps/app_url_redirector.h" |
32 #include "chrome/browser/browser_about_handler.h" | 32 #include "chrome/browser/browser_about_handler.h" |
33 #include "chrome/browser/browser_process.h" | 33 #include "chrome/browser/browser_process.h" |
34 #include "chrome/browser/browser_shutdown.h" | 34 #include "chrome/browser/browser_shutdown.h" |
35 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 35 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
36 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 36 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
37 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 37 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
| 38 #include "chrome/browser/browsing_data/origin_filter_builder.h" |
| 39 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h" |
38 #include "chrome/browser/character_encoding.h" | 40 #include "chrome/browser/character_encoding.h" |
39 #include "chrome/browser/chrome_content_browser_client_parts.h" | 41 #include "chrome/browser/chrome_content_browser_client_parts.h" |
40 #include "chrome/browser/chrome_net_benchmarking_message_filter.h" | 42 #include "chrome/browser/chrome_net_benchmarking_message_filter.h" |
41 #include "chrome/browser/chrome_quota_permission_context.h" | 43 #include "chrome/browser/chrome_quota_permission_context.h" |
42 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 44 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
43 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 45 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
44 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 46 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
45 #include "chrome/browser/defaults.h" | 47 #include "chrome/browser/defaults.h" |
46 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" | 48 #include "chrome/browser/devtools/chrome_devtools_manager_delegate.h" |
47 #include "chrome/browser/download/download_prefs.h" | 49 #include "chrome/browser/download/download_prefs.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 #include "content/public/common/content_features.h" | 162 #include "content/public/common/content_features.h" |
161 #include "content/public/common/content_switches.h" | 163 #include "content/public/common/content_switches.h" |
162 #include "content/public/common/mojo_shell_connection.h" | 164 #include "content/public/common/mojo_shell_connection.h" |
163 #include "content/public/common/sandbox_type.h" | 165 #include "content/public/common/sandbox_type.h" |
164 #include "content/public/common/url_utils.h" | 166 #include "content/public/common/url_utils.h" |
165 #include "content/public/common/web_preferences.h" | 167 #include "content/public/common/web_preferences.h" |
166 #include "device/usb/public/interfaces/chooser_service.mojom.h" | 168 #include "device/usb/public/interfaces/chooser_service.mojom.h" |
167 #include "device/usb/public/interfaces/device_manager.mojom.h" | 169 #include "device/usb/public/interfaces/device_manager.mojom.h" |
168 #include "gin/v8_initializer.h" | 170 #include "gin/v8_initializer.h" |
169 #include "net/base/mime_util.h" | 171 #include "net/base/mime_util.h" |
| 172 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
170 #include "net/cookies/canonical_cookie.h" | 173 #include "net/cookies/canonical_cookie.h" |
171 #include "net/cookies/cookie_options.h" | 174 #include "net/cookies/cookie_options.h" |
172 #include "net/ssl/ssl_cert_request_info.h" | 175 #include "net/ssl/ssl_cert_request_info.h" |
173 #include "ppapi/host/ppapi_host.h" | 176 #include "ppapi/host/ppapi_host.h" |
174 #include "services/shell/public/cpp/service.h" | 177 #include "services/shell/public/cpp/service.h" |
175 #include "storage/browser/fileapi/external_mount_points.h" | 178 #include "storage/browser/fileapi/external_mount_points.h" |
176 #include "ui/base/l10n/l10n_util.h" | 179 #include "ui/base/l10n/l10n_util.h" |
177 #include "ui/base/resource/resource_bundle.h" | 180 #include "ui/base/resource/resource_bundle.h" |
178 #include "ui/resources/grit/ui_resources.h" | 181 #include "ui/resources/grit/ui_resources.h" |
179 #include "url/gurl.h" | 182 #include "url/gurl.h" |
(...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2481 void ChromeContentBrowserClient::ClearCookies(RenderFrameHost* rfh) { | 2484 void ChromeContentBrowserClient::ClearCookies(RenderFrameHost* rfh) { |
2482 Profile* profile = Profile::FromBrowserContext( | 2485 Profile* profile = Profile::FromBrowserContext( |
2483 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); | 2486 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
2484 BrowsingDataRemover* remover = | 2487 BrowsingDataRemover* remover = |
2485 BrowsingDataRemoverFactory::GetForBrowserContext(profile); | 2488 BrowsingDataRemoverFactory::GetForBrowserContext(profile); |
2486 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; | 2489 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
2487 remover->Remove(BrowsingDataRemover::Unbounded(), remove_mask, | 2490 remover->Remove(BrowsingDataRemover::Unbounded(), remove_mask, |
2488 BrowsingDataHelper::UNPROTECTED_WEB); | 2491 BrowsingDataHelper::UNPROTECTED_WEB); |
2489 } | 2492 } |
2490 | 2493 |
| 2494 void ChromeContentBrowserClient::ClearSiteData( |
| 2495 content::BrowserContext* browser_context, const url::Origin& origin, |
| 2496 bool remove_cookies, bool remove_storage, bool remove_cache) { |
| 2497 BrowsingDataRemover* remover = |
| 2498 BrowsingDataRemoverFactory::GetForBrowserContext(browser_context); |
| 2499 |
| 2500 // Cookies and channel IDs are scoped to |
| 2501 // a) eTLD+1 of |origin|'s host if |origin|'s host is a registrable domain |
| 2502 // or a subdomain thereof |
| 2503 // b) |origin|'s host exactly if it is an IP address or an internal hostname |
| 2504 // (e.g. "localhost" or "fileserver"). |
| 2505 int remove_mask = 0; |
| 2506 if (remove_cookies) { |
| 2507 remove_mask |= BrowsingDataRemover::REMOVE_COOKIES | |
| 2508 BrowsingDataRemover::REMOVE_CHANNEL_IDS; |
| 2509 } |
| 2510 |
| 2511 std::string domain = GetDomainAndRegistry( |
| 2512 origin.host(), |
| 2513 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 2514 if (domain.empty()) |
| 2515 domain = origin.host(); // IP address or internal hostname. |
| 2516 |
| 2517 if (remove_mask) { |
| 2518 RegistrableDomainFilterBuilder domain_filter_builder( |
| 2519 BrowsingDataFilterBuilder::WHITELIST); |
| 2520 domain_filter_builder.AddRegisterableDomain(domain); |
| 2521 |
| 2522 remover->RemoveWithFilter( |
| 2523 BrowsingDataRemover::Period( |
| 2524 browsing_data::TimePeriod::EVERYTHING), |
| 2525 remove_mask, |
| 2526 BrowsingDataHelper::ALL, |
| 2527 domain_filter_builder); |
| 2528 } |
| 2529 |
| 2530 // Delete origin-scoped data. |
| 2531 remove_mask = 0; |
| 2532 if (remove_storage) { |
| 2533 remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA & |
| 2534 ~BrowsingDataRemover::REMOVE_COOKIES & |
| 2535 ~BrowsingDataRemover::REMOVE_CHANNEL_IDS; |
| 2536 } |
| 2537 if (remove_cache) |
| 2538 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; |
| 2539 |
| 2540 if (remove_mask) { |
| 2541 OriginFilterBuilder origin_filter_builder( |
| 2542 BrowsingDataFilterBuilder::WHITELIST); |
| 2543 origin_filter_builder.AddOrigin(origin); |
| 2544 |
| 2545 remover->RemoveWithFilter( |
| 2546 BrowsingDataRemover::Period( |
| 2547 browsing_data::TimePeriod::EVERYTHING), |
| 2548 remove_mask, |
| 2549 BrowsingDataHelper::ALL, |
| 2550 origin_filter_builder); |
| 2551 } |
| 2552 } |
| 2553 |
2491 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { | 2554 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
2492 return DownloadPrefs::GetDefaultDownloadDirectory(); | 2555 return DownloadPrefs::GetDefaultDownloadDirectory(); |
2493 } | 2556 } |
2494 | 2557 |
2495 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { | 2558 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
2496 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); | 2559 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
2497 } | 2560 } |
2498 | 2561 |
2499 base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { | 2562 base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { |
2500 base::FilePath user_data_dir; | 2563 base::FilePath user_data_dir; |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3047 if (channel <= kMaxDisableEncryptionChannel) { | 3110 if (channel <= kMaxDisableEncryptionChannel) { |
3048 static const char* const kWebRtcDevSwitchNames[] = { | 3111 static const char* const kWebRtcDevSwitchNames[] = { |
3049 switches::kDisableWebRtcEncryption, | 3112 switches::kDisableWebRtcEncryption, |
3050 }; | 3113 }; |
3051 to_command_line->CopySwitchesFrom(from_command_line, | 3114 to_command_line->CopySwitchesFrom(from_command_line, |
3052 kWebRtcDevSwitchNames, | 3115 kWebRtcDevSwitchNames, |
3053 arraysize(kWebRtcDevSwitchNames)); | 3116 arraysize(kWebRtcDevSwitchNames)); |
3054 } | 3117 } |
3055 } | 3118 } |
3056 #endif // defined(ENABLE_WEBRTC) | 3119 #endif // defined(ENABLE_WEBRTC) |
OLD | NEW |