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

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

Issue 1395043002: Remove ability for users to launch ephemeral apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
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 "base/version.h" 8 #include "base/version.h"
9 #include "chrome/browser/extensions/crx_installer.h" 9 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_install_prompt.h" 10 #include "chrome/browser/extensions/extension_install_prompt.h"
(...skipping 17 matching lines...) Expand all
28 namespace extensions { 28 namespace extensions {
29 29
30 const char kInvalidWebstoreItemId[] = "Invalid Chrome Web Store item ID"; 30 const char kInvalidWebstoreItemId[] = "Invalid Chrome Web Store item ID";
31 const char kWebstoreRequestError[] = 31 const char kWebstoreRequestError[] =
32 "Could not fetch data from the Chrome Web Store"; 32 "Could not fetch data from the Chrome Web Store";
33 const char kInvalidWebstoreResponseError[] = "Invalid Chrome Web Store reponse"; 33 const char kInvalidWebstoreResponseError[] = "Invalid Chrome Web Store reponse";
34 const char kInvalidManifestError[] = "Invalid manifest"; 34 const char kInvalidManifestError[] = "Invalid manifest";
35 const char kUserCancelledError[] = "User cancelled install"; 35 const char kUserCancelledError[] = "User cancelled install";
36 const char kExtensionIsBlacklisted[] = "Extension is blacklisted"; 36 const char kExtensionIsBlacklisted[] = "Extension is blacklisted";
37 const char kInstallInProgressError[] = "An install is already in progress"; 37 const char kInstallInProgressError[] = "An install is already in progress";
38 const char kLaunchInProgressError[] = "A launch is already in progress";
39 38
40 WebstoreStandaloneInstaller::WebstoreStandaloneInstaller( 39 WebstoreStandaloneInstaller::WebstoreStandaloneInstaller(
41 const std::string& webstore_item_id, 40 const std::string& webstore_item_id,
42 Profile* profile, 41 Profile* profile,
43 const Callback& callback) 42 const Callback& callback)
44 : id_(webstore_item_id), 43 : id_(webstore_item_id),
45 callback_(callback), 44 callback_(callback),
46 profile_(profile), 45 profile_(profile),
47 install_source_(WebstoreInstaller::INSTALL_SOURCE_INLINE), 46 install_source_(WebstoreInstaller::INSTALL_SOURCE_INLINE),
48 show_user_count_(true), 47 show_user_count_(true),
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 103
105 bool WebstoreStandaloneInstaller::EnsureUniqueInstall( 104 bool WebstoreStandaloneInstaller::EnsureUniqueInstall(
106 webstore_install::Result* reason, 105 webstore_install::Result* reason,
107 std::string* error) { 106 std::string* error) {
108 InstallTracker* tracker = InstallTracker::Get(profile_); 107 InstallTracker* tracker = InstallTracker::Get(profile_);
109 DCHECK(tracker); 108 DCHECK(tracker);
110 109
111 const ActiveInstallData* existing_install_data = 110 const ActiveInstallData* existing_install_data =
112 tracker->GetActiveInstall(id_); 111 tracker->GetActiveInstall(id_);
113 if (existing_install_data) { 112 if (existing_install_data) {
114 if (existing_install_data->is_ephemeral) { 113 *reason = webstore_install::INSTALL_IN_PROGRESS;
115 *reason = webstore_install::LAUNCH_IN_PROGRESS; 114 *error = kInstallInProgressError;
116 *error = kLaunchInProgressError;
117 } else {
118 *reason = webstore_install::INSTALL_IN_PROGRESS;
119 *error = kInstallInProgressError;
120 }
121 return false; 115 return false;
122 } 116 }
123 117
124 ActiveInstallData install_data(id_); 118 ActiveInstallData install_data(id_);
125 InitInstallData(&install_data); 119 InitInstallData(&install_data);
126 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data)); 120 scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data));
127 return true; 121 return true;
128 } 122 }
129 123
130 void WebstoreStandaloneInstaller::CompleteInstall( 124 void WebstoreStandaloneInstaller::CompleteInstall(
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 extension_service->GetExtensionById(id_, true /* include disabled */); 202 extension_service->GetExtensionById(id_, true /* include disabled */);
209 if (installed_extension) { 203 if (installed_extension) {
210 std::string install_message; 204 std::string install_message;
211 webstore_install::Result install_result = webstore_install::SUCCESS; 205 webstore_install::Result install_result = webstore_install::SUCCESS;
212 bool done = true; 206 bool done = true;
213 207
214 if (ExtensionPrefs::Get(profile_)->IsExtensionBlacklisted(id_)) { 208 if (ExtensionPrefs::Get(profile_)->IsExtensionBlacklisted(id_)) {
215 // Don't install a blacklisted extension. 209 // Don't install a blacklisted extension.
216 install_result = webstore_install::BLACKLISTED; 210 install_result = webstore_install::BLACKLISTED;
217 install_message = kExtensionIsBlacklisted; 211 install_message = kExtensionIsBlacklisted;
218 } else if (util::IsEphemeralApp(installed_extension->id(), profile_) && 212 } else if (util::IsEphemeralApp(installed_extension->id(), profile_)) {
219 !approval->is_ephemeral) {
220 // If the target extension has already been installed ephemerally and is 213 // If the target extension has already been installed ephemerally and is
221 // up to date, it can be promoted to a regular installed extension and 214 // up to date, it can be promoted to a regular installed extension and
222 // downloading from the Web Store is not necessary. 215 // downloading from the Web Store is not necessary.
223 scoped_refptr<const Extension> extension_to_install = 216 scoped_refptr<const Extension> extension_to_install =
224 GetLocalizedExtensionForDisplay(); 217 GetLocalizedExtensionForDisplay();
225 if (!extension_to_install.get()) { 218 if (!extension_to_install.get()) {
226 CompleteInstall(webstore_install::INVALID_MANIFEST, 219 CompleteInstall(webstore_install::INVALID_MANIFEST,
227 kInvalidManifestError); 220 kInvalidManifestError);
228 return; 221 return;
229 } 222 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() { 435 void WebstoreStandaloneInstaller::OnWebStoreDataFetcherDone() {
443 // An instance of this class is passed in as a delegate for the 436 // An instance of this class is passed in as a delegate for the
444 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and 437 // WebstoreInstallHelper, ExtensionInstallPrompt and WebstoreInstaller, and
445 // therefore needs to remain alive until they are done. Clear the webstore 438 // therefore needs to remain alive until they are done. Clear the webstore
446 // data fetcher to avoid calling Release in AbortInstall while any of these 439 // data fetcher to avoid calling Release in AbortInstall while any of these
447 // operations are in progress. 440 // operations are in progress.
448 webstore_data_fetcher_.reset(); 441 webstore_data_fetcher_.reset();
449 } 442 }
450 443
451 } // namespace extensions 444 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/webstore_installer.cc ('k') | chrome/browser/ui/app_list/extension_app_model_builder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698