Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 i != relative_paths.end(); | 205 i != relative_paths.end(); |
| 206 ++i) { | 206 ++i) { |
| 207 const base::FilePath& relative_path = *i; | 207 const base::FilePath& relative_path = *i; |
| 208 | 208 |
| 209 if (relative_path == base::FilePath(kManifestFilename)) | 209 if (relative_path == base::FilePath(kManifestFilename)) |
| 210 continue; | 210 continue; |
| 211 | 211 |
| 212 if (ContainsKey(browser_images, relative_path)) | 212 if (ContainsKey(browser_images, relative_path)) |
| 213 continue; | 213 continue; |
| 214 | 214 |
| 215 // The browser image paths from the extension may not be normalized (eg | |
| 216 // they might have leading '/' or './'), so we need to compare basename and | |
| 217 // dirname separately. | |
| 218 bool browser_image_match = false; | |
| 219 for (const auto& image_path : browser_images) { | |
|
Ken Rockot(use gerrit already)
2014/10/07 17:25:51
YAY AUTO
| |
| 220 if (image_path.BaseName() == relative_path.BaseName() && | |
| 221 image_path.DirName() == relative_path.DirName()) { | |
|
Ken Rockot(use gerrit already)
2014/10/07 17:25:51
Discussed offline, but probably want to compare in
| |
| 222 browser_image_match = true; | |
| 223 break; | |
| 224 } | |
| 225 } | |
| 226 if (browser_image_match) | |
| 227 continue; | |
| 228 | |
| 215 base::FilePath full_path = extension_root.Append(relative_path); | 229 base::FilePath full_path = extension_root.Append(relative_path); |
| 216 if (locales_dir.IsParent(full_path)) { | 230 if (locales_dir.IsParent(full_path)) { |
| 217 if (!all_locales) { | 231 if (!all_locales) { |
| 218 // TODO(asargent) - see if we can cache this list longer to avoid | 232 // TODO(asargent) - see if we can cache this list longer to avoid |
| 219 // having to fetch it more than once for a given run of the | 233 // having to fetch it more than once for a given run of the |
| 220 // browser. Maybe it can never change at runtime? (Or if it can, maybe | 234 // browser. Maybe it can never change at runtime? (Or if it can, maybe |
| 221 // there is an event we can listen for to know to drop our cache). | 235 // there is an event we can listen for to know to drop our cache). |
| 222 all_locales.reset(new std::set<std::string>); | 236 all_locales.reset(new std::set<std::string>); |
| 223 extension_l10n_util::GetAllLocales(all_locales.get()); | 237 extension_l10n_util::GetAllLocales(all_locales.get()); |
| 224 } | 238 } |
| 225 | 239 |
| 226 // Since message catalogs get transcoded during installation, we want | 240 // Since message catalogs get transcoded during installation, we want |
| 227 // to skip those paths. | 241 // to skip those paths. |
| 228 if (full_path.DirName().DirName() == locales_dir && | 242 if (full_path.DirName().DirName() == locales_dir && |
| 229 !extension_l10n_util::ShouldSkipValidation( | 243 !extension_l10n_util::ShouldSkipValidation( |
| 230 locales_dir, full_path.DirName(), *all_locales)) | 244 locales_dir, full_path.DirName(), *all_locales)) |
| 231 continue; | 245 continue; |
| 232 } | 246 } |
| 233 return true; | 247 return true; |
| 234 } | 248 } |
| 235 return false; | 249 return false; |
| 236 } | 250 } |
| 237 | 251 |
| 238 } // namespace extensions | 252 } // namespace extensions |
| OLD | NEW |