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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 #include "content/public/common/content_descriptors.h" | 161 #include "content/public/common/content_descriptors.h" |
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/sandbox_type.h" | 164 #include "content/public/common/sandbox_type.h" |
163 #include "content/public/common/url_utils.h" | 165 #include "content/public/common/url_utils.h" |
164 #include "content/public/common/web_preferences.h" | 166 #include "content/public/common/web_preferences.h" |
165 #include "device/usb/public/interfaces/chooser_service.mojom.h" | 167 #include "device/usb/public/interfaces/chooser_service.mojom.h" |
166 #include "device/usb/public/interfaces/device_manager.mojom.h" | 168 #include "device/usb/public/interfaces/device_manager.mojom.h" |
167 #include "gin/v8_initializer.h" | 169 #include "gin/v8_initializer.h" |
168 #include "net/base/mime_util.h" | 170 #include "net/base/mime_util.h" |
| 171 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
169 #include "net/cookies/canonical_cookie.h" | 172 #include "net/cookies/canonical_cookie.h" |
170 #include "net/cookies/cookie_options.h" | 173 #include "net/cookies/cookie_options.h" |
171 #include "net/ssl/ssl_cert_request_info.h" | 174 #include "net/ssl/ssl_cert_request_info.h" |
172 #include "ppapi/host/ppapi_host.h" | 175 #include "ppapi/host/ppapi_host.h" |
173 #include "services/shell/public/cpp/service.h" | 176 #include "services/shell/public/cpp/service.h" |
174 #include "storage/browser/fileapi/external_mount_points.h" | 177 #include "storage/browser/fileapi/external_mount_points.h" |
175 #include "ui/base/l10n/l10n_util.h" | 178 #include "ui/base/l10n/l10n_util.h" |
176 #include "ui/base/resource/resource_bundle.h" | 179 #include "ui/base/resource/resource_bundle.h" |
177 #include "ui/resources/grit/ui_resources.h" | 180 #include "ui/resources/grit/ui_resources.h" |
178 #include "url/gurl.h" | 181 #include "url/gurl.h" |
(...skipping 2298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2477 void ChromeContentBrowserClient::ClearCookies(RenderFrameHost* rfh) { | 2480 void ChromeContentBrowserClient::ClearCookies(RenderFrameHost* rfh) { |
2478 Profile* profile = Profile::FromBrowserContext( | 2481 Profile* profile = Profile::FromBrowserContext( |
2479 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); | 2482 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
2480 BrowsingDataRemover* remover = | 2483 BrowsingDataRemover* remover = |
2481 BrowsingDataRemoverFactory::GetForBrowserContext(profile); | 2484 BrowsingDataRemoverFactory::GetForBrowserContext(profile); |
2482 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; | 2485 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
2483 remover->Remove(BrowsingDataRemover::Unbounded(), remove_mask, | 2486 remover->Remove(BrowsingDataRemover::Unbounded(), remove_mask, |
2484 BrowsingDataHelper::UNPROTECTED_WEB); | 2487 BrowsingDataHelper::UNPROTECTED_WEB); |
2485 } | 2488 } |
2486 | 2489 |
| 2490 void ChromeContentBrowserClient::ClearSiteData( |
| 2491 content::BrowserContext* browser_context, const url::Origin& origin, |
| 2492 bool remove_cookies, bool remove_storage, bool remove_cache) { |
| 2493 BrowsingDataRemover* remover = |
| 2494 BrowsingDataRemoverFactory::GetForBrowserContext(browser_context); |
| 2495 |
| 2496 // Cookies and channel IDs are scoped to |
| 2497 // a) eTLD+1 of |origin|'s host if |origin|'s host is a registrable domain |
| 2498 // or a subdomain thereof |
| 2499 // b) |origin|'s host exactly if it is an IP address or an internal hostname |
| 2500 // (e.g. "localhost" or "fileserver"). |
| 2501 int remove_mask = 0; |
| 2502 if (remove_cookies) |
| 2503 remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; |
| 2504 if (remove_storage) |
| 2505 remove_mask |= BrowsingDataRemover::REMOVE_CHANNEL_IDS; |
| 2506 |
| 2507 std::string domain = GetDomainAndRegistry( |
| 2508 origin.host(), |
| 2509 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 2510 if (domain.empty()) |
| 2511 domain = origin.host(); // IP address or internal hostname. |
| 2512 |
| 2513 if (remove_mask) { |
| 2514 RegistrableDomainFilterBuilder domain_filter_builder( |
| 2515 BrowsingDataFilterBuilder::WHITELIST); |
| 2516 domain_filter_builder.AddRegisterableDomain(domain); |
| 2517 |
| 2518 remover->RemoveWithFilter( |
| 2519 BrowsingDataRemover::Period( |
| 2520 browsing_data::TimePeriod::EVERYTHING), |
| 2521 remove_mask, |
| 2522 BrowsingDataHelper::ALL, |
| 2523 domain_filter_builder); |
| 2524 } |
| 2525 |
| 2526 // Delete origin-scoped data. |
| 2527 remove_mask = 0; |
| 2528 if (remove_storage) { |
| 2529 remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA & |
| 2530 ~BrowsingDataRemover::REMOVE_COOKIES & |
| 2531 ~BrowsingDataRemover::REMOVE_CHANNEL_IDS; |
| 2532 } |
| 2533 if (remove_cache) |
| 2534 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; |
| 2535 |
| 2536 if (remove_mask) { |
| 2537 OriginFilterBuilder origin_filter_builder( |
| 2538 BrowsingDataFilterBuilder::WHITELIST); |
| 2539 origin_filter_builder.AddOrigin(origin); |
| 2540 |
| 2541 remover->RemoveWithFilter( |
| 2542 BrowsingDataRemover::Period( |
| 2543 browsing_data::TimePeriod::EVERYTHING), |
| 2544 remove_mask, |
| 2545 BrowsingDataHelper::ALL, |
| 2546 origin_filter_builder); |
| 2547 } |
| 2548 } |
| 2549 |
2487 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { | 2550 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
2488 return DownloadPrefs::GetDefaultDownloadDirectory(); | 2551 return DownloadPrefs::GetDefaultDownloadDirectory(); |
2489 } | 2552 } |
2490 | 2553 |
2491 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { | 2554 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
2492 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); | 2555 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
2493 } | 2556 } |
2494 | 2557 |
2495 base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { | 2558 base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { |
2496 base::FilePath user_data_dir; | 2559 base::FilePath user_data_dir; |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3043 if (channel <= kMaxDisableEncryptionChannel) { | 3106 if (channel <= kMaxDisableEncryptionChannel) { |
3044 static const char* const kWebRtcDevSwitchNames[] = { | 3107 static const char* const kWebRtcDevSwitchNames[] = { |
3045 switches::kDisableWebRtcEncryption, | 3108 switches::kDisableWebRtcEncryption, |
3046 }; | 3109 }; |
3047 to_command_line->CopySwitchesFrom(from_command_line, | 3110 to_command_line->CopySwitchesFrom(from_command_line, |
3048 kWebRtcDevSwitchNames, | 3111 kWebRtcDevSwitchNames, |
3049 arraysize(kWebRtcDevSwitchNames)); | 3112 arraysize(kWebRtcDevSwitchNames)); |
3050 } | 3113 } |
3051 } | 3114 } |
3052 #endif // defined(ENABLE_WEBRTC) | 3115 #endif // defined(ENABLE_WEBRTC) |
OLD | NEW |