| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ | 6 #define CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/synchronization/waitable_event_watcher.h" | 13 #include "base/synchronization/waitable_event_watcher.h" |
| 14 #include "base/task/cancelable_task_tracker.h" | 14 #include "base/task/cancelable_task_tracker.h" |
| 15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | |
| 16 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" | |
| 17 #include "chrome/common/features.h" | 15 #include "chrome/common/features.h" |
| 18 #include "components/browsing_data/core/browsing_data_utils.h" | 16 #include "components/browsing_data/core/browsing_data_utils.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" |
| 19 #include "components/offline_pages/core/offline_page_model.h" | 18 #include "components/offline_pages/core/offline_page_model.h" |
| 20 #include "components/search_engines/template_url_service.h" | 19 #include "components/search_engines/template_url_service.h" |
| 20 #include "content/public/browser/browsing_data_remover.h" |
| 21 #include "content/public/browser/browsing_data_remover_delegate.h" |
| 21 #include "extensions/features/features.h" | 22 #include "extensions/features/features.h" |
| 22 #include "media/media_features.h" | 23 #include "media/media_features.h" |
| 23 #include "ppapi/features/features.h" | 24 #include "ppapi/features/features.h" |
| 24 | 25 |
| 25 #if BUILDFLAG(ENABLE_PLUGINS) | 26 #if BUILDFLAG(ENABLE_PLUGINS) |
| 26 #include "chrome/browser/pepper_flash_settings_manager.h" | 27 #include "chrome/browser/pepper_flash_settings_manager.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
| 30 #include "chromeos/dbus/dbus_method_call_status.h" | 31 #include "chromeos/dbus/dbus_method_call_status.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 class BrowsingDataFlashLSOHelper; | 34 class BrowsingDataFlashLSOHelper; |
| 34 class Profile; | 35 class Profile; |
| 35 class WebappRegistry; | 36 class WebappRegistry; |
| 36 | 37 |
| 37 namespace content { | 38 namespace content { |
| 38 class BrowserContext; | 39 class BrowserContext; |
| 39 class PluginDataRemover; | 40 class PluginDataRemover; |
| 40 } | 41 } |
| 41 | 42 |
| 42 // A delegate used by BrowsingDataRemover to delete data specific to Chrome | 43 // A delegate used by BrowsingDataRemover to delete data specific to Chrome |
| 43 // as the embedder. | 44 // as the embedder. |
| 44 class ChromeBrowsingDataRemoverDelegate : public BrowsingDataRemoverDelegate | 45 class ChromeBrowsingDataRemoverDelegate |
| 46 : public content::BrowsingDataRemoverDelegate, |
| 47 public KeyedService |
| 45 #if BUILDFLAG(ENABLE_PLUGINS) | 48 #if BUILDFLAG(ENABLE_PLUGINS) |
| 46 , public PepperFlashSettingsManager::Client | 49 , |
| 50 public PepperFlashSettingsManager::Client |
| 47 #endif | 51 #endif |
| 48 { | 52 { |
| 49 public: | 53 public: |
| 50 // This is an extension of BrowsingDataRemover::RemoveDataMask which includes | 54 // This is an extension of content::BrowsingDataRemover::RemoveDataMask which |
| 51 // all datatypes therefrom and adds additional Chrome-specific ones. | 55 // includes all datatypes therefrom and adds additional Chrome-specific ones. |
| 52 // TODO(crbug.com/668114): Extend this to uint64_t to ensure that we won't | 56 // TODO(crbug.com/668114): Extend this to uint64_t to ensure that we won't |
| 53 // run out of space anytime soon. | 57 // run out of space anytime soon. |
| 54 enum DataType { | 58 enum DataType { |
| 55 // Embedder can start adding datatypes after the last platform datatype. | 59 // Embedder can start adding datatypes after the last platform datatype. |
| 56 DATA_TYPE_EMBEDDER_BEGIN = BrowsingDataRemover::DATA_TYPE_CONTENT_END << 1, | 60 DATA_TYPE_EMBEDDER_BEGIN = |
| 61 content::BrowsingDataRemover::DATA_TYPE_CONTENT_END << 1, |
| 57 | 62 |
| 58 // Chrome-specific datatypes. | 63 // Chrome-specific datatypes. |
| 59 DATA_TYPE_HISTORY = DATA_TYPE_EMBEDDER_BEGIN, | 64 DATA_TYPE_HISTORY = DATA_TYPE_EMBEDDER_BEGIN, |
| 60 DATA_TYPE_FORM_DATA = DATA_TYPE_EMBEDDER_BEGIN << 1, | 65 DATA_TYPE_FORM_DATA = DATA_TYPE_EMBEDDER_BEGIN << 1, |
| 61 DATA_TYPE_PASSWORDS = DATA_TYPE_EMBEDDER_BEGIN << 2, | 66 DATA_TYPE_PASSWORDS = DATA_TYPE_EMBEDDER_BEGIN << 2, |
| 62 DATA_TYPE_PLUGIN_DATA = DATA_TYPE_EMBEDDER_BEGIN << 3, | 67 DATA_TYPE_PLUGIN_DATA = DATA_TYPE_EMBEDDER_BEGIN << 3, |
| 63 #if defined(OS_ANDROID) | 68 #if defined(OS_ANDROID) |
| 64 DATA_TYPE_WEB_APP_DATA = DATA_TYPE_EMBEDDER_BEGIN << 4, | 69 DATA_TYPE_WEB_APP_DATA = DATA_TYPE_EMBEDDER_BEGIN << 4, |
| 65 #endif | 70 #endif |
| 66 DATA_TYPE_SITE_USAGE_DATA = DATA_TYPE_EMBEDDER_BEGIN << 5, | 71 DATA_TYPE_SITE_USAGE_DATA = DATA_TYPE_EMBEDDER_BEGIN << 5, |
| 67 DATA_TYPE_DURABLE_PERMISSION = DATA_TYPE_EMBEDDER_BEGIN << 6, | 72 DATA_TYPE_DURABLE_PERMISSION = DATA_TYPE_EMBEDDER_BEGIN << 6, |
| 68 DATA_TYPE_EXTERNAL_PROTOCOL_DATA = DATA_TYPE_EMBEDDER_BEGIN << 7, | 73 DATA_TYPE_EXTERNAL_PROTOCOL_DATA = DATA_TYPE_EMBEDDER_BEGIN << 7, |
| 69 DATA_TYPE_HOSTED_APP_DATA_TEST_ONLY = DATA_TYPE_EMBEDDER_BEGIN << 8, | 74 DATA_TYPE_HOSTED_APP_DATA_TEST_ONLY = DATA_TYPE_EMBEDDER_BEGIN << 8, |
| 70 | 75 |
| 71 // Group datatypes. | 76 // Group datatypes. |
| 72 | 77 |
| 73 // "Site data" includes storage backend accessible to websites and some | 78 // "Site data" includes storage backend accessible to websites and some |
| 74 // additional metadata kept by the browser (e.g. site usage data). | 79 // additional metadata kept by the browser (e.g. site usage data). |
| 75 DATA_TYPE_SITE_DATA = BrowsingDataRemover::DATA_TYPE_APP_CACHE | | 80 DATA_TYPE_SITE_DATA = |
| 76 BrowsingDataRemover::DATA_TYPE_COOKIES | | 81 content::BrowsingDataRemover::DATA_TYPE_APP_CACHE | |
| 77 BrowsingDataRemover::DATA_TYPE_FILE_SYSTEMS | | 82 content::BrowsingDataRemover::DATA_TYPE_COOKIES | |
| 78 BrowsingDataRemover::DATA_TYPE_INDEXED_DB | | 83 content::BrowsingDataRemover::DATA_TYPE_FILE_SYSTEMS | |
| 79 BrowsingDataRemover::DATA_TYPE_LOCAL_STORAGE | | 84 content::BrowsingDataRemover::DATA_TYPE_INDEXED_DB | |
| 80 BrowsingDataRemover::DATA_TYPE_SERVICE_WORKERS | | 85 content::BrowsingDataRemover::DATA_TYPE_LOCAL_STORAGE | |
| 81 BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE | | 86 content::BrowsingDataRemover::DATA_TYPE_SERVICE_WORKERS | |
| 82 BrowsingDataRemover::DATA_TYPE_WEB_SQL | | 87 content::BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE | |
| 83 BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS | | 88 content::BrowsingDataRemover::DATA_TYPE_WEB_SQL | |
| 84 DATA_TYPE_PLUGIN_DATA | | 89 content::BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS | |
| 90 DATA_TYPE_PLUGIN_DATA | |
| 85 #if defined(OS_ANDROID) | 91 #if defined(OS_ANDROID) |
| 86 DATA_TYPE_WEB_APP_DATA | | 92 DATA_TYPE_WEB_APP_DATA | |
| 87 #endif | 93 #endif |
| 88 DATA_TYPE_SITE_USAGE_DATA | | 94 DATA_TYPE_SITE_USAGE_DATA | |
| 89 DATA_TYPE_DURABLE_PERMISSION | | 95 DATA_TYPE_DURABLE_PERMISSION | |
| 90 DATA_TYPE_EXTERNAL_PROTOCOL_DATA, | 96 DATA_TYPE_EXTERNAL_PROTOCOL_DATA, |
| 91 | 97 |
| 92 // Datatypes protected by Important Sites. | 98 // Datatypes protected by Important Sites. |
| 93 IMPORTANT_SITES_DATA_TYPES = | 99 IMPORTANT_SITES_DATA_TYPES = |
| 94 DATA_TYPE_SITE_DATA | BrowsingDataRemover::DATA_TYPE_CACHE, | 100 DATA_TYPE_SITE_DATA | content::BrowsingDataRemover::DATA_TYPE_CACHE, |
| 95 | 101 |
| 96 // Datatypes that can be deleted partially per URL / origin / domain, | 102 // Datatypes that can be deleted partially per URL / origin / domain, |
| 97 // whichever makes sense. | 103 // whichever makes sense. |
| 98 FILTERABLE_DATA_TYPES = DATA_TYPE_SITE_DATA | | 104 FILTERABLE_DATA_TYPES = DATA_TYPE_SITE_DATA | |
| 99 BrowsingDataRemover::DATA_TYPE_CACHE | | 105 content::BrowsingDataRemover::DATA_TYPE_CACHE | |
| 100 BrowsingDataRemover::DATA_TYPE_DOWNLOADS, | 106 content::BrowsingDataRemover::DATA_TYPE_DOWNLOADS, |
| 101 | 107 |
| 102 // Includes all the available remove options. Meant to be used by clients | 108 // Includes all the available remove options. Meant to be used by clients |
| 103 // that wish to wipe as much data as possible from a Profile, to make it | 109 // that wish to wipe as much data as possible from a Profile, to make it |
| 104 // look like a new Profile. | 110 // look like a new Profile. |
| 105 ALL_DATA_TYPES = DATA_TYPE_SITE_DATA | | 111 ALL_DATA_TYPES = DATA_TYPE_SITE_DATA | |
| 106 BrowsingDataRemover::DATA_TYPE_CACHE | | 112 content::BrowsingDataRemover::DATA_TYPE_CACHE | |
| 107 BrowsingDataRemover::DATA_TYPE_DOWNLOADS | | 113 content::BrowsingDataRemover::DATA_TYPE_DOWNLOADS | |
| 108 DATA_TYPE_FORM_DATA | | 114 DATA_TYPE_FORM_DATA | |
| 109 DATA_TYPE_HISTORY | | 115 DATA_TYPE_HISTORY | |
| 110 DATA_TYPE_PASSWORDS | | 116 DATA_TYPE_PASSWORDS | |
| 111 BrowsingDataRemover::DATA_TYPE_MEDIA_LICENSES, | 117 content::BrowsingDataRemover::DATA_TYPE_MEDIA_LICENSES, |
| 112 | 118 |
| 113 // Includes all available remove options. Meant to be used when the Profile | 119 // Includes all available remove options. Meant to be used when the Profile |
| 114 // is scheduled to be deleted, and all possible data should be wiped from | 120 // is scheduled to be deleted, and all possible data should be wiped from |
| 115 // disk as soon as possible. | 121 // disk as soon as possible. |
| 116 WIPE_PROFILE = ALL_DATA_TYPES | BrowsingDataRemover::DATA_TYPE_NO_CHECKS, | 122 WIPE_PROFILE = |
| 123 ALL_DATA_TYPES | content::BrowsingDataRemover::DATA_TYPE_NO_CHECKS, |
| 117 }; | 124 }; |
| 118 | 125 |
| 119 // This is an extension of BrowsingDataRemover::OriginType which includes all | 126 // This is an extension of content::BrowsingDataRemover::OriginType which |
| 120 // origin types therefrom and adds additional Chrome-specific ones. | 127 // includes all origin types therefrom and adds additional Chrome-specific |
| 128 // ones. |
| 121 enum OriginType { | 129 enum OriginType { |
| 122 // Embedder can start adding origin types after the last | 130 // Embedder can start adding origin types after the last |
| 123 // platform origin type. | 131 // platform origin type. |
| 124 ORIGIN_TYPE_EMBEDDER_BEGIN = BrowsingDataRemover::ORIGIN_TYPE_CONTENT_END | 132 ORIGIN_TYPE_EMBEDDER_BEGIN = |
| 125 << 1, | 133 content::BrowsingDataRemover::ORIGIN_TYPE_CONTENT_END << 1, |
| 126 | 134 |
| 127 #if BUILDFLAG(ENABLE_EXTENSIONS) | 135 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 128 // Packaged apps and extensions (chrome-extension://*). | 136 // Packaged apps and extensions (chrome-extension://*). |
| 129 ORIGIN_TYPE_EXTENSION = ORIGIN_TYPE_EMBEDDER_BEGIN, | 137 ORIGIN_TYPE_EXTENSION = ORIGIN_TYPE_EMBEDDER_BEGIN, |
| 130 #endif | 138 #endif |
| 131 | 139 |
| 132 // All origin types. | 140 // All origin types. |
| 133 ALL_ORIGIN_TYPES = BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | | 141 ALL_ORIGIN_TYPES = |
| 142 content::BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | |
| 134 #if BUILDFLAG(ENABLE_EXTENSIONS) | 143 #if BUILDFLAG(ENABLE_EXTENSIONS) |
| 135 ORIGIN_TYPE_EXTENSION | | 144 ORIGIN_TYPE_EXTENSION | |
| 136 #endif | 145 #endif |
| 137 BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB, | 146 content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB, |
| 138 }; | 147 }; |
| 139 | 148 |
| 140 // Important sites protect a small set of sites from the deletion of certain | 149 // Important sites protect a small set of sites from the deletion of certain |
| 141 // datatypes. Therefore, those datatypes must be filterable by | 150 // datatypes. Therefore, those datatypes must be filterable by |
| 142 // url/origin/domain. | 151 // url/origin/domain. |
| 143 static_assert((IMPORTANT_SITES_DATA_TYPES & ~FILTERABLE_DATA_TYPES) == 0, | 152 static_assert((IMPORTANT_SITES_DATA_TYPES & ~FILTERABLE_DATA_TYPES) == 0, |
| 144 "All important sites datatypes must be filterable."); | 153 "All important sites datatypes must be filterable."); |
| 145 | 154 |
| 146 // Used to track the deletion of a single data storage backend. | 155 // Used to track the deletion of a single data storage backend. |
| 147 class SubTask { | 156 class SubTask { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 165 void CompletionCallback(); | 174 void CompletionCallback(); |
| 166 | 175 |
| 167 bool is_pending_; | 176 bool is_pending_; |
| 168 const base::Closure& forward_callback_; | 177 const base::Closure& forward_callback_; |
| 169 base::WeakPtrFactory<SubTask> weak_ptr_factory_; | 178 base::WeakPtrFactory<SubTask> weak_ptr_factory_; |
| 170 }; | 179 }; |
| 171 | 180 |
| 172 ChromeBrowsingDataRemoverDelegate(content::BrowserContext* browser_context); | 181 ChromeBrowsingDataRemoverDelegate(content::BrowserContext* browser_context); |
| 173 ~ChromeBrowsingDataRemoverDelegate() override; | 182 ~ChromeBrowsingDataRemoverDelegate() override; |
| 174 | 183 |
| 184 // KeyedService: |
| 185 void Shutdown() override; |
| 186 |
| 175 // BrowsingDataRemoverDelegate: | 187 // BrowsingDataRemoverDelegate: |
| 176 BrowsingDataRemoverDelegate::EmbedderOriginTypeMatcher GetOriginTypeMatcher() | 188 content::BrowsingDataRemoverDelegate::EmbedderOriginTypeMatcher |
| 177 const override; | 189 GetOriginTypeMatcher() const override; |
| 178 void RemoveEmbedderData( | 190 void RemoveEmbedderData( |
| 179 const base::Time& delete_begin, | 191 const base::Time& delete_begin, |
| 180 const base::Time& delete_end, | 192 const base::Time& delete_end, |
| 181 int remove_mask, | 193 int remove_mask, |
| 182 const content::BrowsingDataFilterBuilder& filter_builder, | 194 const content::BrowsingDataFilterBuilder& filter_builder, |
| 183 int origin_type_mask, | 195 int origin_type_mask, |
| 184 const base::Closure& callback) override; | 196 const base::Closure& callback) override; |
| 185 | 197 |
| 186 #if defined(OS_ANDROID) | 198 #if defined(OS_ANDROID) |
| 187 void OverrideWebappRegistryForTesting( | 199 void OverrideWebappRegistryForTesting( |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 // not initialised, so the registry must be mocked out. | 314 // not initialised, so the registry must be mocked out. |
| 303 std::unique_ptr<WebappRegistry> webapp_registry_; | 315 std::unique_ptr<WebappRegistry> webapp_registry_; |
| 304 #endif | 316 #endif |
| 305 | 317 |
| 306 base::WeakPtrFactory<ChromeBrowsingDataRemoverDelegate> weak_ptr_factory_; | 318 base::WeakPtrFactory<ChromeBrowsingDataRemoverDelegate> weak_ptr_factory_; |
| 307 | 319 |
| 308 DISALLOW_COPY_AND_ASSIGN(ChromeBrowsingDataRemoverDelegate); | 320 DISALLOW_COPY_AND_ASSIGN(ChromeBrowsingDataRemoverDelegate); |
| 309 }; | 321 }; |
| 310 | 322 |
| 311 #endif // CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ | 323 #endif // CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ |
| OLD | NEW |