| 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" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } | 83 } |
| 84 | 84 |
| 85 return false; | 85 return false; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool PendingExtensionManager::AddFromSync( | 88 bool PendingExtensionManager::AddFromSync( |
| 89 const std::string& id, | 89 const std::string& id, |
| 90 const GURL& update_url, | 90 const GURL& update_url, |
| 91 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, | 91 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, |
| 92 bool install_silently, | 92 bool install_silently, |
| 93 bool remote_install) { | 93 bool remote_install, |
| 94 bool installed_by_custodian) { |
| 94 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 95 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 95 | 96 |
| 96 if (ExtensionRegistry::Get(context_)->GetExtensionById( | 97 if (ExtensionRegistry::Get(context_)->GetExtensionById( |
| 97 id, ExtensionRegistry::EVERYTHING)) { | 98 id, ExtensionRegistry::EVERYTHING)) { |
| 98 LOG(ERROR) << "Trying to add pending extension " << id | 99 LOG(ERROR) << "Trying to add pending extension " << id |
| 99 << " which already exists"; | 100 << " which already exists"; |
| 100 return false; | 101 return false; |
| 101 } | 102 } |
| 102 | 103 |
| 103 // Make sure we don't ever try to install the CWS app, because even though | 104 // Make sure we don't ever try to install the CWS app, because even though |
| 104 // it is listed as a syncable app (because its values need to be synced) it | 105 // it is listed as a syncable app (because its values need to be synced) it |
| 105 // should already be installed on every instance. | 106 // should already be installed on every instance. |
| 106 if (id == extension_misc::kWebStoreAppId) { | 107 if (id == extension_misc::kWebStoreAppId) { |
| 107 NOTREACHED(); | 108 NOTREACHED(); |
| 108 return false; | 109 return false; |
| 109 } | 110 } |
| 110 | 111 |
| 112 int creation_flags = Extension::NO_FLAGS; |
| 113 if (installed_by_custodian) { |
| 114 creation_flags |= Extension::WAS_INSTALLED_BY_CUSTODIAN; |
| 115 } |
| 116 |
| 111 static const bool kIsFromSync = true; | 117 static const bool kIsFromSync = true; |
| 112 static const Manifest::Location kSyncLocation = Manifest::INTERNAL; | 118 static const Manifest::Location kSyncLocation = Manifest::INTERNAL; |
| 113 static const bool kMarkAcknowledged = false; | 119 static const bool kMarkAcknowledged = false; |
| 114 | 120 |
| 115 return AddExtensionImpl(id, | 121 return AddExtensionImpl(id, |
| 116 std::string(), | 122 std::string(), |
| 117 update_url, | 123 update_url, |
| 118 Version(), | 124 Version(), |
| 119 should_allow_install, | 125 should_allow_install, |
| 120 kIsFromSync, | 126 kIsFromSync, |
| 121 install_silently, | 127 install_silently, |
| 122 kSyncLocation, | 128 kSyncLocation, |
| 123 Extension::NO_FLAGS, | 129 creation_flags, |
| 124 kMarkAcknowledged, | 130 kMarkAcknowledged, |
| 125 remote_install); | 131 remote_install); |
| 126 } | 132 } |
| 127 | 133 |
| 128 bool PendingExtensionManager::AddFromExtensionImport( | 134 bool PendingExtensionManager::AddFromExtensionImport( |
| 129 const std::string& id, | 135 const std::string& id, |
| 130 const GURL& update_url, | 136 const GURL& update_url, |
| 131 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { | 137 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { |
| 132 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 138 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 133 | 139 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 314 |
| 309 return true; | 315 return true; |
| 310 } | 316 } |
| 311 | 317 |
| 312 void PendingExtensionManager::AddForTesting( | 318 void PendingExtensionManager::AddForTesting( |
| 313 const PendingExtensionInfo& pending_extension_info) { | 319 const PendingExtensionInfo& pending_extension_info) { |
| 314 pending_extension_list_.push_back(pending_extension_info); | 320 pending_extension_list_.push_back(pending_extension_info); |
| 315 } | 321 } |
| 316 | 322 |
| 317 } // namespace extensions | 323 } // namespace extensions |
| OLD | NEW |