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/extension_webstore_private_api.h" | 5 #include "chrome/browser/extensions/extension_webstore_private_api.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/common/chrome_utility_messages.h" | 25 #include "chrome/common/chrome_utility_messages.h" |
26 #include "chrome/common/extensions/extension_constants.h" | 26 #include "chrome/common/extensions/extension_constants.h" |
27 #include "chrome/common/extensions/extension_error_utils.h" | 27 #include "chrome/common/extensions/extension_error_utils.h" |
28 #include "chrome/common/extensions/extension_l10n_util.h" | 28 #include "chrome/common/extensions/extension_l10n_util.h" |
29 #include "chrome/common/net/gaia/gaia_constants.h" | 29 #include "chrome/common/net/gaia/gaia_constants.h" |
30 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
31 #include "content/common/notification_details.h" | 31 #include "content/common/notification_details.h" |
32 #include "content/common/notification_source.h" | 32 #include "content/common/notification_source.h" |
33 #include "grit/chromium_strings.h" | 33 #include "grit/chromium_strings.h" |
34 #include "grit/generated_resources.h" | 34 #include "grit/generated_resources.h" |
35 #include "net/base/escape.h" | |
36 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
37 | 36 |
38 namespace { | 37 namespace { |
39 | 38 |
40 const char kAppInstallBubbleKey[] = "appInstallBubble"; | 39 const char kAppInstallBubbleKey[] = "appInstallBubble"; |
41 const char kIconDataKey[] = "iconData"; | 40 const char kIconDataKey[] = "iconData"; |
42 const char kIdKey[] = "id"; | 41 const char kIdKey[] = "id"; |
43 const char kLocalizedNameKey[] = "localizedName"; | 42 const char kLocalizedNameKey[] = "localizedName"; |
44 const char kLoginKey[] = "login"; | 43 const char kLoginKey[] = "login"; |
45 const char kManifestKey[] = "manifest"; | 44 const char kManifestKey[] = "manifest"; |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 return false; | 507 return false; |
509 } | 508 } |
510 | 509 |
511 if (!CrxInstaller::IsIdWhitelisted(id) && | 510 if (!CrxInstaller::IsIdWhitelisted(id) && |
512 !CrxInstaller::GetWhitelistEntry(id)) { | 511 !CrxInstaller::GetWhitelistEntry(id)) { |
513 error_ = ExtensionErrorUtils::FormatErrorMessage( | 512 error_ = ExtensionErrorUtils::FormatErrorMessage( |
514 kNoPreviousBeginInstallError, id); | 513 kNoPreviousBeginInstallError, id); |
515 return false; | 514 return false; |
516 } | 515 } |
517 | 516 |
518 std::vector<std::string> params; | 517 GURL install_url(extension_urls::GetWebstoreInstallUrl( |
519 params.push_back("id=" + id); | 518 id, g_browser_process->GetApplicationLocale())); |
520 params.push_back("lang=" + g_browser_process->GetApplicationLocale()); | |
521 params.push_back("uc"); | |
522 std::string url_string = Extension::GalleryUpdateUrl(true).spec(); | |
523 | |
524 GURL url(url_string + "?response=redirect&x=" + | |
525 EscapeQueryParamValue(JoinString(params, '&'), true)); | |
526 DCHECK(url.is_valid()); | |
527 | 519 |
528 // The download url for the given |id| is now contained in |url|. We | 520 // The download url for the given |id| is now contained in |url|. We |
529 // navigate the current (calling) tab to this url which will result in a | 521 // navigate the current (calling) tab to this url which will result in a |
530 // download starting. Once completed it will go through the normal extension | 522 // download starting. Once completed it will go through the normal extension |
531 // install flow. The above call to SetWhitelistedInstallId will bypass the | 523 // install flow. The above call to SetWhitelistedInstallId will bypass the |
532 // normal permissions install dialog. | 524 // normal permissions install dialog. |
533 NavigationController& controller = | 525 NavigationController& controller = |
534 dispatcher()->delegate()->GetAssociatedTabContents()->controller(); | 526 dispatcher()->delegate()->GetAssociatedTabContents()->controller(); |
535 controller.LoadURL(url, source_url(), PageTransition::LINK); | 527 controller.LoadURL(install_url, source_url(), PageTransition::LINK); |
536 | 528 |
537 return true; | 529 return true; |
538 } | 530 } |
539 | 531 |
540 bool GetBrowserLoginFunction::RunImpl() { | 532 bool GetBrowserLoginFunction::RunImpl() { |
541 if (!IsWebStoreURL(profile_, source_url())) | 533 if (!IsWebStoreURL(profile_, source_url())) |
542 return false; | 534 return false; |
543 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); | 535 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); |
544 return true; | 536 return true; |
545 } | 537 } |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
677 } | 669 } |
678 | 670 |
679 DCHECK(waiting_for_token_); | 671 DCHECK(waiting_for_token_); |
680 | 672 |
681 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); | 673 result_.reset(CreateLoginResult(profile_->GetOriginalProfile())); |
682 SendResponse(true); | 674 SendResponse(true); |
683 | 675 |
684 // Matches the AddRef in RunImpl(). | 676 // Matches the AddRef in RunImpl(). |
685 Release(); | 677 Release(); |
686 } | 678 } |
OLD | NEW |