| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_inline_installer.h" | 5 #include "chrome/browser/extensions/webstore_inline_installer.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 std::string redirect_url; | 225 std::string redirect_url; |
| 226 if (!webstore_data->GetString(kRedirectUrlKey, &redirect_url)) { | 226 if (!webstore_data->GetString(kRedirectUrlKey, &redirect_url)) { |
| 227 CompleteInstall(kInvalidWebstoreResponseError); | 227 CompleteInstall(kInvalidWebstoreResponseError); |
| 228 return; | 228 return; |
| 229 } | 229 } |
| 230 | 230 |
| 231 tab_contents()->OpenURL(OpenURLParams( | 231 tab_contents()->OpenURL(OpenURLParams( |
| 232 GURL(redirect_url), | 232 GURL(redirect_url), |
| 233 tab_contents()->GetURL(), | 233 tab_contents()->GetURL(), |
| 234 NEW_FOREGROUND_TAB, | 234 NEW_FOREGROUND_TAB, |
| 235 PageTransition::AUTO_BOOKMARK)); | 235 content::PAGE_TRANSITION_AUTO_BOOKMARK)); |
| 236 CompleteInstall(kInlineInstallSupportedError); | 236 CompleteInstall(kInlineInstallSupportedError); |
| 237 return; | 237 return; |
| 238 } | 238 } |
| 239 | 239 |
| 240 // Manifest, number of users, average rating and rating count are required. | 240 // Manifest, number of users, average rating and rating count are required. |
| 241 std::string manifest; | 241 std::string manifest; |
| 242 if (!webstore_data->GetString(kManifestKey, &manifest) || | 242 if (!webstore_data->GetString(kManifestKey, &manifest) || |
| 243 !webstore_data->GetString(kUsersKey, &localized_user_count_) || | 243 !webstore_data->GetString(kUsersKey, &localized_user_count_) || |
| 244 !webstore_data->GetDouble(kAverageRatingKey, &average_rating_) || | 244 !webstore_data->GetDouble(kAverageRatingKey, &average_rating_) || |
| 245 !webstore_data->GetInteger(kRatingCountKey, &rating_count_)) { | 245 !webstore_data->GetInteger(kRatingCountKey, &rating_count_)) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 GURL install_url(extension_urls::GetWebstoreInstallUrl( | 378 GURL install_url(extension_urls::GetWebstoreInstallUrl( |
| 379 id_, g_browser_process->GetApplicationLocale())); | 379 id_, g_browser_process->GetApplicationLocale())); |
| 380 | 380 |
| 381 NavigationController& controller = tab_contents()->controller(); | 381 NavigationController& controller = tab_contents()->controller(); |
| 382 // TODO(mihaip): we pretend like the referrer is the gallery in order to pass | 382 // TODO(mihaip): we pretend like the referrer is the gallery in order to pass |
| 383 // the checks in ExtensionService::IsDownloadFromGallery. We should instead | 383 // the checks in ExtensionService::IsDownloadFromGallery. We should instead |
| 384 // pass the real referrer, track that this is an inline install in the | 384 // pass the real referrer, track that this is an inline install in the |
| 385 // whitelist entry and look that up when checking that this is a valid | 385 // whitelist entry and look that up when checking that this is a valid |
| 386 // download. | 386 // download. |
| 387 GURL referrer(extension_urls::GetWebstoreItemDetailURLPrefix() + id_); | 387 GURL referrer(extension_urls::GetWebstoreItemDetailURLPrefix() + id_); |
| 388 controller.LoadURL(install_url, referrer, PageTransition::LINK, | 388 controller.LoadURL(install_url, referrer, content::PAGE_TRANSITION_LINK, |
| 389 std::string()); | 389 std::string()); |
| 390 | 390 |
| 391 // TODO(mihaip): the success message should happen later, when the extension | 391 // TODO(mihaip): the success message should happen later, when the extension |
| 392 // is actually downloaded and installed (when NOTIFICATION_EXTENSION_INSTALLED | 392 // is actually downloaded and installed (when NOTIFICATION_EXTENSION_INSTALLED |
| 393 // or NOTIFICATION_EXTENSION_INSTALL_ERROR fire). | 393 // or NOTIFICATION_EXTENSION_INSTALL_ERROR fire). |
| 394 CompleteInstall(""); | 394 CompleteInstall(""); |
| 395 } | 395 } |
| 396 | 396 |
| 397 void WebstoreInlineInstaller::InstallUIAbort(bool user_initiated) { | 397 void WebstoreInlineInstaller::InstallUIAbort(bool user_initiated) { |
| 398 CompleteInstall(kUserCancelledError); | 398 CompleteInstall(kUserCancelledError); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 412 if (tab_contents()) { | 412 if (tab_contents()) { |
| 413 if (error.empty()) { | 413 if (error.empty()) { |
| 414 delegate_->OnInlineInstallSuccess(install_id_); | 414 delegate_->OnInlineInstallSuccess(install_id_); |
| 415 } else { | 415 } else { |
| 416 delegate_->OnInlineInstallFailure(install_id_, error); | 416 delegate_->OnInlineInstallFailure(install_id_, error); |
| 417 } | 417 } |
| 418 } | 418 } |
| 419 | 419 |
| 420 Release(); // Matches the AddRef in BeginInstall. | 420 Release(); // Matches the AddRef in BeginInstall. |
| 421 } | 421 } |
| OLD | NEW |