| 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/common/extensions/extension_constants.h" | 11 #include "chrome/common/extensions/extension_constants.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/browser/extension_prefs.h" |
| 14 #include "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
| 15 #include "extensions/common/constants.h" | 15 #include "extensions/common/constants.h" |
| 16 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 17 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 18 | 18 |
| 19 using content::BrowserThread; | 19 using content::BrowserThread; |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 // Install predicate used by AddFromExternalUpdateUrl(). | 23 // Install predicate used by AddFromExternalUpdateUrl(). |
| 24 bool AlwaysInstall(const extensions::Extension* extension) { | 24 bool AlwaysInstall(const extensions::Extension* extension) { |
| 25 return true; | 25 return true; |
| 26 } | 26 } |
| 27 | 27 |
| 28 std::string GetVersionString(const Version& version) { | 28 std::string GetVersionString(const base::Version& version) { |
| 29 return version.IsValid() ? version.GetString() : "invalid"; | 29 return version.IsValid() ? version.GetString() : "invalid"; |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 namespace extensions { | 34 namespace extensions { |
| 35 | 35 |
| 36 PendingExtensionManager::PendingExtensionManager( | 36 PendingExtensionManager::PendingExtensionManager( |
| 37 content::BrowserContext* context) | 37 content::BrowserContext* context) |
| 38 : context_(context) {} | 38 : context_(context) {} |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 static const bool kIsFromSync = false; | 141 static const bool kIsFromSync = false; |
| 142 static const Manifest::Location kManifestLocation = Manifest::INTERNAL; | 142 static const Manifest::Location kManifestLocation = Manifest::INTERNAL; |
| 143 static const bool kMarkAcknowledged = false; | 143 static const bool kMarkAcknowledged = false; |
| 144 static const bool kRemoteInstall = false; | 144 static const bool kRemoteInstall = false; |
| 145 | 145 |
| 146 return AddExtensionImpl(id, | 146 return AddExtensionImpl(id, |
| 147 std::string(), | 147 std::string(), |
| 148 update_url, | 148 update_url, |
| 149 Version(), | 149 base::Version(), |
| 150 should_allow_install, | 150 should_allow_install, |
| 151 kIsFromSync, | 151 kIsFromSync, |
| 152 kManifestLocation, | 152 kManifestLocation, |
| 153 Extension::NO_FLAGS, | 153 Extension::NO_FLAGS, |
| 154 kMarkAcknowledged, | 154 kMarkAcknowledged, |
| 155 kRemoteInstall); | 155 kRemoteInstall); |
| 156 } | 156 } |
| 157 | 157 |
| 158 bool PendingExtensionManager::AddFromExternalUpdateUrl( | 158 bool PendingExtensionManager::AddFromExternalUpdateUrl( |
| 159 const std::string& id, | 159 const std::string& id, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 180 if (extension) { | 180 if (extension) { |
| 181 LOG(DFATAL) << "Trying to add extension " << id | 181 LOG(DFATAL) << "Trying to add extension " << id |
| 182 << " by external update, but it is already installed."; | 182 << " by external update, but it is already installed."; |
| 183 return false; | 183 return false; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 return AddExtensionImpl(id, | 187 return AddExtensionImpl(id, |
| 188 install_parameter, | 188 install_parameter, |
| 189 update_url, | 189 update_url, |
| 190 Version(), | 190 base::Version(), |
| 191 &AlwaysInstall, | 191 &AlwaysInstall, |
| 192 kIsFromSync, | 192 kIsFromSync, |
| 193 location, | 193 location, |
| 194 creation_flags, | 194 creation_flags, |
| 195 mark_acknowledged, | 195 mark_acknowledged, |
| 196 kRemoteInstall); | 196 kRemoteInstall); |
| 197 } | 197 } |
| 198 | 198 |
| 199 | 199 |
| 200 bool PendingExtensionManager::AddFromExternalFile( | 200 bool PendingExtensionManager::AddFromExternalFile( |
| 201 const std::string& id, | 201 const std::string& id, |
| 202 Manifest::Location install_source, | 202 Manifest::Location install_source, |
| 203 const Version& version, | 203 const base::Version& version, |
| 204 int creation_flags, | 204 int creation_flags, |
| 205 bool mark_acknowledged) { | 205 bool mark_acknowledged) { |
| 206 // TODO(skerner): AddFromSync() checks to see if the extension is | 206 // TODO(skerner): AddFromSync() checks to see if the extension is |
| 207 // installed, but this method assumes that the caller already | 207 // installed, but this method assumes that the caller already |
| 208 // made sure it is not installed. Make all AddFrom*() methods | 208 // made sure it is not installed. Make all AddFrom*() methods |
| 209 // consistent. | 209 // consistent. |
| 210 const GURL& kUpdateUrl = GURL::EmptyGURL(); | 210 const GURL& kUpdateUrl = GURL::EmptyGURL(); |
| 211 static const bool kIsFromSync = false; | 211 static const bool kIsFromSync = false; |
| 212 static const bool kRemoteInstall = false; | 212 static const bool kRemoteInstall = false; |
| 213 | 213 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 241 } | 241 } |
| 242 | 242 |
| 243 out_ids_for_update_check->push_back(iter->id()); | 243 out_ids_for_update_check->push_back(iter->id()); |
| 244 } | 244 } |
| 245 } | 245 } |
| 246 | 246 |
| 247 bool PendingExtensionManager::AddExtensionImpl( | 247 bool PendingExtensionManager::AddExtensionImpl( |
| 248 const std::string& id, | 248 const std::string& id, |
| 249 const std::string& install_parameter, | 249 const std::string& install_parameter, |
| 250 const GURL& update_url, | 250 const GURL& update_url, |
| 251 const Version& version, | 251 const base::Version& version, |
| 252 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, | 252 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
| 253 bool is_from_sync, | 253 bool is_from_sync, |
| 254 Manifest::Location install_source, | 254 Manifest::Location install_source, |
| 255 int creation_flags, | 255 int creation_flags, |
| 256 bool mark_acknowledged, | 256 bool mark_acknowledged, |
| 257 bool remote_install) { | 257 bool remote_install) { |
| 258 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 258 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 259 | 259 |
| 260 PendingExtensionInfo info(id, | 260 PendingExtensionInfo info(id, |
| 261 install_parameter, | 261 install_parameter, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 | 302 |
| 303 return true; | 303 return true; |
| 304 } | 304 } |
| 305 | 305 |
| 306 void PendingExtensionManager::AddForTesting( | 306 void PendingExtensionManager::AddForTesting( |
| 307 const PendingExtensionInfo& pending_extension_info) { | 307 const PendingExtensionInfo& pending_extension_info) { |
| 308 pending_extension_list_.push_back(pending_extension_info); | 308 pending_extension_list_.push_back(pending_extension_info); |
| 309 } | 309 } |
| 310 | 310 |
| 311 } // namespace extensions | 311 } // namespace extensions |
| OLD | NEW |