| 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" |   15 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 
|   16 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" |   16 #include "chrome/browser/browsing_data/browsing_data_remover_delegate.h" | 
|   17 #include "chrome/common/features.h" |   17 #include "chrome/common/features.h" | 
|   18 #include "components/browsing_data/core/browsing_data_utils.h" |   18 #include "components/browsing_data/core/browsing_data_utils.h" | 
|   19 #include "components/offline_pages/core/offline_page_model.h" |   19 #include "components/offline_pages/core/offline_page_model.h" | 
|   20 #include "components/search_engines/template_url_service.h" |   20 #include "components/search_engines/template_url_service.h" | 
 |   21 #include "extensions/features/features.h" | 
|   21 #include "media/media_features.h" |   22 #include "media/media_features.h" | 
|   22 #include "ppapi/features/features.h" |   23 #include "ppapi/features/features.h" | 
|   23  |   24  | 
|   24 #if BUILDFLAG(ENABLE_PLUGINS) |   25 #if BUILDFLAG(ENABLE_PLUGINS) | 
|   25 #include "chrome/browser/pepper_flash_settings_manager.h" |   26 #include "chrome/browser/pepper_flash_settings_manager.h" | 
|   26 #endif |   27 #endif | 
|   27  |   28  | 
|   28 #if defined(OS_CHROMEOS) |   29 #if defined(OS_CHROMEOS) | 
|   29 #include "chromeos/dbus/dbus_method_call_status.h" |   30 #include "chromeos/dbus/dbus_method_call_status.h" | 
|   30 #endif |   31 #endif | 
|   31  |   32  | 
|   32 class BrowsingDataFlashLSOHelper; |   33 class BrowsingDataFlashLSOHelper; | 
|   33 class Profile; |   34 class Profile; | 
|   34 class WebappRegistry; |   35 class WebappRegistry; | 
|   35  |   36  | 
|   36 namespace content { |   37 namespace content { | 
|   37 class BrowserContext; |   38 class BrowserContext; | 
|   38 class PluginDataRemover; |   39 class PluginDataRemover; | 
|   39 } |   40 } | 
|   40  |   41  | 
|   41 // A delegate used by BrowsingDataRemover to delete data specific to Chrome |   42 // A delegate used by BrowsingDataRemover to delete data specific to Chrome | 
|   42 // as the embedder. |   43 // as the embedder. | 
|   43 class ChromeBrowsingDataRemoverDelegate : public BrowsingDataRemoverDelegate |   44 class ChromeBrowsingDataRemoverDelegate : public BrowsingDataRemoverDelegate | 
|   44 #if BUILDFLAG(ENABLE_PLUGINS) |   45 #if BUILDFLAG(ENABLE_PLUGINS) | 
|   45     , public PepperFlashSettingsManager::Client |   46     , public PepperFlashSettingsManager::Client | 
|   46 #endif |   47 #endif | 
|   47 { |   48 { | 
|   48  public: |   49  public: | 
 |   50   // This is an extension of BrowsingDataRemover::RemoveDataMask which includes | 
 |   51   // 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 | 
 |   53   // run out of space anytime soon. | 
 |   54   enum DataType { | 
 |   55     // Embedder can start adding datatypes after the last platform datatype. | 
 |   56     DATA_TYPE_EMBEDDER_BEGIN = BrowsingDataRemover::DATA_TYPE_CONTENT_END << 1, | 
 |   57  | 
 |   58     // Chrome-specific datatypes. | 
 |   59     DATA_TYPE_HISTORY = DATA_TYPE_EMBEDDER_BEGIN, | 
 |   60     DATA_TYPE_FORM_DATA = DATA_TYPE_EMBEDDER_BEGIN << 1, | 
 |   61     DATA_TYPE_PASSWORDS = DATA_TYPE_EMBEDDER_BEGIN << 2, | 
 |   62     DATA_TYPE_PLUGIN_DATA = DATA_TYPE_EMBEDDER_BEGIN << 3, | 
 |   63 #if defined(OS_ANDROID) | 
 |   64     DATA_TYPE_WEB_APP_DATA = DATA_TYPE_EMBEDDER_BEGIN << 4, | 
 |   65 #endif | 
 |   66     DATA_TYPE_SITE_USAGE_DATA = DATA_TYPE_EMBEDDER_BEGIN << 5, | 
 |   67     DATA_TYPE_DURABLE_PERMISSION = DATA_TYPE_EMBEDDER_BEGIN << 6, | 
 |   68     DATA_TYPE_EXTERNAL_PROTOCOL_DATA = DATA_TYPE_EMBEDDER_BEGIN << 7, | 
 |   69     DATA_TYPE_HOSTED_APP_DATA_TEST_ONLY = DATA_TYPE_EMBEDDER_BEGIN << 8, | 
 |   70  | 
 |   71     // Group datatypes. | 
 |   72  | 
 |   73     // "Site data" includes storage backend accessible to websites and some | 
 |   74     // additional metadata kept by the browser (e.g. site usage data). | 
 |   75     DATA_TYPE_SITE_DATA = BrowsingDataRemover::DATA_TYPE_APP_CACHE | | 
 |   76                           BrowsingDataRemover::DATA_TYPE_COOKIES | | 
 |   77                           BrowsingDataRemover::DATA_TYPE_FILE_SYSTEMS | | 
 |   78                           BrowsingDataRemover::DATA_TYPE_INDEXED_DB | | 
 |   79                           BrowsingDataRemover::DATA_TYPE_LOCAL_STORAGE | | 
 |   80                           BrowsingDataRemover::DATA_TYPE_SERVICE_WORKERS | | 
 |   81                           BrowsingDataRemover::DATA_TYPE_CACHE_STORAGE | | 
 |   82                           BrowsingDataRemover::DATA_TYPE_WEB_SQL | | 
 |   83                           BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS | | 
 |   84                           DATA_TYPE_PLUGIN_DATA | | 
 |   85 #if defined(OS_ANDROID) | 
 |   86                           DATA_TYPE_WEB_APP_DATA | | 
 |   87 #endif | 
 |   88                           DATA_TYPE_SITE_USAGE_DATA | | 
 |   89                           DATA_TYPE_DURABLE_PERMISSION | | 
 |   90                           DATA_TYPE_EXTERNAL_PROTOCOL_DATA, | 
 |   91  | 
 |   92     // Datatypes protected by Important Sites. | 
 |   93     IMPORTANT_SITES_DATA_TYPES = | 
 |   94         DATA_TYPE_SITE_DATA | BrowsingDataRemover::DATA_TYPE_CACHE, | 
 |   95  | 
 |   96     // Datatypes that can be deleted partially per URL / origin / domain, | 
 |   97     // whichever makes sense. | 
 |   98     FILTERABLE_DATA_TYPES = DATA_TYPE_SITE_DATA | | 
 |   99                             BrowsingDataRemover::DATA_TYPE_CACHE | | 
 |  100                             BrowsingDataRemover::DATA_TYPE_DOWNLOADS, | 
 |  101  | 
 |  102     // 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 | 
 |  104     // look like a new Profile. | 
 |  105     ALL_DATA_TYPES = DATA_TYPE_SITE_DATA | | 
 |  106                      BrowsingDataRemover::DATA_TYPE_CACHE | | 
 |  107                      BrowsingDataRemover::DATA_TYPE_DOWNLOADS | | 
 |  108                      DATA_TYPE_FORM_DATA | | 
 |  109                      DATA_TYPE_HISTORY | | 
 |  110                      DATA_TYPE_PASSWORDS | | 
 |  111                      BrowsingDataRemover::DATA_TYPE_MEDIA_LICENSES, | 
 |  112  | 
 |  113     // 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 | 
 |  115     // disk as soon as possible. | 
 |  116     WIPE_PROFILE = ALL_DATA_TYPES | BrowsingDataRemover::DATA_TYPE_NO_CHECKS, | 
 |  117   }; | 
 |  118  | 
 |  119   // This is an extension of BrowsingDataRemover::OriginType which includes all | 
 |  120   // origin types therefrom and adds additional Chrome-specific ones. | 
 |  121   enum OriginType { | 
 |  122     // Embedder can start adding origin types after the last | 
 |  123     // platform origin type. | 
 |  124     ORIGIN_TYPE_EMBEDDER_BEGIN = BrowsingDataRemover::ORIGIN_TYPE_CONTENT_END | 
 |  125                                  << 1, | 
 |  126  | 
 |  127 #if BUILDFLAG(ENABLE_EXTENSIONS) | 
 |  128     // Packaged apps and extensions (chrome-extension://*). | 
 |  129     ORIGIN_TYPE_EXTENSION = ORIGIN_TYPE_EMBEDDER_BEGIN, | 
 |  130 #endif | 
 |  131  | 
 |  132     // All origin types. | 
 |  133     ALL_ORIGIN_TYPES = BrowsingDataRemover::ORIGIN_TYPE_UNPROTECTED_WEB | | 
 |  134 #if BUILDFLAG(ENABLE_EXTENSIONS) | 
 |  135                        ORIGIN_TYPE_EXTENSION | | 
 |  136 #endif | 
 |  137                        BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB, | 
 |  138   }; | 
 |  139  | 
 |  140   // Important sites protect a small set of sites from the deletion of certain | 
 |  141   // datatypes. Therefore, those datatypes must be filterable by | 
 |  142   // url/origin/domain. | 
 |  143   static_assert((IMPORTANT_SITES_DATA_TYPES & ~FILTERABLE_DATA_TYPES) == 0, | 
 |  144                 "All important sites datatypes must be filterable."); | 
 |  145  | 
|   49   // Used to track the deletion of a single data storage backend. |  146   // Used to track the deletion of a single data storage backend. | 
|   50   class SubTask { |  147   class SubTask { | 
|   51    public: |  148    public: | 
|   52     // Creates a SubTask that calls |forward_callback| when completed. |  149     // Creates a SubTask that calls |forward_callback| when completed. | 
|   53     // |forward_callback| is only kept as a reference and must outlive SubTask. |  150     // |forward_callback| is only kept as a reference and must outlive SubTask. | 
|   54     explicit SubTask(const base::Closure& forward_callback); |  151     explicit SubTask(const base::Closure& forward_callback); | 
|   55     ~SubTask(); |  152     ~SubTask(); | 
|   56  |  153  | 
|   57     // Indicate that the task is in progress and we're waiting. |  154     // Indicate that the task is in progress and we're waiting. | 
|   58     void Start(); |  155     void Start(); | 
|   59  |  156  | 
|   60     // Returns a callback that should be called to indicate that the task |  157     // Returns a callback that should be called to indicate that the task | 
|   61     // has been finished. |  158     // has been finished. | 
|   62     base::Closure GetCompletionCallback(); |  159     base::Closure GetCompletionCallback(); | 
|   63  |  160  | 
|   64     // Whether the task is still in progress. |  161     // Whether the task is still in progress. | 
|   65     bool is_pending() const { return is_pending_; } |  162     bool is_pending() const { return is_pending_; } | 
|   66  |  163  | 
|   67    private: |  164    private: | 
|   68     void CompletionCallback(); |  165     void CompletionCallback(); | 
|   69  |  166  | 
|   70     bool is_pending_; |  167     bool is_pending_; | 
|   71     const base::Closure& forward_callback_; |  168     const base::Closure& forward_callback_; | 
|   72     base::WeakPtrFactory<SubTask> weak_ptr_factory_; |  169     base::WeakPtrFactory<SubTask> weak_ptr_factory_; | 
|   73   }; |  170   }; | 
|   74  |  171  | 
|   75   ChromeBrowsingDataRemoverDelegate(content::BrowserContext* browser_context); |  172   ChromeBrowsingDataRemoverDelegate(content::BrowserContext* browser_context); | 
|   76   ~ChromeBrowsingDataRemoverDelegate() override; |  173   ~ChromeBrowsingDataRemoverDelegate() override; | 
|   77  |  174  | 
|   78   // Removes Chrome-specific data. |  175   // BrowsingDataRemoverDelegate: | 
 |  176   bool DoesOriginMatchEmbedderMask( | 
 |  177       int origin_type_mask, | 
 |  178       const GURL& origin, | 
 |  179       storage::SpecialStoragePolicy* special_storage_policy) const override; | 
|   79   void RemoveEmbedderData( |  180   void RemoveEmbedderData( | 
|   80       const base::Time& delete_begin, |  181       const base::Time& delete_begin, | 
|   81       const base::Time& delete_end, |  182       const base::Time& delete_end, | 
|   82       int remove_mask, |  183       int remove_mask, | 
|   83       const content::BrowsingDataFilterBuilder& filter_builder, |  184       const content::BrowsingDataFilterBuilder& filter_builder, | 
|   84       int origin_type_mask, |  185       int origin_type_mask, | 
|   85       const base::Closure& callback) override; |  186       const base::Closure& callback) override; | 
|   86  |  187  | 
|   87 #if defined(OS_ANDROID) |  188 #if defined(OS_ANDROID) | 
|   88   void OverrideWebappRegistryForTesting( |  189   void OverrideWebappRegistryForTesting( | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  203   // not initialised, so the registry must be mocked out. |  304   // not initialised, so the registry must be mocked out. | 
|  204   std::unique_ptr<WebappRegistry> webapp_registry_; |  305   std::unique_ptr<WebappRegistry> webapp_registry_; | 
|  205 #endif |  306 #endif | 
|  206  |  307  | 
|  207   base::WeakPtrFactory<ChromeBrowsingDataRemoverDelegate> weak_ptr_factory_; |  308   base::WeakPtrFactory<ChromeBrowsingDataRemoverDelegate> weak_ptr_factory_; | 
|  208  |  309  | 
|  209   DISALLOW_COPY_AND_ASSIGN(ChromeBrowsingDataRemoverDelegate); |  310   DISALLOW_COPY_AND_ASSIGN(ChromeBrowsingDataRemoverDelegate); | 
|  210 }; |  311 }; | 
|  211  |  312  | 
|  212 #endif  // CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ |  313 #endif  // CHROME_BROWSER_BROWSING_DATA_CHROME_BROWSING_DATA_REMOVER_DELEGATE_H_ | 
| OLD | NEW |