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

Side by Side Diff: extensions/browser/content_verifier.cc

Issue 2572833004: Only whitelist messages.json files in _locales for content verification (Closed)
Patch Set: turn on logging to try and understand win_chromium_x64_rel_ng test failures Created 4 years 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 | « extensions/browser/content_hash_fetcher.cc ('k') | extensions/browser/content_verify_job.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/content_verifier.h" 5 #include "extensions/browser/content_verifier.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) { 122 if (!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)) {
123 content::BrowserThread::PostTask( 123 content::BrowserThread::PostTask(
124 content::BrowserThread::UI, 124 content::BrowserThread::UI,
125 FROM_HERE, 125 FROM_HERE,
126 base::Bind(&ContentVerifier::VerifyFailed, this, extension_id, reason)); 126 base::Bind(&ContentVerifier::VerifyFailed, this, extension_id, reason));
127 return; 127 return;
128 } 128 }
129 if (shutdown_) 129 if (shutdown_)
130 return; 130 return;
131 131
132 VLOG(1) << "VerifyFailed " << extension_id << " reason:" << reason; 132 LOG(WARNING) << "VerifyFailed " << extension_id << " reason:" << reason;
133 133
134 ExtensionRegistry* registry = ExtensionRegistry::Get(context_); 134 ExtensionRegistry* registry = ExtensionRegistry::Get(context_);
135 const Extension* extension = 135 const Extension* extension =
136 registry->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); 136 registry->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
137 137
138 if (!extension) 138 if (!extension)
139 return; 139 return;
140 140
141 if (reason == ContentVerifyJob::MISSING_ALL_HASHES) { 141 if (reason == ContentVerifyJob::MISSING_ALL_HASHES) {
142 // If we failed because there were no hashes yet for this extension, just 142 // If we failed because there were no hashes yet for this extension, just
143 // request some. 143 // request some.
144 fetcher_->DoFetch(extension, true /* force */); 144 fetcher_->DoFetch(extension, true /* force */);
145 } else { 145 } else {
146 delegate_->VerifyFailed(extension_id, reason); 146 delegate_->VerifyFailed(extension_id, reason);
147 } 147 }
148 } 148 }
149 149
150 void ContentVerifier::OnExtensionLoaded( 150 void ContentVerifier::OnExtensionLoaded(
151 content::BrowserContext* browser_context, 151 content::BrowserContext* browser_context,
152 const Extension* extension) { 152 const Extension* extension) {
153 if (shutdown_) 153 if (shutdown_)
154 return; 154 return;
155 155
156 LOG(WARNING) << "ContentVerifier::OnExtensionLoaded " << extension->id();
157
156 ContentVerifierDelegate::Mode mode = delegate_->ShouldBeVerified(*extension); 158 ContentVerifierDelegate::Mode mode = delegate_->ShouldBeVerified(*extension);
157 if (mode != ContentVerifierDelegate::NONE) { 159 if (mode != ContentVerifierDelegate::NONE) {
158 // The browser image paths from the extension may not be relative (eg 160 // The browser image paths from the extension may not be relative (eg
159 // they might have leading '/' or './'), so we strip those to make 161 // they might have leading '/' or './'), so we strip those to make
160 // comparing to actual relative paths work later on. 162 // comparing to actual relative paths work later on.
161 std::set<base::FilePath> original_image_paths = 163 std::set<base::FilePath> original_image_paths =
162 delegate_->GetBrowserImagePaths(extension); 164 delegate_->GetBrowserImagePaths(extension);
163 165
164 std::unique_ptr<std::set<base::FilePath>> image_paths( 166 std::unique_ptr<std::set<base::FilePath>> image_paths(
165 new std::set<base::FilePath>); 167 new std::set<base::FilePath>);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 const std::string& extension_id, 208 const std::string& extension_id,
207 bool success, 209 bool success,
208 bool was_force_check, 210 bool was_force_check,
209 const std::set<base::FilePath>& hash_mismatch_paths) { 211 const std::set<base::FilePath>& hash_mismatch_paths) {
210 if (g_test_observer) 212 if (g_test_observer)
211 g_test_observer->OnFetchComplete(extension_id, success); 213 g_test_observer->OnFetchComplete(extension_id, success);
212 214
213 if (shutdown_) 215 if (shutdown_)
214 return; 216 return;
215 217
216 VLOG(1) << "OnFetchComplete " << extension_id << " success:" << success; 218 LOG(WARNING) << "OnFetchComplete " << extension_id << " success:" << success;
217 219
218 ExtensionRegistry* registry = ExtensionRegistry::Get(context_); 220 ExtensionRegistry* registry = ExtensionRegistry::Get(context_);
219 const Extension* extension = 221 const Extension* extension =
220 registry->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); 222 registry->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING);
221 if (!delegate_ || !extension) 223 if (!delegate_ || !extension)
222 return; 224 return;
223 225
224 ContentVerifierDelegate::Mode mode = delegate_->ShouldBeVerified(*extension); 226 ContentVerifierDelegate::Mode mode = delegate_->ShouldBeVerified(*extension);
225 if (was_force_check && !success && 227 if (was_force_check && !success &&
226 mode == ContentVerifierDelegate::ENFORCE_STRICT) { 228 mode == ContentVerifierDelegate::ENFORCE_STRICT) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 if (!all_locales) { 274 if (!all_locales) {
273 // TODO(asargent) - see if we can cache this list longer to avoid 275 // TODO(asargent) - see if we can cache this list longer to avoid
274 // having to fetch it more than once for a given run of the 276 // having to fetch it more than once for a given run of the
275 // browser. Maybe it can never change at runtime? (Or if it can, maybe 277 // browser. Maybe it can never change at runtime? (Or if it can, maybe
276 // there is an event we can listen for to know to drop our cache). 278 // there is an event we can listen for to know to drop our cache).
277 all_locales.reset(new std::set<std::string>); 279 all_locales.reset(new std::set<std::string>);
278 extension_l10n_util::GetAllLocales(all_locales.get()); 280 extension_l10n_util::GetAllLocales(all_locales.get());
279 } 281 }
280 282
281 // Since message catalogs get transcoded during installation, we want 283 // Since message catalogs get transcoded during installation, we want
282 // to skip those paths. 284 // to skip those paths. See if this path looks like
285 // _locales/<some locale>/messages.json - if so then skip it.
283 if (full_path.DirName().DirName() == locales_dir && 286 if (full_path.DirName().DirName() == locales_dir &&
284 !extension_l10n_util::ShouldSkipValidation( 287 base::ContainsKey(*all_locales,
285 locales_dir, full_path.DirName(), *all_locales)) 288 full_path.DirName().BaseName().MaybeAsASCII()) &&
289 full_path == full_path.DirName().Append(kMessagesFilename))
286 continue; 290 continue;
287 } 291 }
288 return true; 292 return true;
289 } 293 }
290 return false; 294 return false;
291 } 295 }
292 296
293 } // namespace extensions 297 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_hash_fetcher.cc ('k') | extensions/browser/content_verify_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698