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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 #include "content/public/common/content_features.h" | 159 #include "content/public/common/content_features.h" |
158 #include "content/public/common/content_switches.h" | 160 #include "content/public/common/content_switches.h" |
159 #include "content/public/common/sandbox_type.h" | 161 #include "content/public/common/sandbox_type.h" |
160 #include "content/public/common/service_registry.h" | 162 #include "content/public/common/service_registry.h" |
161 #include "content/public/common/url_utils.h" | 163 #include "content/public/common/url_utils.h" |
162 #include "content/public/common/web_preferences.h" | 164 #include "content/public/common/web_preferences.h" |
163 #include "device/usb/public/interfaces/chooser_service.mojom.h" | 165 #include "device/usb/public/interfaces/chooser_service.mojom.h" |
164 #include "device/usb/public/interfaces/device_manager.mojom.h" | 166 #include "device/usb/public/interfaces/device_manager.mojom.h" |
165 #include "gin/v8_initializer.h" | 167 #include "gin/v8_initializer.h" |
166 #include "net/base/mime_util.h" | 168 #include "net/base/mime_util.h" |
| 169 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
167 #include "net/cookies/canonical_cookie.h" | 170 #include "net/cookies/canonical_cookie.h" |
168 #include "net/cookies/cookie_options.h" | 171 #include "net/cookies/cookie_options.h" |
169 #include "net/ssl/ssl_cert_request_info.h" | 172 #include "net/ssl/ssl_cert_request_info.h" |
170 #include "ppapi/host/ppapi_host.h" | 173 #include "ppapi/host/ppapi_host.h" |
171 #include "services/shell/public/cpp/shell_client.h" | 174 #include "services/shell/public/cpp/shell_client.h" |
172 #include "storage/browser/fileapi/external_mount_points.h" | 175 #include "storage/browser/fileapi/external_mount_points.h" |
173 #include "ui/base/l10n/l10n_util.h" | 176 #include "ui/base/l10n/l10n_util.h" |
174 #include "ui/base/resource/resource_bundle.h" | 177 #include "ui/base/resource/resource_bundle.h" |
175 #include "ui/resources/grit/ui_resources.h" | 178 #include "ui/resources/grit/ui_resources.h" |
176 #include "url/gurl.h" | 179 #include "url/gurl.h" |
(...skipping 2254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2431 void ChromeContentBrowserClient::ClearCookies(RenderFrameHost* rfh) { | 2434 void ChromeContentBrowserClient::ClearCookies(RenderFrameHost* rfh) { |
2432 Profile* profile = Profile::FromBrowserContext( | 2435 Profile* profile = Profile::FromBrowserContext( |
2433 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); | 2436 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
2434 BrowsingDataRemover* remover = | 2437 BrowsingDataRemover* remover = |
2435 BrowsingDataRemoverFactory::GetForBrowserContext(profile); | 2438 BrowsingDataRemoverFactory::GetForBrowserContext(profile); |
2436 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; | 2439 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
2437 remover->Remove(BrowsingDataRemover::Unbounded(), remove_mask, | 2440 remover->Remove(BrowsingDataRemover::Unbounded(), remove_mask, |
2438 BrowsingDataHelper::UNPROTECTED_WEB); | 2441 BrowsingDataHelper::UNPROTECTED_WEB); |
2439 } | 2442 } |
2440 | 2443 |
| 2444 void ChromeContentBrowserClient::ClearSiteData( |
| 2445 content::BrowserContext* browser_context, const url::Origin& origin, |
| 2446 bool remove_cookies, bool remove_storage, bool remove_cache) { |
| 2447 BrowsingDataRemover* remover = |
| 2448 BrowsingDataRemoverFactory::GetForBrowserContext( |
| 2449 Profile::FromBrowserContext(browser_context)); |
| 2450 |
| 2451 int origin_type_mask = |
| 2452 BrowsingDataHelper::UNPROTECTED_WEB | |
| 2453 BrowsingDataHelper::PROTECTED_WEB | |
| 2454 BrowsingDataHelper::EXTENSION; |
| 2455 |
| 2456 // Cookies and channel IDs are scoped to eTLD+1 and should be deleted |
| 2457 // in this scope. |
| 2458 if (remove_cookies || remove_storage) { |
| 2459 std::string domain = GetDomainAndRegistry( |
| 2460 origin.host(), |
| 2461 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); |
| 2462 |
| 2463 // TODO(msramek): What about origins such as http://localhost:80? |
| 2464 if (domain.empty()) |
| 2465 return; |
| 2466 |
| 2467 int remove_mask = 0; |
| 2468 if (remove_cookies) |
| 2469 remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; |
| 2470 if (remove_storage) |
| 2471 remove_mask |= BrowsingDataRemover::REMOVE_CHANNEL_IDS; |
| 2472 |
| 2473 RegistrableDomainFilterBuilder domain_filter_builder( |
| 2474 BrowsingDataFilterBuilder::WHITELIST); |
| 2475 domain_filter_builder.AddRegisterableDomain(domain); |
| 2476 |
| 2477 remover->RemoveWithFilter( |
| 2478 BrowsingDataRemover::Period( |
| 2479 BrowsingDataRemover::TimePeriod::EVERYTHING), |
| 2480 remove_mask, |
| 2481 origin_type_mask, |
| 2482 domain_filter_builder); |
| 2483 } |
| 2484 |
| 2485 // Delete origin-scoped data. |
| 2486 if (remove_storage || remove_cache) { |
| 2487 OriginFilterBuilder origin_filter_builder( |
| 2488 BrowsingDataFilterBuilder::WHITELIST); |
| 2489 origin_filter_builder.AddOrigin(origin); |
| 2490 |
| 2491 int remove_mask = 0; |
| 2492 if (remove_storage) { |
| 2493 remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA & |
| 2494 ~BrowsingDataRemover::REMOVE_COOKIES & |
| 2495 ~BrowsingDataRemover::REMOVE_CHANNEL_IDS; |
| 2496 } |
| 2497 if (remove_cache) |
| 2498 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; |
| 2499 |
| 2500 remover->RemoveWithFilter( |
| 2501 BrowsingDataRemover::Period( |
| 2502 BrowsingDataRemover::TimePeriod::EVERYTHING), |
| 2503 remove_mask, |
| 2504 origin_type_mask, |
| 2505 origin_filter_builder); |
| 2506 } |
| 2507 } |
| 2508 |
2441 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { | 2509 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
2442 return DownloadPrefs::GetDefaultDownloadDirectory(); | 2510 return DownloadPrefs::GetDefaultDownloadDirectory(); |
2443 } | 2511 } |
2444 | 2512 |
2445 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { | 2513 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
2446 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); | 2514 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
2447 } | 2515 } |
2448 | 2516 |
2449 base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { | 2517 base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { |
2450 base::FilePath user_data_dir; | 2518 base::FilePath user_data_dir; |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2958 if (channel <= kMaxDisableEncryptionChannel) { | 3026 if (channel <= kMaxDisableEncryptionChannel) { |
2959 static const char* const kWebRtcDevSwitchNames[] = { | 3027 static const char* const kWebRtcDevSwitchNames[] = { |
2960 switches::kDisableWebRtcEncryption, | 3028 switches::kDisableWebRtcEncryption, |
2961 }; | 3029 }; |
2962 to_command_line->CopySwitchesFrom(from_command_line, | 3030 to_command_line->CopySwitchesFrom(from_command_line, |
2963 kWebRtcDevSwitchNames, | 3031 kWebRtcDevSwitchNames, |
2964 arraysize(kWebRtcDevSwitchNames)); | 3032 arraysize(kWebRtcDevSwitchNames)); |
2965 } | 3033 } |
2966 } | 3034 } |
2967 #endif // defined(ENABLE_WEBRTC) | 3035 #endif // defined(ENABLE_WEBRTC) |
OLD | NEW |