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

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

Issue 15984016: Call scoped_refptr<T>::get() rather than relying on implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased 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/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
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;
132 } 132 }
133 133
134 std::string error; 134 std::string error;
135 installer_.set_extension(extension_file_util::LoadExtension( 135 installer_.set_extension(extension_file_util::LoadExtension(
136 extension_path_, 136 extension_path_, Manifest::COMMAND_LINE, GetFlags(), &error).get());
137 Manifest::COMMAND_LINE,
138 GetFlags(),
139 &error));
140 137
141 if (!installer_.extension()) { 138 if (!installer_.extension().get()) {
142 ReportExtensionLoadError(error); 139 ReportExtensionLoadError(error);
143 return false; 140 return false;
144 } 141 }
145 142
146 ShowInstallPrompt(); 143 ShowInstallPrompt();
147 144
148 *extension_id = installer_.extension()->id(); 145 *extension_id = installer_.extension()->id();
149 return true; 146 return true;
150 } 147 }
151 148
152 void UnpackedInstaller::ShowInstallPrompt() { 149 void UnpackedInstaller::ShowInstallPrompt() {
153 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 150 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
154 if (!service_weak_.get()) 151 if (!service_weak_.get())
155 return; 152 return;
156 153
157 const ExtensionSet* disabled_extensions = 154 const ExtensionSet* disabled_extensions =
158 service_weak_->disabled_extensions(); 155 service_weak_->disabled_extensions();
159 if (service_weak_->show_extensions_prompts() && 156 if (service_weak_->show_extensions_prompts() && prompt_for_plugins_ &&
160 prompt_for_plugins_ && 157 PluginInfo::HasPlugins(installer_.extension().get()) &&
161 PluginInfo::HasPlugins(installer_.extension()) &&
162 !disabled_extensions->Contains(installer_.extension()->id())) { 158 !disabled_extensions->Contains(installer_.extension()->id())) {
163 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt( 159 SimpleExtensionLoadPrompt* prompt = new SimpleExtensionLoadPrompt(
164 installer_.extension(), 160 installer_.extension().get(),
165 installer_.profile(), 161 installer_.profile(),
166 base::Bind(&UnpackedInstaller::CallCheckRequirements, this)); 162 base::Bind(&UnpackedInstaller::CallCheckRequirements, this));
167 prompt->ShowPrompt(); 163 prompt->ShowPrompt();
168 return; 164 return;
169 } 165 }
170 CallCheckRequirements(); 166 CallCheckRequirements();
171 } 167 }
172 168
173 void UnpackedInstaller::CallCheckRequirements() { 169 void UnpackedInstaller::CallCheckRequirements() {
174 installer_.CheckRequirements( 170 installer_.CheckRequirements(
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 BrowserThread::FILE, 233 BrowserThread::FILE,
238 FROM_HERE, 234 FROM_HERE,
239 base::Bind(&UnpackedInstaller::LoadWithFileAccess, this, GetFlags())); 235 base::Bind(&UnpackedInstaller::LoadWithFileAccess, this, GetFlags()));
240 } 236 }
241 237
242 void UnpackedInstaller::LoadWithFileAccess(int flags) { 238 void UnpackedInstaller::LoadWithFileAccess(int flags) {
243 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 239 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
244 240
245 std::string error; 241 std::string error;
246 installer_.set_extension(extension_file_util::LoadExtension( 242 installer_.set_extension(extension_file_util::LoadExtension(
247 extension_path_, 243 extension_path_, Manifest::UNPACKED, flags, &error).get());
248 Manifest::UNPACKED,
249 flags,
250 &error));
251 244
252 if (!installer_.extension()) { 245 if (!installer_.extension().get()) {
253 BrowserThread::PostTask( 246 BrowserThread::PostTask(
254 BrowserThread::UI, 247 BrowserThread::UI,
255 FROM_HERE, 248 FROM_HERE,
256 base::Bind(&UnpackedInstaller::ReportExtensionLoadError, this, error)); 249 base::Bind(&UnpackedInstaller::ReportExtensionLoadError, this, error));
257 return; 250 return;
258 } 251 }
259 252
260 BrowserThread::PostTask( 253 BrowserThread::PostTask(
261 BrowserThread::UI, 254 BrowserThread::UI,
262 FROM_HERE, 255 FROM_HERE,
263 base::Bind(&UnpackedInstaller::ShowInstallPrompt, this)); 256 base::Bind(&UnpackedInstaller::ShowInstallPrompt, this));
264 } 257 }
265 258
266 void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) { 259 void UnpackedInstaller::ReportExtensionLoadError(const std::string &error) {
267 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 260 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
268 if (!service_weak_.get()) 261 if (!service_weak_.get())
269 return; 262 return;
270 service_weak_->ReportExtensionLoadError(extension_path_, error, true); 263 service_weak_->ReportExtensionLoadError(extension_path_, error, true);
271 } 264 }
272 265
273 void UnpackedInstaller::ConfirmInstall() { 266 void UnpackedInstaller::ConfirmInstall() {
274 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 267 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
275 string16 error = installer_.CheckManagementPolicy(); 268 string16 error = installer_.CheckManagementPolicy();
276 if (!error.empty()) { 269 if (!error.empty()) {
277 ReportExtensionLoadError(UTF16ToUTF8(error)); 270 ReportExtensionLoadError(UTF16ToUTF8(error));
278 return; 271 return;
279 } 272 }
280 273
281 PermissionsUpdater perms_updater(service_weak_->profile()); 274 PermissionsUpdater perms_updater(service_weak_->profile());
282 perms_updater.GrantActivePermissions(installer_.extension()); 275 perms_updater.GrantActivePermissions(installer_.extension().get());
283 276
284 service_weak_->OnExtensionInstalled( 277 service_weak_->OnExtensionInstalled(installer_.extension().get(),
285 installer_.extension(), 278 syncer::StringOrdinal(),
286 syncer::StringOrdinal(), 279 false /* no requirement errors */,
287 false /* no requirement errors */, 280 false /* don't wait for idle */);
288 false /* don't wait for idle */);
289 } 281 }
290 282
291 } // namespace extensions 283 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/tab_helper.cc ('k') | chrome/browser/extensions/updater/extension_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698