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 "chrome/browser/extensions/pending_extension_manager.h" | 5 #include "chrome/browser/extensions/pending_extension_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
| 13 #include "extensions/browser/extension_prefs.h" |
13 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
15 | 16 |
16 using content::BrowserThread; | 17 using content::BrowserThread; |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 // Install predicate used by AddFromExternalUpdateUrl(). | 21 // Install predicate used by AddFromExternalUpdateUrl(). |
21 bool AlwaysInstall(const extensions::Extension* extension) { | 22 bool AlwaysInstall(const extensions::Extension* extension) { |
22 return true; | 23 return true; |
23 } | 24 } |
24 | 25 |
25 std::string GetVersionString(const Version& version) { | 26 std::string GetVersionString(const Version& version) { |
26 return version.IsValid() ? version.GetString() : "invalid"; | 27 return version.IsValid() ? version.GetString() : "invalid"; |
27 } | 28 } |
28 | 29 |
29 } // namespace | 30 } // namespace |
30 | 31 |
31 namespace extensions { | 32 namespace extensions { |
32 | 33 |
33 PendingExtensionManager::PendingExtensionManager( | 34 PendingExtensionManager::PendingExtensionManager( |
34 const ExtensionServiceInterface& service) | 35 const ExtensionServiceInterface& service, |
35 : service_(service) { | 36 content::BrowserContext* context) |
36 } | 37 : service_(service), context_(context) {} |
37 | 38 |
38 PendingExtensionManager::~PendingExtensionManager() {} | 39 PendingExtensionManager::~PendingExtensionManager() {} |
39 | 40 |
40 const PendingExtensionInfo* PendingExtensionManager::GetById( | 41 const PendingExtensionInfo* PendingExtensionManager::GetById( |
41 const std::string& id) const { | 42 const std::string& id) const { |
42 PendingExtensionList::const_iterator iter; | 43 PendingExtensionList::const_iterator iter; |
43 for (iter = pending_extension_list_.begin(); | 44 for (iter = pending_extension_list_.begin(); |
44 iter != pending_extension_list_.end(); | 45 iter != pending_extension_list_.end(); |
45 ++iter) { | 46 ++iter) { |
46 if (id == iter->id()) | 47 if (id == iter->id()) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 | 162 |
162 const bool kIsFromSync = false; | 163 const bool kIsFromSync = false; |
163 const bool kInstallSilently = true; | 164 const bool kInstallSilently = true; |
164 | 165 |
165 const Extension* extension = service_.GetInstalledExtension(id); | 166 const Extension* extension = service_.GetInstalledExtension(id); |
166 if (extension && location == Manifest::GetHigherPriorityLocation( | 167 if (extension && location == Manifest::GetHigherPriorityLocation( |
167 location, extension->location())) { | 168 location, extension->location())) { |
168 // If the new location has higher priority than the location of an existing | 169 // If the new location has higher priority than the location of an existing |
169 // extension, let the update process overwrite the existing extension. | 170 // extension, let the update process overwrite the existing extension. |
170 } else { | 171 } else { |
171 if (service_.IsExternalExtensionUninstalled(id)) | 172 if (ExtensionPrefs::Get(context_)->IsExternalExtensionUninstalled(id)) |
172 return false; | 173 return false; |
173 | 174 |
174 if (extension) { | 175 if (extension) { |
175 LOG(DFATAL) << "Trying to add extension " << id | 176 LOG(DFATAL) << "Trying to add extension " << id |
176 << " by external update, but it is already installed."; | 177 << " by external update, but it is already installed."; |
177 return false; | 178 return false; |
178 } | 179 } |
179 } | 180 } |
180 | 181 |
181 return AddExtensionImpl(id, | 182 return AddExtensionImpl(id, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 | 295 |
295 return true; | 296 return true; |
296 } | 297 } |
297 | 298 |
298 void PendingExtensionManager::AddForTesting( | 299 void PendingExtensionManager::AddForTesting( |
299 const PendingExtensionInfo& pending_extension_info) { | 300 const PendingExtensionInfo& pending_extension_info) { |
300 pending_extension_list_.push_back(pending_extension_info); | 301 pending_extension_list_.push_back(pending_extension_info); |
301 } | 302 } |
302 | 303 |
303 } // namespace extensions | 304 } // namespace extensions |
OLD | NEW |