Split browsing data masks between content and embedder

As a part of the refactoring to move content-related browsing data
infrastructure to content, we split BrowsingDataRemover::RemoveDataMask
and BrowsingDataHelper::OriginTypeMask between content and embedder.

The CL consists of the following steps:

1. BrowsingDataRemover::RemoveDataMask now only contains content datatypes.
Chrome-specific datatypes are moved to ChromeBrowsingDataRemoverDelegate.
The enum in ChromeBrowsingDataRemoverDelegate also copies all values
from BrowsingDataRemover so that this enum inheritance better mimics
class inheritance. Note that this is a second attempt at this change, following
the discussion in https://codereview.chromium.org/2697123004/ where we tried
converting enums into pointers first.

The concept of FILTERABLE_DATATYPES has been moved to
ChromeBrowsingDataRemoverDelegate, since all content data types are filterable.

2. The same exercise is done for BrowsingDataHelper::OriginTypeMask. Its
first two items, UNPROTECTED_WEB and PROTECTED_WEB correspond to the boolean
returned by content::SpecialStoragePolicy::IsProtected(). Therefore, they
are moved to content as a new enum in BrowsingDataRemover. The third item,
EXTENSION, is a Chrome-specific concept and stays in chrome/ code, as a new
enum in ChromeBrowsingDataRemoverDelegate.

BrowsingDataRemoverImpl is now able to tell about each origin whether it is
UNPROTECTED_WEB or PROTECTED_WEB. It delegates the decision what is an
EXTENSION to ChromeBrowsingDataRemoverDelegate. A new method has been added
to the BrowsingDataRemoverDelegate for this purpose.

BrowsingDataHelper now serves no other purpose than recognizing webby and
extension URLs for various classes in browsing_data/ and can be eventually
deprecated (though doing so in this CL would significantly blow it in size).

The behavior of UNPROTECTED_WEB and PROTECTED_WEB is already sufficiently
tested in StoragePartition-related tests of BrowsingDataRemoverTest. We just
had to replace MockExtensionSpecialStoragePolicy with the regular
MockSpecialStoragePolicy. Testcases from BrowsingDataHelperTest have been moved
to ChromeBrowsingDataRemoverDelegateTest to cover the remaining EXTENSION type.

3. Since BrowsingDataRemover and ChromeBrowsingDataRemoverDelegate now host
both the data type and origin type enums, we changed the naming to call out
the difference; all data types are now prefixed with DATA_TYPE, all origin
types with ORIGIN_TYPE.

4. All other files contain equivalent replacements.

[email protected],[email protected]
BUG=668114

Review-Url: https://codereview.chromium.org/2733393003
Cr-Commit-Position: refs/heads/master@{#456757}
diff --git a/chrome/browser/chrome_content_browser_client_unittest.cc b/chrome/browser/chrome_content_browser_client_unittest.cc
index 70725c8..95736423 100644
--- a/chrome/browser/chrome_content_browser_client_unittest.cc
+++ b/chrome/browser/chrome_content_browser_client_unittest.cc
@@ -19,6 +19,7 @@
 #include "build/build_config.h"
 #include "chrome/browser/browsing_data/browsing_data_helper.h"
 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h"
+#include "chrome/browser/browsing_data/chrome_browsing_data_remover_delegate.h"
 #include "chrome/browser/browsing_data/mock_browsing_data_remover.h"
 #include "chrome/browser/search_engines/template_url_service_factory.h"
 #include "chrome/test/base/testing_profile.h"
@@ -387,26 +388,32 @@
     int mask;
   } test_cases[] = {
       {false, false, false, 0},
-      {true, false, false, BrowsingDataRemover::REMOVE_COOKIES |
-                               BrowsingDataRemover::REMOVE_CHANNEL_IDS |
-                               BrowsingDataRemover::REMOVE_PLUGIN_DATA},
-      {false, true, false, BrowsingDataRemover::REMOVE_SITE_DATA &
-                               ~BrowsingDataRemover::REMOVE_COOKIES &
-                               ~BrowsingDataRemover::REMOVE_CHANNEL_IDS &
-                               ~BrowsingDataRemover::REMOVE_PLUGIN_DATA},
-      {false, false, true, BrowsingDataRemover::REMOVE_CACHE},
-      {true, true, false, BrowsingDataRemover::REMOVE_SITE_DATA},
-      {true, false, true, BrowsingDataRemover::REMOVE_COOKIES |
-                              BrowsingDataRemover::REMOVE_CHANNEL_IDS |
-                              BrowsingDataRemover::REMOVE_PLUGIN_DATA |
-                              BrowsingDataRemover::REMOVE_CACHE},
-      {false, true, true, BrowsingDataRemover::REMOVE_CACHE |
-                              (BrowsingDataRemover::REMOVE_SITE_DATA &
-                               ~BrowsingDataRemover::REMOVE_COOKIES &
-                               ~BrowsingDataRemover::REMOVE_CHANNEL_IDS &
-                               ~BrowsingDataRemover::REMOVE_PLUGIN_DATA)},
-      {true, true, true, BrowsingDataRemover::REMOVE_SITE_DATA |
-                             BrowsingDataRemover::REMOVE_CACHE},
+      {true, false, false,
+       BrowsingDataRemover::DATA_TYPE_COOKIES |
+           BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS |
+           ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA},
+      {false, true, false,
+       ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA &
+           ~BrowsingDataRemover::DATA_TYPE_COOKIES &
+           ~BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS &
+           ~ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA},
+      {false, false, true, BrowsingDataRemover::DATA_TYPE_CACHE},
+      {true, true, false,
+       ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA},
+      {true, false, true,
+       BrowsingDataRemover::DATA_TYPE_COOKIES |
+           BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS |
+           ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA |
+           BrowsingDataRemover::DATA_TYPE_CACHE},
+      {false, true, true,
+       BrowsingDataRemover::DATA_TYPE_CACHE |
+           (ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA &
+            ~BrowsingDataRemover::DATA_TYPE_COOKIES &
+            ~BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS &
+            ~ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA)},
+      {true, true, true,
+       ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA |
+           BrowsingDataRemover::DATA_TYPE_CACHE},
   };
 
   for (unsigned int i = 0; i < arraysize(test_cases); ++i) {
@@ -414,16 +421,16 @@
     const TestCase& test_case = test_cases[i];
 
     // We always delete data for all time and all origin types.
-    BrowsingDataHelper::OriginTypeMask all_origin_types =
-        BrowsingDataHelper::ALL;
+    int all_origin_types = ChromeBrowsingDataRemoverDelegate::ALL_ORIGIN_TYPES;
 
     // Some data are deleted for the origin and some for the registrable domain.
     // Depending on the chosen datatypes, this might result into one or two
     // calls. In the latter case, the removal mask will be split into two
     // parts - one for the origin deletion and one for the registrable domain.
-    const int domain_scoped_types = BrowsingDataRemover::REMOVE_COOKIES |
-                                    BrowsingDataRemover::REMOVE_CHANNEL_IDS |
-                                    BrowsingDataRemover::REMOVE_PLUGIN_DATA;
+    const int domain_scoped_types =
+        BrowsingDataRemover::DATA_TYPE_COOKIES |
+        BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS |
+        ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA;
     int registrable_domain_deletion_mask = test_case.mask & domain_scoped_types;
     int origin_deletion_mask = test_case.mask & ~domain_scoped_types;
 
@@ -505,20 +512,21 @@
 
     remover()->ExpectCall(
         base::Time(), base::Time::Max(),
-        BrowsingDataRemover::REMOVE_COOKIES |
-            BrowsingDataRemover::REMOVE_CHANNEL_IDS |
-            BrowsingDataRemover::REMOVE_PLUGIN_DATA,
-        BrowsingDataHelper::ALL, std::move(registrable_domain_filter_builder));
+        BrowsingDataRemover::DATA_TYPE_COOKIES |
+            BrowsingDataRemover::DATA_TYPE_CHANNEL_IDS |
+            ChromeBrowsingDataRemoverDelegate::DATA_TYPE_PLUGIN_DATA,
+        ChromeBrowsingDataRemoverDelegate::ALL_ORIGIN_TYPES,
+        std::move(registrable_domain_filter_builder));
 
     std::unique_ptr<BrowsingDataFilterBuilder> origin_filter_builder(
         BrowsingDataFilterBuilder::Create(
             BrowsingDataFilterBuilder::WHITELIST));
     origin_filter_builder->AddOrigin(url::Origin(GURL(test_case.origin)));
 
-    remover()->ExpectCall(
-        base::Time(), base::Time::Max(),
-        BrowsingDataRemover::REMOVE_CACHE, BrowsingDataHelper::ALL,
-        std::move(origin_filter_builder));
+    remover()->ExpectCall(base::Time(), base::Time::Max(),
+                          BrowsingDataRemover::DATA_TYPE_CACHE,
+                          ChromeBrowsingDataRemoverDelegate::ALL_ORIGIN_TYPES,
+                          std::move(origin_filter_builder));
 
     SetClearingFinished(false);
     client.ClearSiteData(