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/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "base/version.h" | 22 #include "base/version.h" |
23 #include "crypto/sha2.h" | 23 #include "crypto/sha2.h" |
24 #include "content/common/notification_service.h" | 24 #include "content/common/notification_service.h" |
25 #include "content/common/notification_source.h" | 25 #include "content/common/notification_source.h" |
26 #include "chrome/browser/browser_process.h" | 26 #include "chrome/browser/browser_process.h" |
27 #include "chrome/browser/extensions/crx_installer.h" | 27 #include "chrome/browser/extensions/crx_installer.h" |
28 #include "chrome/browser/extensions/extension_error_reporter.h" | 28 #include "chrome/browser/extensions/extension_error_reporter.h" |
29 #include "chrome/browser/extensions/extension_service.h" | 29 #include "chrome/browser/extensions/extension_service.h" |
30 #include "chrome/browser/prefs/pref_service.h" | 30 #include "chrome/browser/prefs/pref_service.h" |
31 #include "chrome/browser/profiles/profile.h" | 31 #include "chrome/browser/profiles/profile.h" |
32 #include "chrome/browser/utility_process_host.h" | |
33 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.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 "googleurl/src/gurl.h" | 40 #include "googleurl/src/gurl.h" |
40 #include "net/base/escape.h" | 41 #include "net/base/escape.h" |
41 #include "net/base/load_flags.h" | 42 #include "net/base/load_flags.h" |
42 #include "net/url_request/url_request_status.h" | 43 #include "net/url_request/url_request_status.h" |
43 | 44 |
44 #if defined(OS_MACOSX) | 45 #if defined(OS_MACOSX) |
45 #include "base/sys_string_conversions.h" | 46 #include "base/sys_string_conversions.h" |
46 #endif | 47 #endif |
47 | 48 |
48 #define SEND_ACTIVE_PINGS 1 | 49 #define SEND_ACTIVE_PINGS 1 |
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 void ParseInSandbox(ResourceDispatcherHost* rdh) { | 634 void ParseInSandbox(ResourceDispatcherHost* rdh) { |
634 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 635 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
635 | 636 |
636 // TODO(asargent) we shouldn't need to do this branch here - instead | 637 // TODO(asargent) we shouldn't need to do this branch here - instead |
637 // UtilityProcessHost should handle it for us. (http://crbug.com/19192) | 638 // UtilityProcessHost should handle it for us. (http://crbug.com/19192) |
638 bool use_utility_process = rdh && | 639 bool use_utility_process = rdh && |
639 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); | 640 !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); |
640 if (use_utility_process) { | 641 if (use_utility_process) { |
641 UtilityProcessHost* host = new UtilityProcessHost( | 642 UtilityProcessHost* host = new UtilityProcessHost( |
642 this, BrowserThread::UI); | 643 this, BrowserThread::UI); |
643 host->StartUpdateManifestParse(xml_); | 644 host->Send(new UtilityMsg_ParseUpdateManifest(xml_)); |
644 } else { | 645 } else { |
645 UpdateManifest manifest; | 646 UpdateManifest manifest; |
646 if (manifest.Parse(xml_)) { | 647 if (manifest.Parse(xml_)) { |
647 if (!BrowserThread::PostTask( | 648 if (!BrowserThread::PostTask( |
648 BrowserThread::UI, FROM_HERE, | 649 BrowserThread::UI, FROM_HERE, |
649 NewRunnableMethod( | 650 NewRunnableMethod( |
650 this, &SafeManifestParser::OnParseUpdateManifestSucceeded, | 651 this, &SafeManifestParser::OnParseUpdateManifestSucceeded, |
651 manifest.results()))) { | 652 manifest.results()))) { |
652 NOTREACHED(); | 653 NOTREACHED(); |
653 } | 654 } |
654 } else { | 655 } else { |
655 if (!BrowserThread::PostTask( | 656 if (!BrowserThread::PostTask( |
656 BrowserThread::UI, FROM_HERE, | 657 BrowserThread::UI, FROM_HERE, |
657 NewRunnableMethod( | 658 NewRunnableMethod( |
658 this, &SafeManifestParser::OnParseUpdateManifestFailed, | 659 this, &SafeManifestParser::OnParseUpdateManifestFailed, |
659 manifest.errors()))) { | 660 manifest.errors()))) { |
660 NOTREACHED(); | 661 NOTREACHED(); |
661 } | 662 } |
662 } | 663 } |
663 } | 664 } |
664 } | 665 } |
665 | 666 |
666 // Callback from the utility process when parsing succeeded. | 667 // UtilityProcessHost::Client |
667 virtual void OnParseUpdateManifestSucceeded( | 668 virtual bool OnMessageReceived(const IPC::Message& message) { |
| 669 bool handled = true; |
| 670 IPC_BEGIN_MESSAGE_MAP(SafeManifestParser, message) |
| 671 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Succeeded, |
| 672 OnParseUpdateManifestSucceeded) |
| 673 IPC_MESSAGE_HANDLER(UtilityHostMsg_ParseUpdateManifest_Failed, |
| 674 OnParseUpdateManifestFailed) |
| 675 IPC_MESSAGE_UNHANDLED(handled = false) |
| 676 IPC_END_MESSAGE_MAP_EX() |
| 677 return handled; |
| 678 } |
| 679 |
| 680 void OnParseUpdateManifestSucceeded( |
668 const UpdateManifest::Results& results) { | 681 const UpdateManifest::Results& results) { |
669 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 682 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
670 if (!updater_) { | 683 if (!updater_) { |
671 return; | 684 return; |
672 } | 685 } |
673 updater_->HandleManifestResults(*fetch_data_, &results); | 686 updater_->HandleManifestResults(*fetch_data_, &results); |
674 } | 687 } |
675 | 688 |
676 // Callback from the utility process when parsing failed. | 689 void OnParseUpdateManifestFailed(const std::string& error_message) { |
677 virtual void OnParseUpdateManifestFailed(const std::string& error_message) { | |
678 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 690 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
679 if (!updater_) { | 691 if (!updater_) { |
680 return; | 692 return; |
681 } | 693 } |
682 LOG(WARNING) << "Error parsing update manifest:\n" << error_message; | 694 LOG(WARNING) << "Error parsing update manifest:\n" << error_message; |
683 updater_->HandleManifestResults(*fetch_data_, NULL); | 695 updater_->HandleManifestResults(*fetch_data_, NULL); |
684 } | 696 } |
685 | 697 |
686 private: | 698 private: |
687 ~SafeManifestParser() { | 699 ~SafeManifestParser() { |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1221 std::set<std::string>::const_iterator i; | 1233 std::set<std::string>::const_iterator i; |
1222 for (i = ids.begin(); i != ids.end(); ++i) | 1234 for (i = ids.begin(); i != ids.end(); ++i) |
1223 in_progress_ids_.insert(*i); | 1235 in_progress_ids_.insert(*i); |
1224 } | 1236 } |
1225 | 1237 |
1226 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { | 1238 void ExtensionUpdater::RemoveFromInProgress(const std::set<std::string>& ids) { |
1227 std::set<std::string>::const_iterator i; | 1239 std::set<std::string>::const_iterator i; |
1228 for (i = ids.begin(); i != ids.end(); ++i) | 1240 for (i = ids.begin(); i != ids.end(); ++i) |
1229 in_progress_ids_.erase(*i); | 1241 in_progress_ids_.erase(*i); |
1230 } | 1242 } |
OLD | NEW |