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 "base/logging.h" | 5 #include "base/logging.h" |
6 #include "base/stl_util.h" | 6 #include "base/stl_util.h" |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/extensions/pending_extension_manager.h" | 8 #include "chrome/browser/extensions/pending_extension_manager.h" |
9 #include "chrome/common/extensions/extension.h" | 9 #include "chrome/common/extensions/extension.h" |
10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 | 68 |
69 void PendingExtensionManager::AddFromExternalUpdateUrl( | 69 void PendingExtensionManager::AddFromExternalUpdateUrl( |
70 const std::string& id, const GURL& update_url, | 70 const std::string& id, const GURL& update_url, |
71 Extension::Location location) { | 71 Extension::Location location) { |
72 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 72 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
73 | 73 |
74 const bool kIsFromSync = false; | 74 const bool kIsFromSync = false; |
75 const bool kInstallSilently = true; | 75 const bool kInstallSilently = true; |
76 | 76 |
77 if (service_.IsExternalExtensionUninstalled(id)) | 77 const Extension* extension = service_.GetInstalledExtension(id); |
78 return; | 78 if (extension && |
79 | 79 location == Extension::GetHigherPriorityLocation(location, |
80 if (service_.GetInstalledExtension(id)) { | 80 extension->location())) { |
81 LOG(DFATAL) << "Trying to add extension " << id | 81 // If the new location has higher priority than the location of an existing |
82 << " by external update, but it is already installed."; | 82 // extension, let the update process overwrite the existing extension. |
83 return; | 83 } else { |
| 84 if (service_.IsExternalExtensionUninstalled(id)) { |
| 85 return; |
| 86 } |
| 87 if (extension) { |
| 88 LOG(DFATAL) << "Trying to add extension " << id |
| 89 << " by external update, but it is already installed."; |
| 90 return; |
| 91 } |
84 } | 92 } |
85 | 93 |
86 AddExtensionImpl(id, update_url, &AlwaysInstall, | 94 AddExtensionImpl(id, update_url, &AlwaysInstall, |
87 kIsFromSync, kInstallSilently, | 95 kIsFromSync, kInstallSilently, |
88 location); | 96 location); |
89 } | 97 } |
90 | 98 |
91 | 99 |
92 void PendingExtensionManager::AddFromExternalFile( | 100 void PendingExtensionManager::AddFromExternalFile( |
93 const std::string& id, | 101 const std::string& id, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 return true; | 157 return true; |
150 } | 158 } |
151 return false; | 159 return false; |
152 } | 160 } |
153 | 161 |
154 void PendingExtensionManager::AddForTesting( | 162 void PendingExtensionManager::AddForTesting( |
155 const std::string& id, | 163 const std::string& id, |
156 const PendingExtensionInfo& pending_extension_info) { | 164 const PendingExtensionInfo& pending_extension_info) { |
157 pending_extension_map_[id] = pending_extension_info; | 165 pending_extension_map_[id] = pending_extension_info; |
158 } | 166 } |
OLD | NEW |