Chromium Code Reviews| 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 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2485 void ChromeContentBrowserClient::ClearCookies(RenderFrameHost* rfh) { | 2488 void ChromeContentBrowserClient::ClearCookies(RenderFrameHost* rfh) { |
| 2486 Profile* profile = Profile::FromBrowserContext( | 2489 Profile* profile = Profile::FromBrowserContext( |
| 2487 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); | 2490 rfh->GetSiteInstance()->GetProcess()->GetBrowserContext()); |
| 2488 BrowsingDataRemover* remover = | 2491 BrowsingDataRemover* remover = |
| 2489 BrowsingDataRemoverFactory::GetForBrowserContext(profile); | 2492 BrowsingDataRemoverFactory::GetForBrowserContext(profile); |
| 2490 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; | 2493 int remove_mask = BrowsingDataRemover::REMOVE_SITE_DATA; |
| 2491 remover->Remove(BrowsingDataRemover::Unbounded(), remove_mask, | 2494 remover->Remove(BrowsingDataRemover::Unbounded(), remove_mask, |
| 2492 BrowsingDataHelper::UNPROTECTED_WEB); | 2495 BrowsingDataHelper::UNPROTECTED_WEB); |
| 2493 } | 2496 } |
| 2494 | 2497 |
| 2498 void ChromeContentBrowserClient::ClearSiteData( | |
| 2499 content::BrowserContext* browser_context, const url::Origin& origin, | |
| 2500 bool remove_cookies, bool remove_storage, bool remove_cache) { | |
| 2501 BrowsingDataRemover* remover = | |
| 2502 BrowsingDataRemoverFactory::GetForBrowserContext( | |
| 2503 Profile::FromBrowserContext(browser_context)); | |
| 2504 | |
| 2505 // Cookies and channel IDs are scoped to eTLD+1 and should be deleted | |
| 2506 // in this scope. | |
| 2507 if (remove_storage || remove_cache) { | |
|
Mike West
2016/06/02 07:00:08
This should be `remove_cookies`, right?
Actually,
msramek
2016/06/14 20:12:07
Sorry, I've been rewriting this a few times, appar
| |
| 2508 std::string domain = GetDomainAndRegistry( | |
| 2509 origin.host(), | |
| 2510 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); | |
| 2511 | |
| 2512 // TODO(msramek): What about origins such as http://localhost:80? | |
| 2513 if (domain.empty()) | |
| 2514 return; | |
| 2515 | |
| 2516 int remove_mask = 0; | |
| 2517 if (remove_cookies) | |
| 2518 remove_mask |= BrowsingDataRemover::REMOVE_COOKIES; | |
| 2519 if (remove_storage) | |
| 2520 remove_mask |= BrowsingDataRemover::REMOVE_CHANNEL_IDS; | |
|
Mike West
2016/06/02 07:00:08
1. Can you file a bug against the spec (or send a
msramek
2016/06/14 20:12:07
BrowsingDataRemover treats them as a part of site
Mike West
2016/06/20 07:57:37
Cookies are part of site data too. :)
| |
| 2521 | |
| 2522 RegistrableDomainFilterBuilder domain_filter_builder( | |
| 2523 BrowsingDataFilterBuilder::WHITELIST); | |
| 2524 domain_filter_builder.AddRegisterableDomain(domain); | |
| 2525 | |
| 2526 remover->RemoveWithFilter( | |
|
Mike West
2016/06/02 07:00:08
If folks want to clear both cookies and DOM storag
msramek
2016/06/14 20:12:07
Not necessarily. BDR is full of if()-s that are on
| |
| 2527 BrowsingDataRemover::Period( | |
| 2528 BrowsingDataRemover::TimePeriod::EVERYTHING), | |
| 2529 remove_mask, | |
| 2530 BrowsingDataHelper::UNPROTECTED_WEB, | |
|
Mike West
2016/06/02 07:00:08
Hrm. I forget what we actually used PROTECTED_WEB
msramek
2016/06/14 20:12:07
Heh, good point. In my mind, I am still mapping th
| |
| 2531 domain_filter_builder); | |
| 2532 } | |
| 2533 | |
| 2534 // Delete origin-scoped data. | |
| 2535 if (remove_storage || remove_cache) { | |
| 2536 OriginFilterBuilder origin_filter_builder( | |
| 2537 BrowsingDataFilterBuilder::WHITELIST); | |
| 2538 origin_filter_builder.AddOrigin(origin); | |
| 2539 | |
| 2540 int remove_mask = 0; | |
| 2541 if (remove_storage) { | |
| 2542 remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA & | |
| 2543 ~BrowsingDataRemover::REMOVE_COOKIES & | |
| 2544 ~BrowsingDataRemover::REMOVE_CHANNEL_IDS; | |
| 2545 } | |
| 2546 if (remove_cache) | |
| 2547 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; | |
| 2548 | |
| 2549 remover->RemoveWithFilter( | |
| 2550 BrowsingDataRemover::Period( | |
| 2551 BrowsingDataRemover::TimePeriod::EVERYTHING), | |
| 2552 remove_mask, | |
| 2553 BrowsingDataHelper::UNPROTECTED_WEB, | |
| 2554 origin_filter_builder); | |
| 2555 } | |
| 2556 } | |
| 2557 | |
| 2495 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { | 2558 base::FilePath ChromeContentBrowserClient::GetDefaultDownloadDirectory() { |
| 2496 return DownloadPrefs::GetDefaultDownloadDirectory(); | 2559 return DownloadPrefs::GetDefaultDownloadDirectory(); |
| 2497 } | 2560 } |
| 2498 | 2561 |
| 2499 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { | 2562 std::string ChromeContentBrowserClient::GetDefaultDownloadName() { |
| 2500 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); | 2563 return l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME); |
| 2501 } | 2564 } |
| 2502 | 2565 |
| 2503 base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { | 2566 base::FilePath ChromeContentBrowserClient::GetShaderDiskCacheDirectory() { |
| 2504 base::FilePath user_data_dir; | 2567 base::FilePath user_data_dir; |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3004 if (channel <= kMaxDisableEncryptionChannel) { | 3067 if (channel <= kMaxDisableEncryptionChannel) { |
| 3005 static const char* const kWebRtcDevSwitchNames[] = { | 3068 static const char* const kWebRtcDevSwitchNames[] = { |
| 3006 switches::kDisableWebRtcEncryption, | 3069 switches::kDisableWebRtcEncryption, |
| 3007 }; | 3070 }; |
| 3008 to_command_line->CopySwitchesFrom(from_command_line, | 3071 to_command_line->CopySwitchesFrom(from_command_line, |
| 3009 kWebRtcDevSwitchNames, | 3072 kWebRtcDevSwitchNames, |
| 3010 arraysize(kWebRtcDevSwitchNames)); | 3073 arraysize(kWebRtcDevSwitchNames)); |
| 3011 } | 3074 } |
| 3012 } | 3075 } |
| 3013 #endif // defined(ENABLE_WEBRTC) | 3076 #endif // defined(ENABLE_WEBRTC) |
| OLD | NEW |