OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/updater/extension_updater.h" | 5 #include "chrome/browser/extensions/updater/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" |
11 #include "base/files/file_enumerator.h" | |
12 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
15 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
16 #include "base/rand_util.h" | 15 #include "base/rand_util.h" |
17 #include "base/stl_util.h" | 16 #include "base/stl_util.h" |
18 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
19 #include "base/strings/string_split.h" | 18 #include "base/strings/string_split.h" |
20 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
21 #include "chrome/browser/extensions/api/module/module.h" | 20 #include "chrome/browser/extensions/api/module/module.h" |
22 #include "chrome/browser/extensions/crx_installer.h" | 21 #include "chrome/browser/extensions/crx_installer.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 22 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/pending_extension_manager.h" | 23 #include "chrome/browser/extensions/pending_extension_manager.h" |
25 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
26 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
27 #include "components/omaha_query_params/omaha_query_params.h" | 26 #include "components/omaha_query_params/omaha_query_params.h" |
28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
30 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
31 #include "content/public/browser/notification_source.h" | 30 #include "content/public/browser/notification_source.h" |
32 #include "crypto/sha2.h" | 31 #include "crypto/sha2.h" |
33 #include "extensions/browser/extension_prefs.h" | 32 #include "extensions/browser/extension_prefs.h" |
34 #include "extensions/browser/extension_registry.h" | 33 #include "extensions/browser/extension_registry.h" |
35 #include "extensions/browser/pref_names.h" | 34 #include "extensions/browser/pref_names.h" |
36 #include "extensions/common/constants.h" | 35 #include "extensions/common/constants.h" |
37 #include "extensions/common/extension.h" | 36 #include "extensions/common/extension.h" |
38 #include "extensions/common/extension_set.h" | 37 #include "extensions/common/extension_set.h" |
39 #include "extensions/common/manifest.h" | 38 #include "extensions/common/manifest.h" |
39 #include "extensions/common/manifest_constants.h" | |
40 | 40 |
41 using base::RandDouble; | 41 using base::RandDouble; |
42 using base::RandInt; | 42 using base::RandInt; |
43 using base::Time; | 43 using base::Time; |
44 using base::TimeDelta; | 44 using base::TimeDelta; |
45 using content::BrowserThread; | 45 using content::BrowserThread; |
46 using extensions::Extension; | 46 using extensions::Extension; |
47 using extensions::ExtensionSet; | 47 using extensions::ExtensionSet; |
48 using omaha_query_params::OmahaQueryParams; | 48 using omaha_query_params::OmahaQueryParams; |
49 | 49 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); | 112 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
113 for (std::vector<scoped_refptr<const Extension> >::const_iterator iter = | 113 for (std::vector<scoped_refptr<const Extension> >::const_iterator iter = |
114 extensions->begin(); | 114 extensions->begin(); |
115 iter != extensions->end(); | 115 iter != extensions->end(); |
116 ++iter) { | 116 ++iter) { |
117 scoped_refptr<const Extension> extension = *iter; | 117 scoped_refptr<const Extension> extension = *iter; |
118 base::FilePath platform_specific_path = extension->path().Append( | 118 base::FilePath platform_specific_path = extension->path().Append( |
119 extensions::kPlatformSpecificFolder); | 119 extensions::kPlatformSpecificFolder); |
120 if (base::PathExists(platform_specific_path)) { | 120 if (base::PathExists(platform_specific_path)) { |
121 bool force = true; | 121 bool force = true; |
122 base::FileEnumerator all_archs(platform_specific_path, | 122 const base::ListValue* platforms; |
123 false, | 123 if (extension->manifest()->GetList(extensions::manifest_keys::kPlatforms, |
124 base::FileEnumerator::DIRECTORIES); | 124 &platforms)) { |
125 base::FilePath arch; | 125 for (size_t i = 0; i < platforms->GetSize(); ++i) { |
126 while (!(arch = all_archs.Next()).empty()) { | 126 const base::DictionaryValue* p; |
127 std::string arch_name = arch.BaseName().AsUTF8Unsafe(); | 127 if (platforms->GetDictionary(i, &p)) { |
128 std::replace(arch_name.begin(), arch_name.end(), '_', '-'); | 128 std::string nacl_arch; |
129 if (arch_name == OmahaQueryParams::GetNaclArch()) | 129 if (p->GetString(extensions::manifest_keys::kNaClArch, |
130 force = false; | 130 &nacl_arch) && |
131 nacl_arch == OmahaQueryParams::GetNaclArch()) { | |
132 std::string subpath; | |
133 if (p->GetString(extensions::manifest_keys::kSubPackagePath, | |
134 &subpath)) { | |
135 // _platform_specific is part of the sub_package_path entry. | |
136 base::FilePath platform_specific_subpath = | |
137 extension->path().Append(subpath); | |
Ken Rockot(use gerrit already)
2014/09/24 16:14:15
You want AppendASCII here
elijahtaylor1
2014/09/24 16:35:48
Done.
| |
138 if (base::PathExists(platform_specific_subpath)) { | |
139 force = false; | |
140 } | |
141 } | |
142 } | |
143 } | |
144 } | |
131 } | 145 } |
132 | 146 |
133 if (force) | 147 if (force) |
134 forced_updates->insert(extension->id()); | 148 forced_updates->insert(extension->id()); |
135 } | 149 } |
136 } | 150 } |
137 BrowserThread::PostTask( | 151 BrowserThread::PostTask( |
138 BrowserThread::UI, | 152 BrowserThread::UI, |
139 FROM_HERE, | 153 FROM_HERE, |
140 base::Bind(&RespondWithForcedUpdates, | 154 base::Bind(&RespondWithForcedUpdates, |
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
743 const InProgressCheck& request = requests_in_progress_[request_id]; | 757 const InProgressCheck& request = requests_in_progress_[request_id]; |
744 if (request.in_progress_ids_.empty()) { | 758 if (request.in_progress_ids_.empty()) { |
745 VLOG(2) << "Finished update check " << request_id; | 759 VLOG(2) << "Finished update check " << request_id; |
746 if (!request.callback.is_null()) | 760 if (!request.callback.is_null()) |
747 request.callback.Run(); | 761 request.callback.Run(); |
748 requests_in_progress_.erase(request_id); | 762 requests_in_progress_.erase(request_id); |
749 } | 763 } |
750 } | 764 } |
751 | 765 |
752 } // namespace extensions | 766 } // namespace extensions |
OLD | NEW |