| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/file_version_info.h" | 12 #include "base/file_version_info.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/sha2.h" | 14 #include "base/sha2.h" |
| 15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/time.h" | 17 #include "base/time.h" |
| 18 #include "base/thread.h" | 18 #include "base/thread.h" |
| 19 #include "base/version.h" | 19 #include "base/version.h" |
| 20 #include "chrome/app/chrome_version_info.h" |
| 20 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/extensions/extensions_service.h" | 22 #include "chrome/browser/extensions/extensions_service.h" |
| 22 #include "chrome/browser/pref_service.h" | 23 #include "chrome/browser/pref_service.h" |
| 23 #include "chrome/browser/profile.h" | 24 #include "chrome/browser/profile.h" |
| 24 #include "chrome/browser/utility_process_host.h" | 25 #include "chrome/browser/utility_process_host.h" |
| 25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/extension_error_reporter.h" | 28 #include "chrome/common/extensions/extension_error_reporter.h" |
| 28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 29 #include "googleurl/src/gurl.h" | 30 #include "googleurl/src/gurl.h" |
| (...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 if (!update_version.get() || | 775 if (!update_version.get() || |
| 775 update_version->CompareTo(*(existing_version.get())) <= 0) { | 776 update_version->CompareTo(*(existing_version.get())) <= 0) { |
| 776 continue; | 777 continue; |
| 777 } | 778 } |
| 778 | 779 |
| 779 // If the update specifies a browser minimum version, do we qualify? | 780 // If the update specifies a browser minimum version, do we qualify? |
| 780 if (update->browser_min_version.length() > 0) { | 781 if (update->browser_min_version.length() > 0) { |
| 781 // First determine the browser version if we haven't already. | 782 // First determine the browser version if we haven't already. |
| 782 if (!browser_version.get()) { | 783 if (!browser_version.get()) { |
| 783 scoped_ptr<FileVersionInfo> version_info( | 784 scoped_ptr<FileVersionInfo> version_info( |
| 784 FileVersionInfo::CreateFileVersionInfoForCurrentModule()); | 785 chrome_app::GetChromeVersionInfo()); |
| 785 if (version_info.get()) { | 786 if (version_info.get()) { |
| 786 browser_version.reset(Version::GetVersionFromString( | 787 browser_version.reset(Version::GetVersionFromString( |
| 787 version_info->product_version())); | 788 version_info->product_version())); |
| 788 } | 789 } |
| 789 } | 790 } |
| 790 scoped_ptr<Version> browser_min_version( | 791 scoped_ptr<Version> browser_min_version( |
| 791 Version::GetVersionFromString(update->browser_min_version)); | 792 Version::GetVersionFromString(update->browser_min_version)); |
| 792 if (browser_version.get() && browser_min_version.get() && | 793 if (browser_version.get() && browser_min_version.get() && |
| 793 browser_min_version->CompareTo(*browser_version.get()) > 0) { | 794 browser_min_version->CompareTo(*browser_version.get()) > 0) { |
| 794 // TODO(asargent) - We may want this to show up in the extensions UI | 795 // TODO(asargent) - We may want this to show up in the extensions UI |
| 795 // eventually. (http://crbug.com/12547). | 796 // eventually. (http://crbug.com/12547). |
| 796 LOG(WARNING) << "Updated version of extension " << update->extension_id | 797 LOG(WARNING) << "Updated version of extension " << update->extension_id |
| 797 << " available, but requires chrome version " | 798 << " available, but requires chrome version " |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 extension_fetcher_.reset( | 855 extension_fetcher_.reset( |
| 855 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); | 856 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); |
| 856 extension_fetcher_->set_request_context( | 857 extension_fetcher_->set_request_context( |
| 857 Profile::GetDefaultRequestContext()); | 858 Profile::GetDefaultRequestContext()); |
| 858 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | | 859 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 859 net::LOAD_DO_NOT_SAVE_COOKIES); | 860 net::LOAD_DO_NOT_SAVE_COOKIES); |
| 860 extension_fetcher_->Start(); | 861 extension_fetcher_->Start(); |
| 861 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); | 862 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); |
| 862 } | 863 } |
| 863 } | 864 } |
| OLD | NEW |