OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |