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/api/webstore_private/webstore_private_api.h" | 5 #include "chrome/browser/extensions/api/webstore_private/webstore_private_api.h" |
6 | 6 |
7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #include "chrome/browser/extensions/webstore_installer.h" | 23 #include "chrome/browser/extensions/webstore_installer.h" |
24 #include "chrome/browser/gpu/gpu_feature_checker.h" | 24 #include "chrome/browser/gpu/gpu_feature_checker.h" |
25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
26 #include "chrome/browser/signin/signin_manager.h" | 26 #include "chrome/browser/signin/signin_manager.h" |
27 #include "chrome/browser/signin/signin_manager_factory.h" | 27 #include "chrome/browser/signin/signin_manager_factory.h" |
28 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
29 #include "chrome/browser/sync/profile_sync_service_factory.h" | 29 #include "chrome/browser/sync/profile_sync_service_factory.h" |
30 #include "chrome/browser/ui/app_list/app_list_service.h" | 30 #include "chrome/browser/ui/app_list/app_list_service.h" |
31 #include "chrome/browser/ui/app_list/app_list_util.h" | 31 #include "chrome/browser/ui/app_list/app_list_util.h" |
32 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
33 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | |
34 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | |
33 #include "chrome/common/extensions/extension_constants.h" | 35 #include "chrome/common/extensions/extension_constants.h" |
34 #include "chrome/common/extensions/extension_l10n_util.h" | 36 #include "chrome/common/extensions/extension_l10n_util.h" |
35 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
36 #include "content/public/browser/gpu_data_manager.h" | 38 #include "content/public/browser/gpu_data_manager.h" |
37 #include "content/public/browser/notification_details.h" | 39 #include "content/public/browser/notification_details.h" |
38 #include "content/public/browser/notification_source.h" | 40 #include "content/public/browser/notification_source.h" |
39 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
40 #include "extensions/browser/extension_prefs.h" | 42 #include "extensions/browser/extension_prefs.h" |
41 #include "extensions/browser/extension_system.h" | 43 #include "extensions/browser/extension_system.h" |
42 #include "extensions/common/error_utils.h" | 44 #include "extensions/common/error_utils.h" |
43 #include "extensions/common/extension.h" | 45 #include "extensions/common/extension.h" |
44 #include "grit/chromium_strings.h" | 46 #include "grit/chromium_strings.h" |
45 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
46 #include "ui/base/l10n/l10n_util.h" | 48 #include "ui/base/l10n/l10n_util.h" |
47 | 49 |
48 using content::GpuDataManager; | 50 using content::GpuDataManager; |
49 | 51 |
50 namespace extensions { | 52 namespace extensions { |
51 | 53 |
52 namespace BeginInstallWithManifest3 = | 54 namespace BeginInstallWithManifest3 = |
53 api::webstore_private::BeginInstallWithManifest3; | 55 api::webstore_private::BeginInstallWithManifest3; |
54 namespace CompleteInstall = api::webstore_private::CompleteInstall; | 56 namespace CompleteInstall = api::webstore_private::CompleteInstall; |
55 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; | 57 namespace GetBrowserLogin = api::webstore_private::GetBrowserLogin; |
56 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; | 58 namespace GetIsLauncherEnabled = api::webstore_private::GetIsLauncherEnabled; |
57 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; | 59 namespace GetStoreLogin = api::webstore_private::GetStoreLogin; |
58 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; | 60 namespace GetWebGLStatus = api::webstore_private::GetWebGLStatus; |
59 namespace InstallBundle = api::webstore_private::InstallBundle; | 61 namespace InstallBundle = api::webstore_private::InstallBundle; |
60 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; | 62 namespace IsInIncognitoMode = api::webstore_private::IsInIncognitoMode; |
63 namespace SignIn = api::webstore_private::SignIn; | |
61 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; | 64 namespace SetStoreLogin = api::webstore_private::SetStoreLogin; |
62 | 65 |
63 namespace { | 66 namespace { |
64 | 67 |
65 // Holds the Approvals between the time we prompt and start the installs. | 68 // Holds the Approvals between the time we prompt and start the installs. |
66 class PendingApprovals { | 69 class PendingApprovals { |
67 public: | 70 public: |
68 PendingApprovals(); | 71 PendingApprovals(); |
69 ~PendingApprovals(); | 72 ~PendingApprovals(); |
70 | 73 |
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
679 results_ = GetIsLauncherEnabled::Results::Create(IsAppLauncherEnabled()); | 682 results_ = GetIsLauncherEnabled::Results::Create(IsAppLauncherEnabled()); |
680 return true; | 683 return true; |
681 } | 684 } |
682 | 685 |
683 bool WebstorePrivateIsInIncognitoModeFunction::RunImpl() { | 686 bool WebstorePrivateIsInIncognitoModeFunction::RunImpl() { |
684 results_ = IsInIncognitoMode::Results::Create( | 687 results_ = IsInIncognitoMode::Results::Create( |
685 GetProfile() != GetProfile()->GetOriginalProfile()); | 688 GetProfile() != GetProfile()->GetOriginalProfile()); |
686 return true; | 689 return true; |
687 } | 690 } |
688 | 691 |
692 bool WebstorePrivateSignInFunction::RunImpl() { | |
Ilya Sherman
2014/03/12 06:34:29
Hui, this CL is not nearly ready for a full review
guohui
2014/03/12 18:17:39
it looks good in general, plz see my comments belo
| |
693 scoped_ptr<SignIn::Params> params = SignIn::Params::Create(*args_); | |
694 EXTENSION_FUNCTION_VALIDATE(params); | |
695 | |
696 // The |continue_url| is required. | |
697 if (!params->continue_url) | |
698 return false; | |
699 | |
700 // If sign-in is disallowed, give up. | |
701 SigninManagerBase* signin_manager = | |
702 SigninManagerFactory::GetForProfile(GetProfile()); | |
703 if (!signin_manager || !signin_manager->IsSigninAllowed()) | |
704 return false; | |
Ilya Sherman
2014/03/12 06:34:29
Am I right to be using a SigninManager here?
guohui
2014/03/12 18:17:39
yes, i think so, though i think you need to notify
| |
705 | |
706 // If the user is already signed in, there's nothing else to do. | |
707 if (!signin_manager->GetAuthenticatedUsername().empty()) | |
708 return true; | |
Ilya Sherman
2014/03/12 06:34:29
Is it appropriate to bail if the user is already s
guohui
2014/03/12 18:17:39
yup, again we should notify the webstore of the re
| |
709 | |
710 // TODO(isherman): What to do if an authentication is already in progress? | |
711 // if (signin_manager->AuthInProgress()) ... | |
Ilya Sherman
2014/03/12 06:34:29
What's the expected behavior if there is already a
guohui
2014/03/12 18:17:39
this means signin is already triggered through a s
| |
712 | |
713 // TODO(isherman): Replace the current tab with the UI, rather than showing it | |
714 // in a new tab. | |
Ilya Sherman
2014/03/12 06:34:29
Are you aware of existing code that I can re-use t
guohui
2014/03/12 18:17:39
hmm i think you could simply navigate the current
| |
715 // TODO(isherman): Make use of the |continue_url|. | |
716 LoginUIService* login_ui_service = | |
717 LoginUIServiceFactory::GetForProfile(GetProfile()); | |
718 login_ui_service->ShowLoginPopup(); | |
Ilya Sherman
2014/03/12 06:34:29
Is a LoginUIService the best way to show an inline
guohui
2014/03/12 18:17:39
LoginUIService::ShowLoginPopup shows the login UI
| |
719 | |
720 // TODO(isherman): Just for debugging: | |
721 DLOG(WARNING) << *params->continue_url; | |
722 return true; | |
723 } | |
724 | |
689 } // namespace extensions | 725 } // namespace extensions |
OLD | NEW |