| 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 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 return; | 151 return; |
| 152 | 152 |
| 153 ContentVerifierDelegate::Mode mode = delegate_->ShouldBeVerified(*extension); | 153 ContentVerifierDelegate::Mode mode = delegate_->ShouldBeVerified(*extension); |
| 154 if (mode != ContentVerifierDelegate::NONE) { | 154 if (mode != ContentVerifierDelegate::NONE) { |
| 155 // The browser image paths from the extension may not be relative (eg | 155 // The browser image paths from the extension may not be relative (eg |
| 156 // they might have leading '/' or './'), so we strip those to make | 156 // they might have leading '/' or './'), so we strip those to make |
| 157 // comparing to actual relative paths work later on. | 157 // comparing to actual relative paths work later on. |
| 158 std::set<base::FilePath> original_image_paths = | 158 std::set<base::FilePath> original_image_paths = |
| 159 delegate_->GetBrowserImagePaths(extension); | 159 delegate_->GetBrowserImagePaths(extension); |
| 160 | 160 |
| 161 scoped_ptr<std::set<base::FilePath>> image_paths( | 161 std::unique_ptr<std::set<base::FilePath>> image_paths( |
| 162 new std::set<base::FilePath>); | 162 new std::set<base::FilePath>); |
| 163 for (const auto& path : original_image_paths) { | 163 for (const auto& path : original_image_paths) { |
| 164 image_paths->insert(NormalizeRelativePath(path)); | 164 image_paths->insert(NormalizeRelativePath(path)); |
| 165 } | 165 } |
| 166 | 166 |
| 167 scoped_ptr<ContentVerifierIOData::ExtensionData> data( | 167 std::unique_ptr<ContentVerifierIOData::ExtensionData> data( |
| 168 new ContentVerifierIOData::ExtensionData( | 168 new ContentVerifierIOData::ExtensionData( |
| 169 std::move(image_paths), | 169 std::move(image_paths), |
| 170 extension->version() ? *extension->version() : base::Version())); | 170 extension->version() ? *extension->version() : base::Version())); |
| 171 content::BrowserThread::PostTask(content::BrowserThread::IO, | 171 content::BrowserThread::PostTask(content::BrowserThread::IO, |
| 172 FROM_HERE, | 172 FROM_HERE, |
| 173 base::Bind(&ContentVerifierIOData::AddData, | 173 base::Bind(&ContentVerifierIOData::AddData, |
| 174 io_data_, | 174 io_data_, |
| 175 extension->id(), | 175 extension->id(), |
| 176 base::Passed(&data))); | 176 base::Passed(&data))); |
| 177 fetcher_->ExtensionLoaded(extension); | 177 fetcher_->ExtensionLoaded(extension); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 const std::set<base::FilePath>& relative_paths) { | 244 const std::set<base::FilePath>& relative_paths) { |
| 245 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 245 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 246 const ContentVerifierIOData::ExtensionData* data = | 246 const ContentVerifierIOData::ExtensionData* data = |
| 247 io_data_->GetData(extension_id); | 247 io_data_->GetData(extension_id); |
| 248 if (!data) | 248 if (!data) |
| 249 return false; | 249 return false; |
| 250 | 250 |
| 251 const std::set<base::FilePath>& browser_images = *(data->browser_image_paths); | 251 const std::set<base::FilePath>& browser_images = *(data->browser_image_paths); |
| 252 | 252 |
| 253 base::FilePath locales_dir = extension_root.Append(kLocaleFolder); | 253 base::FilePath locales_dir = extension_root.Append(kLocaleFolder); |
| 254 scoped_ptr<std::set<std::string> > all_locales; | 254 std::unique_ptr<std::set<std::string>> all_locales; |
| 255 | 255 |
| 256 for (std::set<base::FilePath>::const_iterator i = relative_paths.begin(); | 256 for (std::set<base::FilePath>::const_iterator i = relative_paths.begin(); |
| 257 i != relative_paths.end(); | 257 i != relative_paths.end(); |
| 258 ++i) { | 258 ++i) { |
| 259 const base::FilePath& relative_path = *i; | 259 const base::FilePath& relative_path = *i; |
| 260 | 260 |
| 261 if (relative_path == base::FilePath(kManifestFilename)) | 261 if (relative_path == base::FilePath(kManifestFilename)) |
| 262 continue; | 262 continue; |
| 263 | 263 |
| 264 if (ContainsKey(browser_images, relative_path)) | 264 if (ContainsKey(browser_images, relative_path)) |
| (...skipping 16 matching lines...) Expand all Loading... |
| 281 !extension_l10n_util::ShouldSkipValidation( | 281 !extension_l10n_util::ShouldSkipValidation( |
| 282 locales_dir, full_path.DirName(), *all_locales)) | 282 locales_dir, full_path.DirName(), *all_locales)) |
| 283 continue; | 283 continue; |
| 284 } | 284 } |
| 285 return true; | 285 return true; |
| 286 } | 286 } |
| 287 return false; | 287 return false; |
| 288 } | 288 } |
| 289 | 289 |
| 290 } // namespace extensions | 290 } // namespace extensions |
| OLD | NEW |