Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(350)

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 2647683002: Consolidate Origin- and RegistrableDomain- FilterBuilder into one class (Closed)
Patch Set: Fix memory leak. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 16 matching lines...) Expand all
27 #include "base/strings/stringprintf.h" 27 #include "base/strings/stringprintf.h"
28 #include "base/strings/utf_string_conversions.h" 28 #include "base/strings/utf_string_conversions.h"
29 #include "base/threading/sequenced_worker_pool.h" 29 #include "base/threading/sequenced_worker_pool.h"
30 #include "base/threading/thread_task_runner_handle.h" 30 #include "base/threading/thread_task_runner_handle.h"
31 #include "build/build_config.h" 31 #include "build/build_config.h"
32 #include "chrome/browser/after_startup_task_utils.h" 32 #include "chrome/browser/after_startup_task_utils.h"
33 #include "chrome/browser/apps/app_url_redirector.h" 33 #include "chrome/browser/apps/app_url_redirector.h"
34 #include "chrome/browser/browser_about_handler.h" 34 #include "chrome/browser/browser_about_handler.h"
35 #include "chrome/browser/browser_process.h" 35 #include "chrome/browser/browser_process.h"
36 #include "chrome/browser/browser_shutdown.h" 36 #include "chrome/browser/browser_shutdown.h"
37 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h"
37 #include "chrome/browser/browsing_data/browsing_data_helper.h" 38 #include "chrome/browser/browsing_data/browsing_data_helper.h"
38 #include "chrome/browser/browsing_data/browsing_data_remover.h" 39 #include "chrome/browser/browsing_data/browsing_data_remover.h"
39 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" 40 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h"
40 #include "chrome/browser/browsing_data/origin_filter_builder.h"
41 #include "chrome/browser/browsing_data/registrable_domain_filter_builder.h"
42 #include "chrome/browser/budget_service/budget_service_impl.h" 41 #include "chrome/browser/budget_service/budget_service_impl.h"
43 #include "chrome/browser/chrome_content_browser_client_parts.h" 42 #include "chrome/browser/chrome_content_browser_client_parts.h"
44 #include "chrome/browser/chrome_quota_permission_context.h" 43 #include "chrome/browser/chrome_quota_permission_context.h"
45 #include "chrome/browser/content_settings/cookie_settings_factory.h" 44 #include "chrome/browser/content_settings/cookie_settings_factory.h"
46 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" 45 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
47 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 46 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
48 #include "chrome/browser/defaults.h" 47 #include "chrome/browser/defaults.h"
49 #include "chrome/browser/download/download_prefs.h" 48 #include "chrome/browser/download/download_prefs.h"
50 #include "chrome/browser/engagement/site_engagement_eviction_policy.h" 49 #include "chrome/browser/engagement/site_engagement_eviction_policy.h"
51 #include "chrome/browser/field_trial_recorder.h" 50 #include "chrome/browser/field_trial_recorder.h"
(...skipping 2557 matching lines...) Expand 10 before | Expand all | Expand 10 after
2609 // b) |origin|'s host exactly if it is an IP address or an internal hostname 2608 // b) |origin|'s host exactly if it is an IP address or an internal hostname
2610 // (e.g. "localhost" or "fileserver"). 2609 // (e.g. "localhost" or "fileserver").
2611 if (remove_cookies) { 2610 if (remove_cookies) {
2612 std::string domain = GetDomainAndRegistry( 2611 std::string domain = GetDomainAndRegistry(
2613 origin.host(), 2612 origin.host(),
2614 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES); 2613 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
2615 2614
2616 if (domain.empty()) 2615 if (domain.empty())
2617 domain = origin.host(); // IP address or internal hostname. 2616 domain = origin.host(); // IP address or internal hostname.
2618 2617
2619 std::unique_ptr<RegistrableDomainFilterBuilder> domain_filter_builder( 2618 std::unique_ptr<BrowsingDataFilterBuilder> domain_filter_builder(
2620 new RegistrableDomainFilterBuilder( 2619 BrowsingDataFilterBuilder::Create(
2621 BrowsingDataFilterBuilder::WHITELIST)); 2620 BrowsingDataFilterBuilder::WHITELIST));
2622 domain_filter_builder->AddRegisterableDomain(domain); 2621 domain_filter_builder->AddRegisterableDomain(domain);
2623 2622
2624 remover->RemoveWithFilterAndReply( 2623 remover->RemoveWithFilterAndReply(
2625 base::Time(), base::Time::Max(), 2624 base::Time(), base::Time::Max(),
2626 BrowsingDataRemover::REMOVE_COOKIES | 2625 BrowsingDataRemover::REMOVE_COOKIES |
2627 BrowsingDataRemover::REMOVE_CHANNEL_IDS | 2626 BrowsingDataRemover::REMOVE_CHANNEL_IDS |
2628 BrowsingDataRemover::REMOVE_PLUGIN_DATA, 2627 BrowsingDataRemover::REMOVE_PLUGIN_DATA,
2629 BrowsingDataHelper::ALL, std::move(domain_filter_builder), observer); 2628 BrowsingDataHelper::ALL, std::move(domain_filter_builder), observer);
2630 } else { 2629 } else {
2631 // The first removal task is a no-op. 2630 // The first removal task is a no-op.
2632 observer->OnBrowsingDataRemoverDone(); 2631 observer->OnBrowsingDataRemoverDone();
2633 } 2632 }
2634 2633
2635 // Delete origin-scoped data. 2634 // Delete origin-scoped data.
2636 int remove_mask = 0; 2635 int remove_mask = 0;
2637 if (remove_storage) { 2636 if (remove_storage) {
2638 remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA & 2637 remove_mask |= BrowsingDataRemover::REMOVE_SITE_DATA &
2639 ~BrowsingDataRemover::REMOVE_COOKIES & 2638 ~BrowsingDataRemover::REMOVE_COOKIES &
2640 ~BrowsingDataRemover::REMOVE_CHANNEL_IDS & 2639 ~BrowsingDataRemover::REMOVE_CHANNEL_IDS &
2641 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA; 2640 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA;
2642 } 2641 }
2643 if (remove_cache) 2642 if (remove_cache)
2644 remove_mask |= BrowsingDataRemover::REMOVE_CACHE; 2643 remove_mask |= BrowsingDataRemover::REMOVE_CACHE;
2645 2644
2646 if (remove_mask) { 2645 if (remove_mask) {
2647 std::unique_ptr<OriginFilterBuilder> origin_filter_builder( 2646 std::unique_ptr<BrowsingDataFilterBuilder> origin_filter_builder(
2648 new OriginFilterBuilder(BrowsingDataFilterBuilder::WHITELIST)); 2647 BrowsingDataFilterBuilder::Create(
2648 BrowsingDataFilterBuilder::WHITELIST));
2649 origin_filter_builder->AddOrigin(origin); 2649 origin_filter_builder->AddOrigin(origin);
2650 2650
2651 remover->RemoveWithFilterAndReply( 2651 remover->RemoveWithFilterAndReply(
2652 base::Time(), base::Time::Max(), 2652 base::Time(), base::Time::Max(),
2653 remove_mask, BrowsingDataHelper::ALL, std::move(origin_filter_builder), 2653 remove_mask, BrowsingDataHelper::ALL, std::move(origin_filter_builder),
2654 observer); 2654 observer);
2655 } else { 2655 } else {
2656 // The second removal task is a no-op. 2656 // The second removal task is a no-op.
2657 observer->OnBrowsingDataRemoverDone(); 2657 observer->OnBrowsingDataRemoverDone();
2658 } 2658 }
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
3367 bool ChromeContentBrowserClient::ShouldRedirectDOMStorageTaskRunner() { 3367 bool ChromeContentBrowserClient::ShouldRedirectDOMStorageTaskRunner() {
3368 return variations::GetVariationParamValue( 3368 return variations::GetVariationParamValue(
3369 "BrowserScheduler", "RedirectDOMStorageTaskRunner") == "true"; 3369 "BrowserScheduler", "RedirectDOMStorageTaskRunner") == "true";
3370 } 3370 }
3371 3371
3372 bool ChromeContentBrowserClient:: 3372 bool ChromeContentBrowserClient::
3373 RedirectNonUINonIOBrowserThreadsToTaskScheduler() { 3373 RedirectNonUINonIOBrowserThreadsToTaskScheduler() {
3374 return variations::GetVariationParamValue( 3374 return variations::GetVariationParamValue(
3375 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true"; 3375 "BrowserScheduler", "RedirectNonUINonIOBrowserThreads") == "true";
3376 } 3376 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698