Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/browser/extensions/pending_extension_manager.cc

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 // Make sure we don't ever try to install the CWS app, because even though 107 // Make sure we don't ever try to install the CWS app, because even though
108 // it is listed as a syncable app (because its values need to be synced) it 108 // it is listed as a syncable app (because its values need to be synced) it
109 // should already be installed on every instance. 109 // should already be installed on every instance.
110 if (id == extension_misc::kWebStoreAppId) { 110 if (id == extension_misc::kWebStoreAppId) {
111 NOTREACHED(); 111 NOTREACHED();
112 return false; 112 return false;
113 } 113 }
114 114
115 const bool kIsFromSync = true; 115 const bool kIsFromSync = true;
116 const Extension::Location kSyncLocation = Extension::INTERNAL; 116 const Manifest::Location kSyncLocation = Manifest::INTERNAL;
117 117
118 return AddExtensionImpl(id, update_url, Version(), should_allow_install, 118 return AddExtensionImpl(id, update_url, Version(), should_allow_install,
119 kIsFromSync, install_silently, kSyncLocation); 119 kIsFromSync, install_silently, kSyncLocation);
120 } 120 }
121 121
122 bool PendingExtensionManager::AddFromExternalUpdateUrl( 122 bool PendingExtensionManager::AddFromExternalUpdateUrl(
123 const std::string& id, 123 const std::string& id,
124 const GURL& update_url, 124 const GURL& update_url,
125 Extension::Location location) { 125 Manifest::Location location) {
126 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 126 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
127 127
128 const bool kIsFromSync = false; 128 const bool kIsFromSync = false;
129 const bool kInstallSilently = true; 129 const bool kInstallSilently = true;
130 130
131 const Extension* extension = service_.GetInstalledExtension(id); 131 const Extension* extension = service_.GetInstalledExtension(id);
132 if (extension && 132 if (extension &&
133 location == Extension::GetHigherPriorityLocation(location, 133 location == Manifest::GetHigherPriorityLocation(location,
134 extension->location())) { 134 extension->location())) {
135 // If the new location has higher priority than the location of an existing 135 // If the new location has higher priority than the location of an existing
136 // extension, let the update process overwrite the existing extension. 136 // extension, let the update process overwrite the existing extension.
137 } else { 137 } else {
138 if (service_.IsExternalExtensionUninstalled(id)) 138 if (service_.IsExternalExtensionUninstalled(id))
139 return false; 139 return false;
140 140
141 if (extension) { 141 if (extension) {
142 LOG(DFATAL) << "Trying to add extension " << id 142 LOG(DFATAL) << "Trying to add extension " << id
143 << " by external update, but it is already installed."; 143 << " by external update, but it is already installed.";
144 return false; 144 return false;
145 } 145 }
146 } 146 }
147 147
148 return AddExtensionImpl(id, update_url, Version(), &AlwaysInstall, 148 return AddExtensionImpl(id, update_url, Version(), &AlwaysInstall,
149 kIsFromSync, kInstallSilently, 149 kIsFromSync, kInstallSilently,
150 location); 150 location);
151 } 151 }
152 152
153 153
154 bool PendingExtensionManager::AddFromExternalFile( 154 bool PendingExtensionManager::AddFromExternalFile(
155 const std::string& id, 155 const std::string& id,
156 Extension::Location install_source, 156 Manifest::Location install_source,
157 const Version& version) { 157 const Version& version) {
158 // TODO(skerner): AddFromSync() checks to see if the extension is 158 // TODO(skerner): AddFromSync() checks to see if the extension is
159 // installed, but this method assumes that the caller already 159 // installed, but this method assumes that the caller already
160 // made sure it is not installed. Make all AddFrom*() methods 160 // made sure it is not installed. Make all AddFrom*() methods
161 // consistent. 161 // consistent.
162 GURL kUpdateUrl = GURL(); 162 GURL kUpdateUrl = GURL();
163 bool kIsFromSync = false; 163 bool kIsFromSync = false;
164 bool kInstallSilently = true; 164 bool kInstallSilently = true;
165 165
166 return AddExtensionImpl( 166 return AddExtensionImpl(
167 id, 167 id,
168 kUpdateUrl, 168 kUpdateUrl,
169 version, 169 version,
170 &AlwaysInstall, 170 &AlwaysInstall,
171 kIsFromSync, 171 kIsFromSync,
172 kInstallSilently, 172 kInstallSilently,
173 install_source); 173 install_source);
174 } 174 }
175 175
176 void PendingExtensionManager::GetPendingIdsForUpdateCheck( 176 void PendingExtensionManager::GetPendingIdsForUpdateCheck(
177 std::list<std::string>* out_ids_for_update_check) const { 177 std::list<std::string>* out_ids_for_update_check) const {
178 PendingExtensionList::const_iterator iter; 178 PendingExtensionList::const_iterator iter;
179 for (iter = pending_extension_list_.begin(); 179 for (iter = pending_extension_list_.begin();
180 iter != pending_extension_list_.end(); 180 iter != pending_extension_list_.end();
181 ++iter) { 181 ++iter) {
182 Extension::Location install_source = iter->install_source(); 182 Manifest::Location install_source = iter->install_source();
183 183
184 // Some install sources read a CRX from the filesystem. They can 184 // Some install sources read a CRX from the filesystem. They can
185 // not be fetched from an update URL, so don't include them in the 185 // not be fetched from an update URL, so don't include them in the
186 // set of ids. 186 // set of ids.
187 if (install_source == Extension::EXTERNAL_PREF || 187 if (install_source == Manifest::EXTERNAL_PREF ||
188 install_source == Extension::EXTERNAL_REGISTRY) 188 install_source == Manifest::EXTERNAL_REGISTRY)
189 continue; 189 continue;
190 190
191 out_ids_for_update_check->push_back(iter->id()); 191 out_ids_for_update_check->push_back(iter->id());
192 } 192 }
193 } 193 }
194 194
195 bool PendingExtensionManager::AddExtensionImpl( 195 bool PendingExtensionManager::AddExtensionImpl(
196 const std::string& id, 196 const std::string& id,
197 const GURL& update_url, 197 const GURL& update_url,
198 const Version& version, 198 const Version& version,
199 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install, 199 PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install,
200 bool is_from_sync, 200 bool is_from_sync,
201 bool install_silently, 201 bool install_silently,
202 Extension::Location install_source) { 202 Manifest::Location install_source) {
203 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 203 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
204 204
205 PendingExtensionInfo info(id, 205 PendingExtensionInfo info(id,
206 update_url, 206 update_url,
207 version, 207 version,
208 should_allow_install, 208 should_allow_install,
209 is_from_sync, 209 is_from_sync,
210 install_silently, 210 install_silently,
211 install_source); 211 install_source);
212 212
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 244
245 return true; 245 return true;
246 } 246 }
247 247
248 void PendingExtensionManager::AddForTesting( 248 void PendingExtensionManager::AddForTesting(
249 const PendingExtensionInfo& pending_extension_info) { 249 const PendingExtensionInfo& pending_extension_info) {
250 pending_extension_list_.push_back(pending_extension_info); 250 pending_extension_list_.push_back(pending_extension_info);
251 } 251 }
252 252
253 } // namespace extensions 253 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/pending_extension_manager.h ('k') | chrome/browser/extensions/permissions_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698