| 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_hash_fetcher.h" | 5 #include "extensions/browser/content_hash_fetcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "crypto/sha2.h" | 25 #include "crypto/sha2.h" |
| 26 #include "extensions/browser/computed_hashes.h" | 26 #include "extensions/browser/computed_hashes.h" |
| 27 #include "extensions/browser/content_hash_tree.h" | 27 #include "extensions/browser/content_hash_tree.h" |
| 28 #include "extensions/browser/content_verifier_delegate.h" | 28 #include "extensions/browser/content_verifier_delegate.h" |
| 29 #include "extensions/browser/verified_contents.h" | 29 #include "extensions/browser/verified_contents.h" |
| 30 #include "extensions/common/constants.h" | 30 #include "extensions/common/constants.h" |
| 31 #include "extensions/common/extension.h" | 31 #include "extensions/common/extension.h" |
| 32 #include "extensions/common/file_util.h" | 32 #include "extensions/common/file_util.h" |
| 33 #include "net/base/load_flags.h" | 33 #include "net/base/load_flags.h" |
| 34 #include "net/traffic_annotation/network_traffic_annotation.h" |
| 34 #include "net/url_request/url_fetcher.h" | 35 #include "net/url_request/url_fetcher.h" |
| 35 #include "net/url_request/url_fetcher_delegate.h" | 36 #include "net/url_request/url_fetcher_delegate.h" |
| 36 #include "net/url_request/url_request_status.h" | 37 #include "net/url_request/url_request_status.h" |
| 37 | 38 |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 typedef std::set<base::FilePath> SortedFilePathSet; | 41 typedef std::set<base::FilePath> SortedFilePathSet; |
| 41 | 42 |
| 42 } // namespace | 43 } // namespace |
| 43 | 44 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 234 |
| 234 void ContentHashFetcherJob::DoneCheckingForVerifiedContents(bool found) { | 235 void ContentHashFetcherJob::DoneCheckingForVerifiedContents(bool found) { |
| 235 if (IsCancelled()) | 236 if (IsCancelled()) |
| 236 return; | 237 return; |
| 237 if (found) { | 238 if (found) { |
| 238 VLOG(1) << "Found verified contents for " << extension_id_; | 239 VLOG(1) << "Found verified contents for " << extension_id_; |
| 239 DoneFetchingVerifiedContents(true); | 240 DoneFetchingVerifiedContents(true); |
| 240 } else { | 241 } else { |
| 241 VLOG(1) << "Missing verified contents for " << extension_id_ | 242 VLOG(1) << "Missing verified contents for " << extension_id_ |
| 242 << ", fetching..."; | 243 << ", fetching..."; |
| 243 url_fetcher_ = | 244 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 244 net::URLFetcher::Create(fetch_url_, net::URLFetcher::GET, this); | 245 net::DefineNetworkTrafficAnnotation("content_hash_verification_job", R"( |
| 246 semantics { |
| 247 sender: "Web Store Content Verification" |
| 248 description: |
| 249 "The request sent to retrieve the file required for content " |
| 250 "verification for an extension from the Web Store." |
| 251 trigger: |
| 252 "An extension from the Web Store is missing the " |
| 253 "verified_contents.json file required for extension content " |
| 254 "verification." |
| 255 data: "The extension id and extension version." |
| 256 destination: GOOGLE_OWNED_SERVICE |
| 257 } |
| 258 policy { |
| 259 cookies_allowed: false |
| 260 setting: |
| 261 "This feature cannot be directly disabled; it is enabled if any " |
| 262 "extension from the webstore is installed in the browser." |
| 263 policy_exception_justification: |
| 264 "Not implemented, not required. If the user has extensions from " |
| 265 "the Web Store, this feature is required to ensure the " |
| 266 "extensions match what is distributed by the store." |
| 267 })"); |
| 268 url_fetcher_ = net::URLFetcher::Create(fetch_url_, net::URLFetcher::GET, |
| 269 this, traffic_annotation); |
| 245 url_fetcher_->SetRequestContext(request_context_); | 270 url_fetcher_->SetRequestContext(request_context_); |
| 246 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 271 url_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 247 net::LOAD_DO_NOT_SAVE_COOKIES | | 272 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 248 net::LOAD_DISABLE_CACHE); | 273 net::LOAD_DISABLE_CACHE); |
| 249 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); | 274 url_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); |
| 250 url_fetcher_->Start(); | 275 url_fetcher_->Start(); |
| 251 } | 276 } |
| 252 } | 277 } |
| 253 | 278 |
| 254 // Helper function to let us pass ownership of a string via base::Bind with the | 279 // Helper function to let us pass ownership of a string via base::Bind with the |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 522 |
| 498 for (JobMap::iterator i = jobs_.begin(); i != jobs_.end(); ++i) { | 523 for (JobMap::iterator i = jobs_.begin(); i != jobs_.end(); ++i) { |
| 499 if (i->second.get() == job) { | 524 if (i->second.get() == job) { |
| 500 jobs_.erase(i); | 525 jobs_.erase(i); |
| 501 break; | 526 break; |
| 502 } | 527 } |
| 503 } | 528 } |
| 504 } | 529 } |
| 505 | 530 |
| 506 } // namespace extensions | 531 } // namespace extensions |
| OLD | NEW |