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

Side by Side Diff: chrome/browser/component_updater/subresource_filter_component_installer.cc

Issue 2831373002: Introduce subresource_filter::ConfigurationList and make querying it cheap. (Closed)
Patch Set: Rebase. Created 3 years, 8 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 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 #include "chrome/browser/component_updater/subresource_filter_component_installe r.h" 5 #include "chrome/browser/component_updater/subresource_filter_component_installe r.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 std::vector<uint8_t>* hash) const { 105 std::vector<uint8_t>* hash) const {
106 hash->assign(std::begin(kPublicKeySHA256), std::end(kPublicKeySHA256)); 106 hash->assign(std::begin(kPublicKeySHA256), std::end(kPublicKeySHA256));
107 } 107 }
108 108
109 std::string SubresourceFilterComponentInstallerTraits::GetName() const { 109 std::string SubresourceFilterComponentInstallerTraits::GetName() const {
110 return kSubresourceFilterSetFetcherManifestName; 110 return kSubresourceFilterSetFetcherManifestName;
111 } 111 }
112 112
113 // static 113 // static
114 std::string SubresourceFilterComponentInstallerTraits::GetInstallerTag() { 114 std::string SubresourceFilterComponentInstallerTraits::GetInstallerTag() {
115 std::string ruleset_flavor = 115 std::string ruleset_flavor = subresource_filter::GetActiveConfigurations()
Sorin Jianu 2017/04/24 21:58:59 can this be declared const?
engedy 2017/04/25 08:34:23 Yep, done.
116 subresource_filter::GetActiveConfiguration().ruleset_flavor; 116 ->the_one_and_only()
117 .ruleset_flavor;
117 if (ruleset_flavor.empty()) 118 if (ruleset_flavor.empty())
118 return ruleset_flavor; 119 return ruleset_flavor;
119 120
120 // We allow 4 ruleset flavor identifiers: a, b, c, d 121 // We allow 4 ruleset flavor identifiers: a, b, c, d
121 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' && 122 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' &&
122 ruleset_flavor.at(0) <= 'd') 123 ruleset_flavor.at(0) <= 'd')
123 return ruleset_flavor; 124 return ruleset_flavor;
124 125
125 // Return 'invalid' for any cases where we encounter an invalid installer 126 // Return 'invalid' for any cases where we encounter an invalid installer
126 // tag. This allows us to verify that no clients are encountering invalid 127 // tag. This allows us to verify that no clients are encountering invalid
(...skipping 21 matching lines...) Expand all
148 return; 149 return;
149 std::unique_ptr<ComponentInstallerTraits> traits( 150 std::unique_ptr<ComponentInstallerTraits> traits(
150 new SubresourceFilterComponentInstallerTraits()); 151 new SubresourceFilterComponentInstallerTraits());
151 // |cus| will take ownership of |installer| during installer->Register(cus). 152 // |cus| will take ownership of |installer| during installer->Register(cus).
152 DefaultComponentInstaller* installer = 153 DefaultComponentInstaller* installer =
153 new DefaultComponentInstaller(std::move(traits)); 154 new DefaultComponentInstaller(std::move(traits));
154 installer->Register(cus, base::Closure()); 155 installer->Register(cus, base::Closure());
155 } 156 }
156 157
157 } // namespace component_updater 158 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698