Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: chrome/browser/ui/webui/sync_setup_handler2.h

Issue 9104028: Unfork various Sync settings UI classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another cros compilation fix. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER2_H_
6 #define CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER2_H_
7
8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
10 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
11 #include "chrome/browser/sync/sync_setup_flow_handler.h"
12 #include "chrome/browser/ui/webui/options2/options_ui2.h"
13
14 class SyncSetupFlow;
15 class ProfileManager;
16
17 namespace options2 {
18
19 class SyncSetupHandler2 : public GaiaOAuthConsumer,
20 public OptionsPageUIHandler,
21 public SyncSetupFlowHandler {
22 public:
23 // Constructs a new SyncSetupHandler. |profile_manager| may be NULL.
24 explicit SyncSetupHandler2(ProfileManager* profile_manager);
25 virtual ~SyncSetupHandler2();
26
27 // OptionsPageUIHandler implementation.
28 virtual void GetLocalizedValues(base::DictionaryValue* localized_strings)
29 OVERRIDE;
30 virtual void Initialize() OVERRIDE;
31 virtual void RegisterMessages() OVERRIDE;
32
33 // SyncSetupFlowHandler implementation.
34 virtual void ShowOAuthLogin() OVERRIDE;
35 virtual void ShowGaiaLogin(const base::DictionaryValue& args) OVERRIDE;
36 virtual void ShowGaiaSuccessAndClose() OVERRIDE;
37 virtual void ShowGaiaSuccessAndSettingUp() OVERRIDE;
38 virtual void ShowConfigure(const base::DictionaryValue& args) OVERRIDE;
39 virtual void ShowPassphraseEntry(const base::DictionaryValue& args) OVERRIDE;
40 virtual void ShowSettingUp() OVERRIDE;
41 virtual void ShowSetupDone(const string16& user) OVERRIDE;
42 virtual void SetFlow(SyncSetupFlow* flow) OVERRIDE;
43 virtual void Focus() OVERRIDE;
44
45 // GaiaOAuthConsumer implementation.
46 virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE;
47 virtual void OnGetOAuthTokenFailure(
48 const GoogleServiceAuthError& error) OVERRIDE;
49
50 static void GetStaticLocalizedValues(
51 base::DictionaryValue* localized_strings,
52 content::WebUI* web_ui);
53
54 // Initializes the sync setup flow and shows the setup UI.
55 void OpenSyncSetup();
56
57 // Terminates the sync setup flow.
58 void CloseSyncSetup();
59
60 protected:
61 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, InitialStepLogin);
62 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, ChooseDataTypesSetsPrefs);
63 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DialogCancelled);
64 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, InvalidTransitions);
65 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, FullSuccessfulRunSetsPref);
66 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, AbortedByPendingClear);
67 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DiscreteRunGaiaLogin);
68 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, DiscreteRunChooseDataTypes);
69 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest,
70 DiscreteRunChooseDataTypesAbortedByPendingClear);
71 FRIEND_TEST_ALL_PREFIXES(SyncSetupWizardTest, EnterPassphraseRequired);
72
73 // Callbacks from the page. Protected in order to be called by the
74 // SyncSetupWizardTest.
75 void OnDidClosePage(const base::ListValue* args);
76 void HandleSubmitAuth(const base::ListValue* args);
77 void HandleConfigure(const base::ListValue* args);
78 void HandlePassphraseEntry(const base::ListValue* args);
79 void HandlePassphraseCancel(const base::ListValue* args);
80 void HandleAttachHandler(const base::ListValue* args);
81 void HandleShowErrorUI(const base::ListValue* args);
82 void HandleShowSetupUI(const base::ListValue* args);
83
84 SyncSetupFlow* flow() { return flow_; }
85
86 // Subclasses must implement to step the SyncSetupWizard to the correct state
87 // before showing the Setup UI.
88 virtual void StepWizardForShowSetupUI() = 0;
89
90 // Subclasses must implement this to show the setup UI that's appropriate
91 // for the page this is contained in.
92 virtual void ShowSetupUI() = 0;
93
94 private:
95 // If a wizard already exists, focus it and return true.
96 bool FocusExistingWizard();
97
98 // Invokes the javascript call to close the setup overlay.
99 void CloseOverlay();
100
101 // Returns true if the given login data is valid, false otherwise. If the
102 // login data is not valid then on return |error_message| will be set to a
103 // localized error message. Note, |error_message| must not be NULL.
104 bool IsLoginAuthDataValid(const std::string& username,
105 string16* error_message);
106
107 // Displays the given error message in the login UI.
108 void ShowLoginErrorMessage(const string16& error_message);
109
110 // Weak reference.
111 SyncSetupFlow* flow_;
112 scoped_ptr<GaiaOAuthFetcher> oauth_login_;
113 // Weak reference to the profile manager.
114 ProfileManager* const profile_manager_;
115
116 DISALLOW_COPY_AND_ASSIGN(SyncSetupHandler2);
117 };
118
119 } // namespace options2
120
121 #endif // CHROME_BROWSER_UI_WEBUI_SYNC_SETUP_HANDLER2_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/stop_syncing_handler2.cc ('k') | chrome/browser/ui/webui/sync_setup_handler2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698