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

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

Issue 15987009: Update chrome/ to use WeakPtr<T>::get() instead of implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/unpacked_installer.h" 5 #include "chrome/browser/extensions/unpacked_installer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 BrowserThread::FILE, 111 BrowserThread::FILE,
112 FROM_HERE, 112 FROM_HERE,
113 base::Bind(&UnpackedInstaller::GetAbsolutePath, this)); 113 base::Bind(&UnpackedInstaller::GetAbsolutePath, this));
114 } 114 }
115 115
116 bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in, 116 bool UnpackedInstaller::LoadFromCommandLine(const base::FilePath& path_in,
117 std::string* extension_id) { 117 std::string* extension_id) {
118 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 118 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
119 DCHECK(extension_path_.empty()); 119 DCHECK(extension_path_.empty());
120 120
121 if (!service_weak_) 121 if (!service_weak_.get())
122 return false; 122 return false;
123 // Load extensions from the command line synchronously to avoid a race 123 // Load extensions from the command line synchronously to avoid a race
124 // between extension loading and loading an URL from the command line. 124 // between extension loading and loading an URL from the command line.
125 base::ThreadRestrictions::ScopedAllowIO allow_io; 125 base::ThreadRestrictions::ScopedAllowIO allow_io;
126 126
127 extension_path_ = base::MakeAbsoluteFilePath(path_in); 127 extension_path_ = base::MakeAbsoluteFilePath(path_in);
128 128
129 if (!IsLoadingUnpackedAllowed()) { 129 if (!IsLoadingUnpackedAllowed()) {
130 ReportExtensionLoadError(kUnpackedExtensionsBlacklistedError); 130 ReportExtensionLoadError(kUnpackedExtensionsBlacklistedError);
131 return false; 131 return false;
(...skipping 12 matching lines...) Expand all
144 } 144 }
145 145
146 ShowInstallPrompt(); 146 ShowInstallPrompt();
147 147
148 *extension_id = installer_.extension()->id(); 148 *extension_id = installer_.extension()->id();
149 return true; 149 return true;
150 } 150 }
151 151
152 void UnpackedInstaller::ShowInstallPrompt() { 152 void UnpackedInstaller::ShowInstallPrompt() {
153 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 153 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
154 if (!service_weak_) 154 if (!service_weak_.get())
155 return; 155 return;
156 156
157 const ExtensionSet* disabled_extensions = 157 const ExtensionSet* disabled_extensions =
158 service_weak_->disabled_extensions(); 158 service_weak_->disabled_extensions();
159 if (service_weak_->show_extensions_prompts() && 159 if (service_weak_->show_extensions_prompts() &&
160 prompt_for_plugins_ && 160 prompt_for_plugins_ &&
161 PluginInfo::HasPlugins(installer_.extension()) && 161 PluginInfo::HasPlugins(installer_.extension()) &&
162 !disabled_extensions->Contains(installer_.extension()->id())) { 162 !disabled_extensions->Contains(installer_.extension()->id())) {
163 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( 163 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
164 installer_.extension(), 164 installer_.extension(),
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 int result = Extension::FOLLOW_SYMLINKS_ANYWHERE; 198 int result = Extension::FOLLOW_SYMLINKS_ANYWHERE;
199 if (allow_file_access) 199 if (allow_file_access)
200 result |= Extension::ALLOW_FILE_ACCESS; 200 result |= Extension::ALLOW_FILE_ACCESS;
201 if (require_modern_manifest_version_) 201 if (require_modern_manifest_version_)
202 result |= Extension::REQUIRE_MODERN_MANIFEST_VERSION; 202 result |= Extension::REQUIRE_MODERN_MANIFEST_VERSION;
203 203
204 return result; 204 return result;
205 } 205 }
206 206
207 bool UnpackedInstaller::IsLoadingUnpackedAllowed() const { 207 bool UnpackedInstaller::IsLoadingUnpackedAllowed() const {
208 if (!service_weak_) 208 if (!service_weak_.get())
209 return true; 209 return true;
210 // If there is a "*" in the extension blacklist, then no extensions should be 210 // If there is a "*" in the extension blacklist, then no extensions should be
211 // allowed at all (except explicitly whitelisted extensions). 211 // allowed at all (except explicitly whitelisted extensions).
212 ExtensionPrefs* prefs = service_weak_->extension_prefs(); 212 ExtensionPrefs* prefs = service_weak_->extension_prefs();
213 return !prefs->ExtensionsBlacklistedByDefault(); 213 return !prefs->ExtensionsBlacklistedByDefault();
214 } 214 }
215 215
216 void UnpackedInstaller::GetAbsolutePath() { 216 void UnpackedInstaller::GetAbsolutePath() {
217 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 217 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
218 218
219 extension_path_ = base::MakeAbsoluteFilePath(extension_path_); 219 extension_path_ = base::MakeAbsoluteFilePath(extension_path_);
220 220
221 BrowserThread::PostTask( 221 BrowserThread::PostTask(
222 BrowserThread::UI, FROM_HERE, 222 BrowserThread::UI, FROM_HERE,
223 base::Bind(&UnpackedInstaller::CheckExtensionFileAccess, this)); 223 base::Bind(&UnpackedInstaller::CheckExtensionFileAccess, this));
224 } 224 }
225 225
226 void UnpackedInstaller::CheckExtensionFileAccess() { 226 void UnpackedInstaller::CheckExtensionFileAccess() {
227 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 227 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
228 if (!service_weak_) 228 if (!service_weak_.get())
229 return; 229 return;
230 230
231 if (!IsLoadingUnpackedAllowed()) { 231 if (!IsLoadingUnpackedAllowed()) {
232 ReportExtensionLoadError(kUnpackedExtensionsBlacklistedError); 232 ReportExtensionLoadError(kUnpackedExtensionsBlacklistedError);
233 return; 233 return;
234 } 234 }
235 235
236 BrowserThread::PostTask( 236 BrowserThread::PostTask(
237 BrowserThread::FILE, 237 BrowserThread::FILE,
238 FROM_HERE, 238 FROM_HERE,
(...skipping 19 matching lines...) Expand all
258 } 258 }
259 259
260 BrowserThread::PostTask( 260 BrowserThread::PostTask(
261 BrowserThread::UI, 261 BrowserThread::UI,
262 FROM_HERE, 262 FROM_HERE,
263 base::Bind(&UnpackedInstaller::ShowInstallPrompt, this)); 263 base::Bind(&UnpackedInstaller::ShowInstallPrompt, this));
264 } 264 }
265 265
266 void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) { 266 void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) {
267 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 267 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
268 if (!service_weak_) 268 if (!service_weak_.get())
269 return; 269 return;
270 service_weak_->ReportExtensionLoadError(extension_path_, error, true); 270 service_weak_->ReportExtensionLoadError(extension_path_, error, true);
271 } 271 }
272 272
273 void UnpackedInstaller::ConfirmInstall() { 273 void UnpackedInstaller::ConfirmInstall() {
274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
275 string16 error = installer_.CheckManagementPolicy(); 275 string16 error = installer_.CheckManagementPolicy();
276 if (!error.empty()) { 276 if (!error.empty()) {
277 ReportExtensionLoadError(UTF16ToUTF8(error)); 277 ReportExtensionLoadError(UTF16ToUTF8(error));
278 return; 278 return;
279 } 279 }
280 280
281 PermissionsUpdater perms_updater(service_weak_->profile()); 281 PermissionsUpdater perms_updater(service_weak_->profile());
282 perms_updater.GrantActivePermissions(installer_.extension()); 282 perms_updater.GrantActivePermissions(installer_.extension());
283 283
284 service_weak_->OnExtensionInstalled( 284 service_weak_->OnExtensionInstalled(
285 installer_.extension(), 285 installer_.extension(),
286 syncer::StringOrdinal(), 286 syncer::StringOrdinal(),
287 false /* no requirement errors */, 287 false /* no requirement errors */,
288 false /* don't wait for idle */); 288 false /* don't wait for idle */);
289 } 289 }
290 290
291 } // namespace extensions 291 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/script_executor.cc ('k') | chrome/browser/extensions/user_script_listener.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698