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

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

Issue 297263003: Optimize promotion of ephemeral apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 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
« no previous file with comments | « chrome/browser/extensions/webstore_installer.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/webstore_standalone_installer.h" 5 #include "chrome/browser/extensions/webstore_standalone_installer.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/crx_installer.h" 8 #include "chrome/browser/extensions/crx_installer.h"
9 #include "chrome/browser/extensions/extension_install_prompt.h" 9 #include "chrome/browser/extensions/extension_install_prompt.h"
10 #include "chrome/browser/extensions/extension_install_ui.h" 10 #include "chrome/browser/extensions/extension_install_ui.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/webstore_data_fetcher.h" 12 #include "chrome/browser/extensions/webstore_data_fetcher.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "extensions/browser/extension_prefs.h" 15 #include "extensions/browser/extension_prefs.h"
16 #include "extensions/browser/extension_registry.h"
16 #include "extensions/browser/extension_system.h" 17 #include "extensions/browser/extension_system.h"
17 #include "extensions/browser/extension_util.h" 18 #include "extensions/browser/extension_util.h"
18 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
19 #include "url/gurl.h" 20 #include "url/gurl.h"
20 21
21 using content::WebContents; 22 using content::WebContents;
22 23
23 namespace extensions { 24 namespace extensions {
24 25
25 const char kInvalidWebstoreItemId[] = "Invalid Chrome Web Store item ID"; 26 const char kInvalidWebstoreItemId[] = "Invalid Chrome Web Store item ID";
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 const std::string& error_message) { 225 const std::string& error_message) {
225 CompleteInstall(error_message); 226 CompleteInstall(error_message);
226 } 227 }
227 228
228 void WebstoreStandaloneInstaller::InstallUIProceed() { 229 void WebstoreStandaloneInstaller::InstallUIProceed() {
229 if (!CheckRequestorAlive()) { 230 if (!CheckRequestorAlive()) {
230 CompleteInstall(std::string()); 231 CompleteInstall(std::string());
231 return; 232 return;
232 } 233 }
233 234
235 scoped_ptr<WebstoreInstaller::Approval> approval = CreateApproval();
236
234 ExtensionService* extension_service = 237 ExtensionService* extension_service =
235 ExtensionSystem::Get(profile_)->extension_service(); 238 ExtensionSystem::Get(profile_)->extension_service();
236 const Extension* extension = 239 const Extension* extension =
237 extension_service->GetExtensionById(id_, true /* include disabled */); 240 extension_service->GetExtensionById(id_, true /* include disabled */);
238 if (extension) { 241 if (extension) {
239 std::string install_result; // Empty string for install success. 242 std::string install_result; // Empty string for install success.
240 if (!extension_service->IsExtensionEnabled(id_)) {
241 if (!ExtensionPrefs::Get(profile_)->IsExtensionBlacklisted(id_)) {
242 // If the extension is installed but disabled, and not blacklisted,
243 // enable it.
244 extension_service->EnableExtension(id_);
245 } else { // Don't install a blacklisted extension.
246 install_result = kExtensionIsBlacklisted;
247 }
248 } else if (!util::IsEphemeralApp(extension->id(), profile_)) {
249 // else extension is installed and enabled; no work to be done.
250 CompleteInstall(install_result);
251 return;
252 }
253 243
254 // TODO(tmdiep): Optimize installation of ephemeral apps. For now we just 244 if (ExtensionPrefs::Get(profile_)->IsExtensionBlacklisted(id_)) {
255 // reinstall the app. 245 // Don't install a blacklisted extension.
246 install_result = kExtensionIsBlacklisted;
247 } else if (util::IsEphemeralApp(extension->id(), profile_) &&
248 !approval->is_ephemeral) {
249 // If the target extension has already been installed ephemerally, it can
250 // be promoted to a regular installed extension and downloading from the
251 // Web Store is not necessary.
252 extension_service->PromoteEphemeralApp(extension, false);
253 } else if (!extension_service->IsExtensionEnabled(id_)) {
254 // If the extension is installed but disabled, and not blacklisted,
255 // enable it.
256 extension_service->EnableExtension(id_);
257 } // else extension is installed and enabled; no work to be done.
258
259 CompleteInstall(install_result);
260 return;
256 } 261 }
257 262
258 scoped_ptr<WebstoreInstaller::Approval> approval = CreateApproval();
259
260 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( 263 scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller(
261 profile_, 264 profile_,
262 this, 265 this,
263 GetWebContents(), 266 GetWebContents(),
264 id_, 267 id_,
265 approval.Pass(), 268 approval.Pass(),
266 install_source_); 269 install_source_);
267 installer->Start(); 270 installer->Start();
268 } 271 }
269 272
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 // Balanced in InstallUIAbort or indirectly in InstallUIProceed via 330 // Balanced in InstallUIAbort or indirectly in InstallUIProceed via
328 // OnExtensionInstallSuccess or OnExtensionInstallFailure. 331 // OnExtensionInstallSuccess or OnExtensionInstallFailure.
329 AddRef(); 332 AddRef();
330 333
331 install_ui_ = CreateInstallUI(); 334 install_ui_ = CreateInstallUI();
332 install_ui_->ConfirmStandaloneInstall( 335 install_ui_->ConfirmStandaloneInstall(
333 this, localized_extension_for_display_.get(), &icon_, *install_prompt_); 336 this, localized_extension_for_display_.get(), &icon_, *install_prompt_);
334 } 337 }
335 338
336 } // namespace extensions 339 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_installer.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698