OLD | NEW |
| (Empty) |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/app_list/chrome_signin_delegate.h" | |
6 | |
7 #include "chrome/browser/extensions/extension_service.h" | |
8 #include "chrome/browser/profiles/profile.h" | |
9 #include "chrome/browser/signin/signin_manager_factory.h" | |
10 #include "chrome/browser/signin/signin_promo.h" | |
11 #include "chrome/browser/ui/browser_navigator.h" | |
12 #include "chrome/browser/ui/chrome_pages.h" | |
13 #include "chrome/browser/ui/extensions/application_launch.h" | |
14 #include "chrome/browser/ui/host_desktop.h" | |
15 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | |
16 #include "chrome/common/extensions/extension_constants.h" | |
17 #include "components/signin/core/browser/signin_manager.h" | |
18 #include "content/public/common/page_transition_types.h" | |
19 #include "grit/chromium_strings.h" | |
20 #include "grit/generated_resources.h" | |
21 #include "ui/base/resource/resource_bundle.h" | |
22 | |
23 namespace { | |
24 | |
25 #if !defined(OS_CHROMEOS) | |
26 SigninManagerBase* GetSigninManager(Profile* profile) { | |
27 return SigninManagerFactory::GetForProfile(profile); | |
28 } | |
29 #endif // !defined(OS_CHROMEOS) | |
30 | |
31 } // namespace | |
32 | |
33 ChromeSigninDelegate::ChromeSigninDelegate() {} | |
34 | |
35 ChromeSigninDelegate::~ChromeSigninDelegate() {} | |
36 | |
37 void ChromeSigninDelegate::SetProfile(Profile* profile) { | |
38 profile_ = profile; | |
39 } | |
40 | |
41 bool ChromeSigninDelegate::NeedSignin() { | |
42 #if defined(OS_CHROMEOS) | |
43 return false; | |
44 #else | |
45 if (!profile_) | |
46 return false; | |
47 | |
48 if (!GetSigninManager(profile_)) | |
49 return false; | |
50 | |
51 return GetSigninManager(profile_)->GetAuthenticatedUsername().empty(); | |
52 #endif | |
53 } | |
54 | |
55 void ChromeSigninDelegate::ShowSignin() { | |
56 DCHECK(profile_); | |
57 chrome::ScopedTabbedBrowserDisplayer displayer( | |
58 profile_, chrome::GetActiveDesktop()); | |
59 chrome::ShowBrowserSignin(displayer.browser(), signin::SOURCE_APP_LAUNCHER); | |
60 } | |
61 | |
62 void ChromeSigninDelegate::OpenLearnMore() { | |
63 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
64 GURL gurl(rb.GetLocalizedString(IDS_APP_LIST_SIGNIN_LEARN_MORE_LINK)); | |
65 chrome::NavigateParams params(profile_, gurl, content::PAGE_TRANSITION_LINK); | |
66 chrome::Navigate(¶ms); | |
67 } | |
68 | |
69 void ChromeSigninDelegate::OpenSettings() { | |
70 ExtensionService* service = profile_->GetExtensionService(); | |
71 DCHECK(service); | |
72 const extensions::Extension* extension = service->GetInstalledExtension( | |
73 extension_misc::kSettingsAppId); | |
74 if (!extension) | |
75 return; | |
76 | |
77 OpenApplication(AppLaunchParams(profile_, extension, NEW_FOREGROUND_TAB)); | |
78 } | |
79 | |
80 base::string16 ChromeSigninDelegate::GetSigninHeading() { | |
81 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
82 return rb.GetLocalizedString(IDS_APP_LIST_SIGNIN_HEADING); | |
83 } | |
84 | |
85 base::string16 ChromeSigninDelegate::GetSigninText() { | |
86 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
87 return rb.GetLocalizedString(IDS_APP_LIST_SIGNIN_TEXT); | |
88 } | |
89 | |
90 base::string16 ChromeSigninDelegate::GetSigninButtonText() { | |
91 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
92 return rb.GetLocalizedString(IDS_APP_LIST_SIGNIN_BUTTON); | |
93 } | |
94 | |
95 base::string16 ChromeSigninDelegate::GetLearnMoreLinkText() { | |
96 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
97 return rb.GetLocalizedString(IDS_APP_LIST_SIGNIN_LEARN_MORE_TEXT); | |
98 } | |
99 | |
100 base::string16 ChromeSigninDelegate::GetSettingsLinkText() { | |
101 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
102 return rb.GetLocalizedString(IDS_APP_LIST_SIGNIN_SETTINGS_TEXT); | |
103 } | |
OLD | NEW |