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.
5 #include "chrome/browser/ui/app_list/chrome_signin_delegate.h"
7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/signin/signin_manager.h"
10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/browser/signin/signin_promo.h"
12 #include "chrome/browser/ui/browser_navigator.h"
13 #include "chrome/browser/ui/chrome_pages.h"
14 #include "chrome/browser/ui/extensions/application_launch.h"
15 #include "chrome/browser/ui/host_desktop.h"
16 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
17 #include "chrome/common/extensions/extension_constants.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"
25 #if !defined(OS_CHROMEOS)
26 SigninManagerBase
* GetSigninManager(Profile
* profile
) {
27 return SigninManagerFactory::GetForProfile(profile
);
29 #endif // !defined(OS_CHROMEOS)
33 ChromeSigninDelegate::ChromeSigninDelegate() {}
35 ChromeSigninDelegate::~ChromeSigninDelegate() {}
37 void ChromeSigninDelegate::SetProfile(Profile
* profile
) {
41 bool ChromeSigninDelegate::NeedSignin() {
42 #if defined(OS_CHROMEOS)
48 if (!GetSigninManager(profile_
))
51 return GetSigninManager(profile_
)->GetAuthenticatedUsername().empty();
55 void ChromeSigninDelegate::ShowSignin() {
57 chrome::ScopedTabbedBrowserDisplayer
displayer(
58 profile_
, chrome::GetActiveDesktop());
59 chrome::ShowBrowserSignin(displayer
.browser(), signin::SOURCE_APP_LAUNCHER
);
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
);
69 void ChromeSigninDelegate::OpenSettings() {
70 ExtensionService
* service
= profile_
->GetExtensionService();
72 const extensions::Extension
* extension
= service
->GetInstalledExtension(
73 extension_misc::kSettingsAppId
);
77 OpenApplication(AppLaunchParams(profile_
, extension
, NEW_FOREGROUND_TAB
));
80 base::string16
ChromeSigninDelegate::GetSigninHeading() {
81 ui::ResourceBundle
& rb
= ui::ResourceBundle::GetSharedInstance();
82 return rb
.GetLocalizedString(IDS_APP_LIST_SIGNIN_HEADING
);
85 base::string16
ChromeSigninDelegate::GetSigninText() {
86 ui::ResourceBundle
& rb
= ui::ResourceBundle::GetSharedInstance();
87 return rb
.GetLocalizedString(IDS_APP_LIST_SIGNIN_TEXT
);
90 base::string16
ChromeSigninDelegate::GetSigninButtonText() {
91 ui::ResourceBundle
& rb
= ui::ResourceBundle::GetSharedInstance();
92 return rb
.GetLocalizedString(IDS_APP_LIST_SIGNIN_BUTTON
);
95 base::string16
ChromeSigninDelegate::GetLearnMoreLinkText() {
96 ui::ResourceBundle
& rb
= ui::ResourceBundle::GetSharedInstance();
97 return rb
.GetLocalizedString(IDS_APP_LIST_SIGNIN_LEARN_MORE_TEXT
);
100 base::string16
ChromeSigninDelegate::GetSettingsLinkText() {
101 ui::ResourceBundle
& rb
= ui::ResourceBundle::GetSharedInstance();
102 return rb
.GetLocalizedString(IDS_APP_LIST_SIGNIN_SETTINGS_TEXT
);