Print Preview: Changing displayed error message when PDF Viewer is missing.
[chromium-blink-merge.git] / chrome / browser / browser_signin.h
blob63096eaf4de6349ac0bc4e7de63483083e4e3e55
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_BROWSER_SIGNIN_H_
6 #define CHROME_BROWSER_BROWSER_SIGNIN_H_
7 #pragma once
9 #include <string>
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/common/net/gaia/google_service_auth_error.h"
13 #include "content/common/notification_observer.h"
14 #include "content/common/notification_registrar.h"
16 class BrowserSigninHtml;
17 class Profile;
18 class ProfileSyncService;
19 class TabContents;
21 // The BrowserSignin class provides a login screen which allows the
22 // user to signin to the browser. Currently the signin is coordinated
23 // through the Chrome Sync logic.
25 // TODO(johnnyg): Separate this from the sync logic and make it the
26 // sole co-ordinator of browser signin.
28 // This class should only be accessed on the UI thread.
29 class BrowserSignin : public NotificationObserver {
30 public:
31 explicit BrowserSignin(Profile* profile);
32 virtual ~BrowserSignin();
34 // The delegate class is invoked on success and failure.
35 class SigninDelegate {
36 public:
37 virtual ~SigninDelegate() {}
39 // The login was successful.
40 virtual void OnLoginSuccess() = 0;
42 // The login failed.
43 virtual void OnLoginFailure(const GoogleServiceAuthError& error) = 0;
46 // Request that the user signin, modal to TabContents provided.
47 // If a user is already signed in, this will show a login dialog where
48 // the username is not editable.
50 // A custom HTML string can be provided that will be displayed next
51 // to the signin dialog.
53 // Only one sign-in can be in process at a time; if there is one in
54 // progress already it will be canceled in favor of this one.
56 // The delegate will eventually be called with OnLoginSuccess() or
57 // OnLoginFailure(), but never both. virtual for test override.
58 virtual void RequestSignin(TabContents* tab_contents,
59 const string16& suggested_email,
60 const string16& login_message,
61 SigninDelegate* delegate);
63 // Returns the username of the user currently signed in. If no
64 // user is signed in, returns the empty string. virtual for test
65 // override.
66 virtual std::string GetSignedInUsername() const;
68 // NotificationObserver implementation.
69 virtual void Observe(NotificationType type,
70 const NotificationSource& source,
71 const NotificationDetails& details);
73 ProfileSyncService* GetProfileSyncService() const;
75 // Close the dialog. Delegate's OnLoginFailure method will be called.
76 void Cancel();
78 private:
79 // Create the HTML Dialog content.
80 BrowserSigninHtml* CreateHtmlDialogUI();
82 // When the dialog is closed.
83 void OnLoginFinished();
85 // Turn auth notifications on.
86 void RegisterAuthNotifications();
88 // Turn auth notifications off.
89 void UnregisterAuthNotifications();
91 // Show the dialog Tab-Modal.
92 void ShowSigninTabModal(TabContents* tab_contents);
94 // Non-owned pointer to the profile (which owns this object).
95 Profile* profile_;
97 // Suggested email for the current login prompt.
98 string16 suggested_email_;
100 // Current login message.
101 string16 login_message_;
103 // Delegate for the current sign in request.
104 SigninDelegate* delegate_;
106 // Current HTML Dialog information. Pointer is owned by the WebUI it will be
107 // attached to.
108 BrowserSigninHtml* html_dialog_ui_delegate_;
110 NotificationRegistrar registrar_;
112 DISALLOW_COPY_AND_ASSIGN(BrowserSignin);
116 #endif // CHROME_BROWSER_BROWSER_SIGNIN_H_