[email protected] | bdb74a2 | 2012-01-25 20:33:33 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 5 | #include "chrome/browser/extensions/webstore_standalone_installer.h" |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 6 | |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 7 | #include "base/values.h" |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 8 | #include "chrome/browser/extensions/crx_installer.h" |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 9 | #include "chrome/browser/extensions/extension_install_prompt.h" |
[email protected] | 00b3824 | 2012-07-18 18:43:22 | [diff] [blame] | 10 | #include "chrome/browser/extensions/extension_install_ui.h" |
[email protected] | 655b2b1a | 2011-10-13 17:13:06 | [diff] [blame] | 11 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | 7b394105 | 2013-02-13 01:21:59 | [diff] [blame] | 12 | #include "chrome/browser/extensions/webstore_data_fetcher.h" |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 13 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 14 | #include "chrome/common/extensions/extension.h" |
[email protected] | 10c2d69 | 2012-05-11 05:32:23 | [diff] [blame] | 15 | #include "content/public/browser/web_contents.h" |
[email protected] | a6483d2 | 2013-07-03 22:11:00 | [diff] [blame] | 16 | #include "url/gurl.h" |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 17 | |
[email protected] | 26b5e32 | 2011-12-23 01:36:47 | [diff] [blame] | 18 | using content::WebContents; |
[email protected] | 631bb74 | 2011-11-02 11:29:39 | [diff] [blame] | 19 | |
[email protected] | 3d61a7f | 2012-07-12 19:11:25 | [diff] [blame] | 20 | namespace extensions { |
| 21 | |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 22 | const char kManifestKey[] = "manifest"; |
| 23 | const char kIconUrlKey[] = "icon_url"; |
| 24 | const char kLocalizedNameKey[] = "localized_name"; |
[email protected] | 5fdbd6f | 2011-09-01 17:33:04 | [diff] [blame] | 25 | const char kLocalizedDescriptionKey[] = "localized_description"; |
| 26 | const char kUsersKey[] = "users"; |
[email protected] | dcde34b3 | 2013-07-31 02:28:45 | [diff] [blame] | 27 | const char kShowUserCountKey[] = "show_user_count"; |
[email protected] | 5fdbd6f | 2011-09-01 17:33:04 | [diff] [blame] | 28 | const char kAverageRatingKey[] = "average_rating"; |
| 29 | const char kRatingCountKey[] = "rating_count"; |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 30 | |
[email protected] | a221ef09 | 2011-09-07 01:34:10 | [diff] [blame] | 31 | const char kInvalidWebstoreItemId[] = "Invalid Chrome Web Store item ID"; |
| 32 | const char kWebstoreRequestError[] = |
| 33 | "Could not fetch data from the Chrome Web Store"; |
| 34 | const char kInvalidWebstoreResponseError[] = "Invalid Chrome Web Store reponse"; |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 35 | const char kInvalidManifestError[] = "Invalid manifest"; |
| 36 | const char kUserCancelledError[] = "User cancelled install"; |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 37 | |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 38 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 39 | WebstoreStandaloneInstaller::WebstoreStandaloneInstaller( |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 40 | const std::string& webstore_item_id, |
[email protected] | c1b2d04 | 2013-02-23 00:31:04 | [diff] [blame] | 41 | Profile* profile, |
[email protected] | c1b2d04 | 2013-02-23 00:31:04 | [diff] [blame] | 42 | const Callback& callback) |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 43 | : id_(webstore_item_id), |
[email protected] | d2a639e | 2012-09-17 07:41:21 | [diff] [blame] | 44 | callback_(callback), |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 45 | profile_(profile), |
[email protected] | 084e3548 | 2013-09-25 02:46:19 | [diff] [blame] | 46 | install_source_(WebstoreInstaller::INSTALL_SOURCE_INLINE), |
[email protected] | dcde34b3 | 2013-07-31 02:28:45 | [diff] [blame] | 47 | show_user_count_(true), |
[email protected] | c7bf745 | 2011-09-12 21:31:50 | [diff] [blame] | 48 | average_rating_(0.0), |
[email protected] | 5f2a475 | 2012-04-27 22:18:58 | [diff] [blame] | 49 | rating_count_(0) { |
[email protected] | c1b2d04 | 2013-02-23 00:31:04 | [diff] [blame] | 50 | CHECK(!callback_.is_null()); |
| 51 | } |
| 52 | |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 53 | WebstoreStandaloneInstaller::~WebstoreStandaloneInstaller() {} |
| 54 | |
| 55 | // |
| 56 | // Private interface implementation. |
| 57 | // |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 58 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 59 | void WebstoreStandaloneInstaller::BeginInstall() { |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 60 | // Add a ref to keep this alive for WebstoreDataFetcher. |
| 61 | // All code paths from here eventually lead to either CompleteInstall or |
| 62 | // AbortInstall, which both release this ref. |
| 63 | AddRef(); |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 64 | |
[email protected] | 3d61a7f | 2012-07-12 19:11:25 | [diff] [blame] | 65 | if (!Extension::IdIsValid(id_)) { |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 66 | CompleteInstall(kInvalidWebstoreItemId); |
| 67 | return; |
| 68 | } |
| 69 | |
[email protected] | b4574c0 | 2011-11-17 06:19:13 | [diff] [blame] | 70 | // Use the requesting page as the referrer both since that is more correct |
| 71 | // (it is the page that caused this request to happen) and so that we can |
| 72 | // track top sites that trigger inline install requests. |
[email protected] | 7b394105 | 2013-02-13 01:21:59 | [diff] [blame] | 73 | webstore_data_fetcher_.reset(new WebstoreDataFetcher( |
| 74 | this, |
[email protected] | c1b2d04 | 2013-02-23 00:31:04 | [diff] [blame] | 75 | profile_->GetRequestContext(), |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 76 | GetRequestorURL(), |
[email protected] | 7b394105 | 2013-02-13 01:21:59 | [diff] [blame] | 77 | id_)); |
| 78 | webstore_data_fetcher_->Start(); |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 79 | } |
| 80 | |
[email protected] | f8b23b4 | 2013-06-27 20:12:14 | [diff] [blame] | 81 | scoped_ptr<ExtensionInstallPrompt> |
| 82 | WebstoreStandaloneInstaller::CreateInstallUI() { |
| 83 | return make_scoped_ptr(new ExtensionInstallPrompt(GetWebContents())); |
| 84 | } |
| 85 | |
[email protected] | 7b394105 | 2013-02-13 01:21:59 | [diff] [blame] | 86 | void WebstoreStandaloneInstaller::OnWebstoreRequestFailure() { |
| 87 | CompleteInstall(kWebstoreRequestError); |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 88 | } |
| 89 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 90 | void WebstoreStandaloneInstaller::OnWebstoreResponseParseSuccess( |
[email protected] | b3188ec | 2013-11-06 10:26:13 | [diff] [blame^] | 91 | scoped_ptr<DictionaryValue> webstore_data) { |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 92 | if (!CheckRequestorAlive()) { |
[email protected] | 007b3f8 | 2013-04-09 08:46:45 | [diff] [blame] | 93 | CompleteInstall(std::string()); |
[email protected] | 4693243e | 2011-09-09 23:52:37 | [diff] [blame] | 94 | return; |
| 95 | } |
| 96 | |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 97 | std::string error; |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 98 | |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 99 | if (!CheckInlineInstallPermitted(*webstore_data, &error)) { |
| 100 | CompleteInstall(error); |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 101 | return; |
| 102 | } |
| 103 | |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 104 | if (!CheckRequestorPermitted(*webstore_data, &error)) { |
| 105 | CompleteInstall(error); |
[email protected] | dd5161a | 2011-09-14 17:40:17 | [diff] [blame] | 106 | return; |
| 107 | } |
| 108 | |
| 109 | // Manifest, number of users, average rating and rating count are required. |
| 110 | std::string manifest; |
| 111 | if (!webstore_data->GetString(kManifestKey, &manifest) || |
| 112 | !webstore_data->GetString(kUsersKey, &localized_user_count_) || |
[email protected] | 5fdbd6f | 2011-09-01 17:33:04 | [diff] [blame] | 113 | !webstore_data->GetDouble(kAverageRatingKey, &average_rating_) || |
| 114 | !webstore_data->GetInteger(kRatingCountKey, &rating_count_)) { |
| 115 | CompleteInstall(kInvalidWebstoreResponseError); |
| 116 | return; |
| 117 | } |
| 118 | |
[email protected] | dcde34b3 | 2013-07-31 02:28:45 | [diff] [blame] | 119 | // Optional. |
| 120 | show_user_count_ = true; |
| 121 | webstore_data->GetBoolean(kShowUserCountKey, &show_user_count_); |
| 122 | |
[email protected] | c82da8c4 | 2012-06-08 19:49:11 | [diff] [blame] | 123 | if (average_rating_ < ExtensionInstallPrompt::kMinExtensionRating || |
| 124 | average_rating_ > ExtensionInstallPrompt::kMaxExtensionRating) { |
[email protected] | 5fdbd6f | 2011-09-01 17:33:04 | [diff] [blame] | 125 | CompleteInstall(kInvalidWebstoreResponseError); |
| 126 | return; |
| 127 | } |
| 128 | |
| 129 | // Localized name and description are optional. |
| 130 | if ((webstore_data->HasKey(kLocalizedNameKey) && |
| 131 | !webstore_data->GetString(kLocalizedNameKey, &localized_name_)) || |
| 132 | (webstore_data->HasKey(kLocalizedDescriptionKey) && |
| 133 | !webstore_data->GetString( |
| 134 | kLocalizedDescriptionKey, &localized_description_))) { |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 135 | CompleteInstall(kInvalidWebstoreResponseError); |
| 136 | return; |
| 137 | } |
| 138 | |
| 139 | // Icon URL is optional. |
| 140 | GURL icon_url; |
| 141 | if (webstore_data->HasKey(kIconUrlKey)) { |
| 142 | std::string icon_url_string; |
| 143 | if (!webstore_data->GetString(kIconUrlKey, &icon_url_string)) { |
| 144 | CompleteInstall(kInvalidWebstoreResponseError); |
| 145 | return; |
| 146 | } |
| 147 | icon_url = GURL(extension_urls::GetWebstoreLaunchURL()).Resolve( |
| 148 | icon_url_string); |
| 149 | if (!icon_url.is_valid()) { |
| 150 | CompleteInstall(kInvalidWebstoreResponseError); |
| 151 | return; |
| 152 | } |
| 153 | } |
| 154 | |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 155 | // Assume ownership of webstore_data. |
[email protected] | b3188ec | 2013-11-06 10:26:13 | [diff] [blame^] | 156 | webstore_data_ = webstore_data.Pass(); |
[email protected] | a221ef09 | 2011-09-07 01:34:10 | [diff] [blame] | 157 | |
[email protected] | 007b3f8 | 2013-04-09 08:46:45 | [diff] [blame] | 158 | scoped_refptr<WebstoreInstallHelper> helper = |
| 159 | new WebstoreInstallHelper(this, |
| 160 | id_, |
| 161 | manifest, |
| 162 | std::string(), // We don't have any icon data. |
| 163 | icon_url, |
| 164 | profile_->GetRequestContext()); |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 165 | // The helper will call us back via OnWebstoreParseSucces or |
| 166 | // OnWebstoreParseFailure. |
| 167 | helper->Start(); |
| 168 | } |
| 169 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 170 | void WebstoreStandaloneInstaller::OnWebstoreResponseParseFailure( |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 171 | const std::string& error) { |
| 172 | CompleteInstall(error); |
| 173 | } |
| 174 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 175 | void WebstoreStandaloneInstaller::OnWebstoreParseSuccess( |
[email protected] | 98e4e52 | 2011-10-25 13:00:16 | [diff] [blame] | 176 | const std::string& id, |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 177 | const SkBitmap& icon, |
| 178 | base::DictionaryValue* manifest) { |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 179 | CHECK_EQ(id_, id); |
| 180 | |
| 181 | if (!CheckRequestorAlive()) { |
[email protected] | 007b3f8 | 2013-04-09 08:46:45 | [diff] [blame] | 182 | CompleteInstall(std::string()); |
[email protected] | 2fd920fb | 2011-09-08 23:33:00 | [diff] [blame] | 183 | return; |
| 184 | } |
| 185 | |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 186 | manifest_.reset(manifest); |
| 187 | icon_ = icon; |
| 188 | |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 189 | install_prompt_ = CreateInstallPrompt(); |
| 190 | if (install_prompt_) { |
[email protected] | f8b23b4 | 2013-06-27 20:12:14 | [diff] [blame] | 191 | ShowInstallUI(); |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 192 | // Control flow finishes up in InstallUIProceed or InstallUIAbort. |
| 193 | } else { |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 194 | // Balanced in InstallUIAbort or indirectly in InstallUIProceed via |
| 195 | // OnExtensionInstallSuccess or OnExtensionInstallFailure. |
| 196 | AddRef(); |
[email protected] | 77e9261d | 2013-02-04 22:01:47 | [diff] [blame] | 197 | InstallUIProceed(); |
[email protected] | 77e9261d | 2013-02-04 22:01:47 | [diff] [blame] | 198 | } |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 199 | } |
| 200 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 201 | void WebstoreStandaloneInstaller::OnWebstoreParseFailure( |
[email protected] | 98e4e52 | 2011-10-25 13:00:16 | [diff] [blame] | 202 | const std::string& id, |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 203 | InstallHelperResultCode result_code, |
| 204 | const std::string& error_message) { |
| 205 | CompleteInstall(error_message); |
| 206 | } |
| 207 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 208 | void WebstoreStandaloneInstaller::InstallUIProceed() { |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 209 | if (!CheckRequestorAlive()) { |
[email protected] | 007b3f8 | 2013-04-09 08:46:45 | [diff] [blame] | 210 | CompleteInstall(std::string()); |
[email protected] | 2fd920fb | 2011-09-08 23:33:00 | [diff] [blame] | 211 | return; |
| 212 | } |
| 213 | |
[email protected] | 21a5ad6 | 2012-04-03 04:48:45 | [diff] [blame] | 214 | scoped_ptr<WebstoreInstaller::Approval> approval( |
[email protected] | 89019d6 | 2012-05-17 18:47:09 | [diff] [blame] | 215 | WebstoreInstaller::Approval::CreateWithNoInstallPrompt( |
[email protected] | c1b2d04 | 2013-02-23 00:31:04 | [diff] [blame] | 216 | profile_, |
[email protected] | 89019d6 | 2012-05-17 18:47:09 | [diff] [blame] | 217 | id_, |
[email protected] | 8529082 | 2013-08-23 20:27:38 | [diff] [blame] | 218 | scoped_ptr<base::DictionaryValue>(manifest_.get()->DeepCopy()), |
| 219 | true)); |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 220 | approval->skip_post_install_ui = !ShouldShowPostInstallUI(); |
| 221 | approval->use_app_installed_bubble = ShouldShowAppInstalledBubble(); |
[email protected] | 28e910e | 2013-08-23 04:18:33 | [diff] [blame] | 222 | approval->installing_icon = gfx::ImageSkia::CreateFrom1xBitmap(icon_); |
[email protected] | 21a5ad6 | 2012-04-03 04:48:45 | [diff] [blame] | 223 | |
[email protected] | 98e4e52 | 2011-10-25 13:00:16 | [diff] [blame] | 224 | scoped_refptr<WebstoreInstaller> installer = new WebstoreInstaller( |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 225 | profile_, |
| 226 | this, |
| 227 | &(GetWebContents()->GetController()), |
| 228 | id_, |
| 229 | approval.Pass(), |
[email protected] | 084e3548 | 2013-09-25 02:46:19 | [diff] [blame] | 230 | install_source_); |
[email protected] | 98e4e52 | 2011-10-25 13:00:16 | [diff] [blame] | 231 | installer->Start(); |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 232 | } |
| 233 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 234 | void WebstoreStandaloneInstaller::InstallUIAbort(bool user_initiated) { |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 235 | CompleteInstall(kUserCancelledError); |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 236 | Release(); // Balanced in ShowInstallUI. |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 237 | } |
| 238 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 239 | void WebstoreStandaloneInstaller::OnExtensionInstallSuccess( |
| 240 | const std::string& id) { |
[email protected] | cb08ba2 | 2011-10-19 21:41:40 | [diff] [blame] | 241 | CHECK_EQ(id_, id); |
[email protected] | 007b3f8 | 2013-04-09 08:46:45 | [diff] [blame] | 242 | CompleteInstall(std::string()); |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 243 | Release(); // Balanced in ShowInstallUI. |
[email protected] | cb08ba2 | 2011-10-19 21:41:40 | [diff] [blame] | 244 | } |
| 245 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 246 | void WebstoreStandaloneInstaller::OnExtensionInstallFailure( |
[email protected] | bcd1eaf7 | 2012-10-03 05:42:29 | [diff] [blame] | 247 | const std::string& id, |
| 248 | const std::string& error, |
| 249 | WebstoreInstaller::FailureReason cancelled) { |
[email protected] | cb08ba2 | 2011-10-19 21:41:40 | [diff] [blame] | 250 | CHECK_EQ(id_, id); |
| 251 | CompleteInstall(error); |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 252 | Release(); // Balanced in ShowInstallUI. |
[email protected] | cb08ba2 | 2011-10-19 21:41:40 | [diff] [blame] | 253 | } |
| 254 | |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 255 | void WebstoreStandaloneInstaller::AbortInstall() { |
| 256 | callback_.Reset(); |
| 257 | // Abort any in-progress fetches. |
[email protected] | 3eeddd89 | 2013-04-17 17:00:11 | [diff] [blame] | 258 | if (webstore_data_fetcher_) { |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 259 | webstore_data_fetcher_.reset(); |
| 260 | Release(); // Matches the AddRef in BeginInstall. |
| 261 | } |
| 262 | } |
| 263 | |
[email protected] | 734bcec | 2012-10-08 20:29:05 | [diff] [blame] | 264 | void WebstoreStandaloneInstaller::CompleteInstall(const std::string& error) { |
[email protected] | d2a639e | 2012-09-17 07:41:21 | [diff] [blame] | 265 | if (!callback_.is_null()) |
| 266 | callback_.Run(error.empty(), error); |
[email protected] | 5db2e88 | 2012-12-20 10:17:26 | [diff] [blame] | 267 | Release(); // Matches the AddRef in BeginInstall. |
[email protected] | 8915f34 | 2011-08-29 22:14:37 | [diff] [blame] | 268 | } |
[email protected] | 5f2a475 | 2012-04-27 22:18:58 | [diff] [blame] | 269 | |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 270 | void |
[email protected] | f8b23b4 | 2013-06-27 20:12:14 | [diff] [blame] | 271 | WebstoreStandaloneInstaller::ShowInstallUI() { |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 272 | std::string error; |
| 273 | localized_extension_for_display_ = |
| 274 | ExtensionInstallPrompt::GetLocalizedExtensionForDisplay( |
| 275 | manifest_.get(), |
| 276 | Extension::REQUIRE_KEY | Extension::FROM_WEBSTORE, |
| 277 | id_, |
| 278 | localized_name_, |
| 279 | localized_description_, |
| 280 | &error); |
[email protected] | dc24976f | 2013-06-02 21:15:09 | [diff] [blame] | 281 | if (!localized_extension_for_display_.get()) { |
[email protected] | d44ec7b | 2013-03-15 04:34:34 | [diff] [blame] | 282 | CompleteInstall(kInvalidManifestError); |
| 283 | return; |
[email protected] | 5f2a475 | 2012-04-27 22:18:58 | [diff] [blame] | 284 | } |
[email protected] | 5f2a475 | 2012-04-27 22:18:58 | [diff] [blame] | 285 | |
[email protected] | 3d6d67652 | 2013-10-14 20:44:55 | [diff] [blame] | 286 | // Keep this alive as long as the install prompt lives. |
| 287 | // Balanced in InstallUIAbort or indirectly in InstallUIProceed via |
| 288 | // OnExtensionInstallSuccess or OnExtensionInstallFailure. |
| 289 | AddRef(); |
| 290 | |
[email protected] | f8b23b4 | 2013-06-27 20:12:14 | [diff] [blame] | 291 | install_ui_ = CreateInstallUI(); |
[email protected] | dc24976f | 2013-06-02 21:15:09 | [diff] [blame] | 292 | install_ui_->ConfirmStandaloneInstall( |
| 293 | this, localized_extension_for_display_.get(), &icon_, *install_prompt_); |
[email protected] | 5f2a475 | 2012-04-27 22:18:58 | [diff] [blame] | 294 | } |
[email protected] | 3d61a7f | 2012-07-12 19:11:25 | [diff] [blame] | 295 | |
| 296 | } // namespace extensions |