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

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

Issue 2837163004: Make call sites of subresource_filter::GetActiveConfigurations const-correct. (Closed)
Patch Set: Addressed comments from pkalinnikov@. 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
« no previous file with comments | « no previous file | components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 = subresource_filter::GetActiveConfigurations() 115 const auto configurations = subresource_filter::GetActiveConfigurations();
116 ->the_one_and_only() 116 const std::string& ruleset_flavor =
117 .ruleset_flavor; 117 configurations->the_one_and_only().ruleset_flavor;
118 if (ruleset_flavor.empty()) 118 if (ruleset_flavor.empty())
119 return ruleset_flavor; 119 return ruleset_flavor;
120 120
121 // We allow 4 ruleset flavor identifiers: a, b, c, d 121 // We allow 4 ruleset flavor identifiers: a, b, c, d
122 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' && 122 if (ruleset_flavor.size() == 1 && ruleset_flavor.at(0) >= 'a' &&
123 ruleset_flavor.at(0) <= 'd') 123 ruleset_flavor.at(0) <= 'd') {
124 return ruleset_flavor; 124 return ruleset_flavor;
125 }
125 126
126 // Return 'invalid' for any cases where we encounter an invalid installer 127 // Return 'invalid' for any cases where we encounter an invalid installer
127 // tag. This allows us to verify that no clients are encountering invalid 128 // tag. This allows us to verify that no clients are encountering invalid
128 // installer tags in the field. 129 // installer tags in the field.
129 return "invalid"; 130 return "invalid";
130 } 131 }
131 132
132 update_client::InstallerAttributes 133 update_client::InstallerAttributes
133 SubresourceFilterComponentInstallerTraits::GetInstallerAttributes() const { 134 SubresourceFilterComponentInstallerTraits::GetInstallerAttributes() const {
134 update_client::InstallerAttributes attributes; 135 update_client::InstallerAttributes attributes;
135 std::string installer_tag = GetInstallerTag(); 136 std::string installer_tag = GetInstallerTag();
136 if (!installer_tag.empty()) 137 if (!installer_tag.empty())
137 attributes["tag"] = installer_tag; 138 attributes["tag"] = installer_tag;
138 return attributes; 139 return attributes;
139 } 140 }
140 141
141 std::vector<std::string> 142 std::vector<std::string>
142 SubresourceFilterComponentInstallerTraits::GetMimeTypes() const { 143 SubresourceFilterComponentInstallerTraits::GetMimeTypes() const {
143 return std::vector<std::string>(); 144 return std::vector<std::string>();
144 } 145 }
145 146
146 void RegisterSubresourceFilterComponent(ComponentUpdateService* cus) { 147 void RegisterSubresourceFilterComponent(ComponentUpdateService* cus) {
147 if (!base::FeatureList::IsEnabled( 148 if (!base::FeatureList::IsEnabled(
148 subresource_filter::kSafeBrowsingSubresourceFilter)) 149 subresource_filter::kSafeBrowsingSubresourceFilter)) {
149 return; 150 return;
151 }
150 std::unique_ptr<ComponentInstallerTraits> traits( 152 std::unique_ptr<ComponentInstallerTraits> traits(
151 new SubresourceFilterComponentInstallerTraits()); 153 new SubresourceFilterComponentInstallerTraits());
152 // |cus| will take ownership of |installer| during installer->Register(cus). 154 // |cus| will take ownership of |installer| during installer->Register(cus).
153 DefaultComponentInstaller* installer = 155 DefaultComponentInstaller* installer =
154 new DefaultComponentInstaller(std::move(traits)); 156 new DefaultComponentInstaller(std::move(traits));
155 installer->Register(cus, base::Closure()); 157 installer->Register(cus, base::Closure());
156 } 158 }
157 159
158 } // namespace component_updater 160 } // namespace component_updater
OLDNEW
« no previous file with comments | « no previous file | components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698