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

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

Issue 406713002: Allow drag-and-drop of zipped extensions on chrome://extensions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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"
11 #include "base/strings/utf_string_conversions.h"
11 #include "base/threading/thread_restrictions.h" 12 #include "base/threading/thread_restrictions.h"
12 #include "chrome/browser/extensions/extension_error_reporter.h" 13 #include "chrome/browser/extensions/extension_error_reporter.h"
13 #include "chrome/browser/extensions/extension_install_prompt.h" 14 #include "chrome/browser/extensions/extension_install_prompt.h"
14 #include "chrome/browser/extensions/extension_install_ui.h" 15 #include "chrome/browser/extensions/extension_install_ui.h"
15 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
16 #include "chrome/browser/extensions/permissions_updater.h" 17 #include "chrome/browser/extensions/permissions_updater.h"
17 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 19 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
19 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
20 #include "extensions/browser/extension_prefs.h" 21 #include "extensions/browser/extension_prefs.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 ReportExtensionLoadError(error); 158 ReportExtensionLoadError(error);
158 return false; 159 return false;
159 } 160 }
160 161
161 ShowInstallPrompt(); 162 ShowInstallPrompt();
162 163
163 *extension_id = extension()->id(); 164 *extension_id = extension()->id();
164 return true; 165 return true;
165 } 166 }
166 167
168 void UnpackedInstaller::LoadFromZipFile(const base::FilePath& zip_path) {
169 scoped_refptr<SandboxedUnpacker> unpacker(new SandboxedUnpacker(
170 zip_path,
171 Manifest::UNPACKED,
172 0,
173 base::FilePath(),
174 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE).get(),
175 this));
176
177 BrowserThread::PostTask(
178 BrowserThread::FILE,
179 FROM_HERE,
180 base::Bind(&SandboxedUnpacker::Start, unpacker.get()));
181 }
182
183 void UnpackedInstaller::OnUnpackSuccess(
184 const base::FilePath& temp_dir,
185 const base::FilePath& extension_root,
186 const base::DictionaryValue* original_manifest,
187 const Extension* extension,
188 const SkBitmap& install_icon) {
189 Load(extension_root);
190 }
191
192 void UnpackedInstaller::OnUnpackFailure(const base::string16& error) {
193 ReportExtensionLoadError(base::UTF16ToUTF8(error));
194 }
195
167 void UnpackedInstaller::ShowInstallPrompt() { 196 void UnpackedInstaller::ShowInstallPrompt() {
168 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 197 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
169 if (!service_weak_.get()) 198 if (!service_weak_.get())
170 return; 199 return;
171 200
172 const ExtensionSet& disabled_extensions = 201 const ExtensionSet& disabled_extensions =
173 ExtensionRegistry::Get(service_weak_->profile())->disabled_extensions(); 202 ExtensionRegistry::Get(service_weak_->profile())->disabled_extensions();
174 if (service_weak_->show_extensions_prompts() && prompt_for_plugins_ && 203 if (service_weak_->show_extensions_prompts() && prompt_for_plugins_ &&
175 PluginInfo::HasPlugins(extension()) && 204 PluginInfo::HasPlugins(extension()) &&
176 !disabled_extensions.Contains(extension()->id())) { 205 !disabled_extensions.Contains(extension()->id())) {
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 DCHECK_CURRENTLY_ON(BrowserThread::UI); 338 DCHECK_CURRENTLY_ON(BrowserThread::UI);
310 339
311 PermissionsUpdater perms_updater(service_weak_->profile()); 340 PermissionsUpdater perms_updater(service_weak_->profile());
312 perms_updater.GrantActivePermissions(extension()); 341 perms_updater.GrantActivePermissions(extension());
313 342
314 service_weak_->OnExtensionInstalled( 343 service_weak_->OnExtensionInstalled(
315 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately); 344 extension(), syncer::StringOrdinal(), kInstallFlagInstallImmediately);
316 } 345 }
317 346
318 } // namespace extensions 347 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698