| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 31 #include "chrome/common/chrome_notification_types.h" | 31 #include "chrome/common/chrome_notification_types.h" |
| 32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/chrome_utility_messages.h" | 33 #include "chrome/common/chrome_utility_messages.h" |
| 34 #include "chrome/common/chrome_version_info.h" | 34 #include "chrome/common/chrome_version_info.h" |
| 35 #include "chrome/common/extensions/extension.h" | 35 #include "chrome/common/extensions/extension.h" |
| 36 #include "chrome/common/extensions/extension_constants.h" | 36 #include "chrome/common/extensions/extension_constants.h" |
| 37 #include "chrome/common/extensions/extension_file_util.h" | 37 #include "chrome/common/extensions/extension_file_util.h" |
| 38 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 39 #include "content/browser/utility_process_host.h" | 39 #include "content/browser/utility_process_host.h" |
| 40 #include "content/common/net/url_fetcher.h" |
| 40 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 41 #include "content/public/browser/notification_source.h" | 42 #include "content/public/browser/notification_source.h" |
| 42 #include "crypto/sha2.h" | 43 #include "crypto/sha2.h" |
| 43 #include "googleurl/src/gurl.h" | 44 #include "googleurl/src/gurl.h" |
| 44 #include "net/base/escape.h" | 45 #include "net/base/escape.h" |
| 45 #include "net/base/load_flags.h" | 46 #include "net/base/load_flags.h" |
| 46 #include "net/url_request/url_request_status.h" | 47 #include "net/url_request/url_request_status.h" |
| 47 | 48 |
| 48 #if defined(OS_MACOSX) | 49 #if defined(OS_MACOSX) |
| 49 #include "base/sys_string_conversions.h" | 50 #include "base/sys_string_conversions.h" |
| (...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 extensions_pending_.clear(); | 591 extensions_pending_.clear(); |
| 591 } | 592 } |
| 592 | 593 |
| 593 void ExtensionUpdater::OnURLFetchComplete(const URLFetcher* source) { | 594 void ExtensionUpdater::OnURLFetchComplete(const URLFetcher* source) { |
| 594 // Stop() destroys all our URLFetchers, which means we shouldn't be | 595 // Stop() destroys all our URLFetchers, which means we shouldn't be |
| 595 // called after Stop() is called. | 596 // called after Stop() is called. |
| 596 DCHECK(alive_); | 597 DCHECK(alive_); |
| 597 | 598 |
| 598 if (source == manifest_fetcher_.get()) { | 599 if (source == manifest_fetcher_.get()) { |
| 599 std::string data; | 600 std::string data; |
| 600 CHECK(source->GetResponseAsString(&data)); | 601 source->GetResponseAsString(&data); |
| 601 OnManifestFetchComplete(source->url(), | 602 OnManifestFetchComplete(source->url(), |
| 602 source->status(), | 603 source->status(), |
| 603 source->response_code(), | 604 source->response_code(), |
| 604 data); | 605 data); |
| 605 } else if (source == extension_fetcher_.get()) { | 606 } else if (source == extension_fetcher_.get()) { |
| 606 OnCRXFetchComplete(source, | 607 OnCRXFetchComplete(source, |
| 607 source->url(), | 608 source->url(), |
| 608 source->status(), | 609 source->status(), |
| 609 source->response_code()); | 610 source->response_code()); |
| 610 } else { | 611 } else { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 836 << current_extension_fetch_.id << ". " | 837 << current_extension_fetch_.id << ". " |
| 837 << "Error code is "<< error_code; | 838 << "Error code is "<< error_code; |
| 838 | 839 |
| 839 RecordCRXWriteHistogram(false, FilePath()); | 840 RecordCRXWriteHistogram(false, FilePath()); |
| 840 OnCRXFileWriteError(current_extension_fetch_.id); | 841 OnCRXFileWriteError(current_extension_fetch_.id); |
| 841 | 842 |
| 842 } else if (status.status() == net::URLRequestStatus::SUCCESS && | 843 } else if (status.status() == net::URLRequestStatus::SUCCESS && |
| 843 (response_code == 200 || url.SchemeIsFile())) { | 844 (response_code == 200 || url.SchemeIsFile())) { |
| 844 if (current_extension_fetch_.id == kBlacklistAppID) { | 845 if (current_extension_fetch_.id == kBlacklistAppID) { |
| 845 std::string data; | 846 std::string data; |
| 846 CHECK(source->GetResponseAsString(&data)); | 847 source->GetResponseAsString(&data); |
| 847 ProcessBlacklist(data); | 848 ProcessBlacklist(data); |
| 848 in_progress_ids_.erase(current_extension_fetch_.id); | 849 in_progress_ids_.erase(current_extension_fetch_.id); |
| 849 } else { | 850 } else { |
| 850 FilePath crx_path; | 851 FilePath crx_path; |
| 851 // Take ownership of the file at |crx_path|. | 852 // Take ownership of the file at |crx_path|. |
| 852 CHECK(source->GetResponseAsFilePath(true, &crx_path)); | 853 CHECK(source->GetResponseAsFilePath(true, &crx_path)); |
| 853 RecordCRXWriteHistogram(true, crx_path); | 854 RecordCRXWriteHistogram(true, crx_path); |
| 854 OnCRXFileWritten(current_extension_fetch_.id, crx_path, url); | 855 OnCRXFileWritten(current_extension_fetch_.id, crx_path, url); |
| 855 } | 856 } |
| 856 } else { | 857 } else { |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1243 std::set<std::string>::const_iterator i; | 1244 std::set<std::string>::const_iterator i; |
| 1244 for (i = ids.begin(); i != ids.end(); ++i) | 1245 for (i = ids.begin(); i != ids.end(); ++i) |
| 1245 in_progress_ids_.insert(*i); | 1246 in_progress_ids_.insert(*i); |
| 1246 } | 1247 } |
| 1247 | 1248 |
| 1248 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1249 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
| 1249 std::set<std::string>::const_iterator i; | 1250 std::set<std::string>::const_iterator i; |
| 1250 for (i = ids.begin(); i != ids.end(); ++i) | 1251 for (i = ids.begin(); i != ids.end(); ++i) |
| 1251 in_progress_ids_.erase(*i); | 1252 in_progress_ids_.erase(*i); |
| 1252 } | 1253 } |
| OLD | NEW |