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

Side by Side Diff: chrome/browser/views/sync/sync_setup_wizard.cc

Issue 270081: Facelifts to sync UI (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 2 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
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #ifdef CHROME_PERSONALIZATION 5 #ifdef CHROME_PERSONALIZATION
6 6
7 #include "chrome/browser/views/sync/sync_setup_wizard.h" 7 #include "chrome/browser/views/sync/sync_setup_wizard.h"
8 8
9 #include "app/resource_bundle.h" 9 #include "app/resource_bundle.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 l10n_util::GetString(IDS_SYNC_LOGIN_COULD_NOT_CONNECT)); 73 l10n_util::GetString(IDS_SYNC_LOGIN_COULD_NOT_CONNECT));
74 localized_strings.SetString(L"cannotaccessaccount", 74 localized_strings.SetString(L"cannotaccessaccount",
75 l10n_util::GetString(IDS_SYNC_CANNOT_ACCESS_ACCOUNT)); 75 l10n_util::GetString(IDS_SYNC_CANNOT_ACCESS_ACCOUNT));
76 localized_strings.SetString(L"createaccount", 76 localized_strings.SetString(L"createaccount",
77 l10n_util::GetString(IDS_SYNC_CREATE_ACCOUNT)); 77 l10n_util::GetString(IDS_SYNC_CREATE_ACCOUNT));
78 localized_strings.SetString(L"cancel", 78 localized_strings.SetString(L"cancel",
79 l10n_util::GetString(IDS_CANCEL)); 79 l10n_util::GetString(IDS_CANCEL));
80 localized_strings.SetString(L"settingup", 80 localized_strings.SetString(L"settingup",
81 l10n_util::GetString(IDS_SYNC_LOGIN_SETTING_UP)); 81 l10n_util::GetString(IDS_SYNC_LOGIN_SETTING_UP));
82 localized_strings.SetString(L"success", 82 localized_strings.SetString(L"success",
83 l10n_util::GetString(IDS_SYNC_LOGIN_SUCCESS)); 83 l10n_util::GetString(IDS_SYNC_SUCCESS));
84 localized_strings.SetString(L"errorsigningin", 84 localized_strings.SetString(L"errorsigningin",
85 l10n_util::GetString(IDS_SYNC_ERROR_SIGNING_IN)); 85 l10n_util::GetString(IDS_SYNC_ERROR_SIGNING_IN));
86 static const base::StringPiece html(ResourceBundle::GetSharedInstance() 86 static const base::StringPiece html(ResourceBundle::GetSharedInstance()
87 .GetRawDataResource(IDR_GAIA_LOGIN_HTML)); 87 .GetRawDataResource(IDR_GAIA_LOGIN_HTML));
88 SetFontAndTextDirection(&localized_strings); 88 SetFontAndTextDirection(&localized_strings);
89 response = jstemplate_builder::GetI18nTemplateHtml( 89 response = jstemplate_builder::GetI18nTemplateHtml(
90 html, &localized_strings); 90 html, &localized_strings);
91 } else if (path_raw == chrome::kSyncMergeAndSyncPath) { 91 } else if (path_raw == chrome::kSyncMergeAndSyncPath) {
92 DictionaryValue localized_strings; 92 DictionaryValue localized_strings;
93 localized_strings.SetString(L"introduction", 93 localized_strings.SetString(L"introduction",
94 l10n_util::GetString(IDS_SYNC_MERGE_INTRODUCTION)); 94 l10n_util::GetString(IDS_SYNC_MERGE_INTRODUCTION));
95 localized_strings.SetString(L"mergeandsynclabel", 95 localized_strings.SetString(L"mergeandsynclabel",
96 l10n_util::GetString(IDS_SYNC_MERGE_AND_SYNC_LABEL)); 96 l10n_util::GetString(IDS_SYNC_MERGE_AND_SYNC_LABEL));
97 localized_strings.SetString(L"abortlabel", 97 localized_strings.SetString(L"abortlabel",
98 l10n_util::GetString(IDS_ABORT)); 98 l10n_util::GetString(IDS_ABORT));
99 localized_strings.SetString(L"closelabel", 99 localized_strings.SetString(L"closelabel",
100 l10n_util::GetString(IDS_CLOSE)); 100 l10n_util::GetString(IDS_CLOSE));
101 localized_strings.SetString(L"alldone",
102 l10n_util::GetString(IDS_SYNC_MERGE_ALL_DONE));
103 localized_strings.SetString(L"mergeandsyncwarning", 101 localized_strings.SetString(L"mergeandsyncwarning",
104 l10n_util::GetString(IDS_SYNC_MERGE_WARNING)); 102 l10n_util::GetString(IDS_SYNC_MERGE_WARNING));
105 localized_strings.SetString(L"setuperror", 103 localized_strings.SetString(L"setuperror",
106 l10n_util::GetString(IDS_SYNC_SETUP_ERROR)); 104 l10n_util::GetString(IDS_SYNC_SETUP_ERROR));
107 105
108 static const base::StringPiece html(ResourceBundle::GetSharedInstance() 106 static const base::StringPiece html(ResourceBundle::GetSharedInstance()
109 .GetRawDataResource(IDR_MERGE_AND_SYNC_HTML)); 107 .GetRawDataResource(IDR_MERGE_AND_SYNC_HTML));
110 SetFontAndTextDirection(&localized_strings); 108 SetFontAndTextDirection(&localized_strings);
111 response = jstemplate_builder::GetI18nTemplateHtml( 109 response = jstemplate_builder::GetI18nTemplateHtml(
112 html, &localized_strings); 110 html, &localized_strings);
111 } else if (path_raw == chrome::kSyncSetupDonePath) {
112 DictionaryValue localized_strings;
113 localized_strings.SetString(L"success",
114 l10n_util::GetString(IDS_SYNC_SUCCESS));
115 localized_strings.SetString(L"setupsummary",
116 l10n_util::GetString(IDS_SYNC_SETUP_ALL_DONE));
117 localized_strings.SetString(L"firsttimesetupsummary",
118 l10n_util::GetString(IDS_SYNC_SETUP_FIRST_TIME_ALL_DONE));
119 localized_strings.SetString(L"okay",
120 l10n_util::GetString(IDS_SYNC_SETUP_OK_BUTTON_LABEL));
121 static const base::StringPiece html(ResourceBundle::GetSharedInstance()
122 .GetRawDataResource(IDR_SYNC_SETUP_DONE_HTML));
123 SetFontAndTextDirection(&localized_strings);
124 response = jstemplate_builder::GetI18nTemplateHtml(
125 html, &localized_strings);
113 } else if (path_raw == chrome::kSyncSetupFlowPath) { 126 } else if (path_raw == chrome::kSyncSetupFlowPath) {
114 static const base::StringPiece html(ResourceBundle::GetSharedInstance() 127 static const base::StringPiece html(ResourceBundle::GetSharedInstance()
115 .GetRawDataResource(IDR_SYNC_SETUP_FLOW_HTML)); 128 .GetRawDataResource(IDR_SYNC_SETUP_FLOW_HTML));
116 response = html.as_string(); 129 response = html.as_string();
117 } 130 }
118 // Send the response. 131 // Send the response.
119 html_bytes->data.resize(response.size()); 132 html_bytes->data.resize(response.size());
120 std::copy(response.begin(), response.end(), html_bytes->data.begin()); 133 std::copy(response.begin(), response.end(), html_bytes->data.begin());
121 SendResponse(request_id, html_bytes); 134 SendResponse(request_id, html_bytes);
122 } 135 }
(...skipping 16 matching lines...) Expand all
139 delete flow_container_; 152 delete flow_container_;
140 } 153 }
141 154
142 void SyncSetupWizard::Step(State advance_state) { 155 void SyncSetupWizard::Step(State advance_state) {
143 SyncSetupFlow* flow = flow_container_->get_flow(); 156 SyncSetupFlow* flow = flow_container_->get_flow();
144 if (flow) { 157 if (flow) {
145 // A setup flow is in progress and dialog is currently showing. 158 // A setup flow is in progress and dialog is currently showing.
146 flow->Advance(advance_state); 159 flow->Advance(advance_state);
147 } else if (!service_->profile()->GetPrefs()->GetBoolean( 160 } else if (!service_->profile()->GetPrefs()->GetBoolean(
148 prefs::kSyncHasSetupCompleted)) { 161 prefs::kSyncHasSetupCompleted)) {
149 if (advance_state == DONE || advance_state == GAIA_SUCCESS) 162 if (IsTerminalState(advance_state))
150 return; 163 return;
151 // No flow is in progress, and we have never escorted the user all the 164 // No flow is in progress, and we have never escorted the user all the
152 // way through the wizard flow. 165 // way through the wizard flow.
153 flow_container_->set_flow( 166 flow_container_->set_flow(
154 SyncSetupFlow::Run(service_, flow_container_, advance_state, DONE)); 167 SyncSetupFlow::Run(service_, flow_container_, advance_state, DONE));
155 } else { 168 } else {
156 // No flow in in progress, but we've finished the wizard flow once before. 169 // No flow in in progress, but we've finished the wizard flow once before.
157 // This is just a discrete run. 170 // This is just a discrete run.
158 if (advance_state == DONE || advance_state == GAIA_SUCCESS) 171 if (IsTerminalState(advance_state))
159 return; // Nothing to do. 172 return; // Nothing to do.
160 flow_container_->set_flow(SyncSetupFlow::Run(service_, flow_container_, 173 flow_container_->set_flow(SyncSetupFlow::Run(service_, flow_container_,
161 advance_state, GetEndStateForDiscreteRun(advance_state))); 174 advance_state, GetEndStateForDiscreteRun(advance_state)));
162 } 175 }
163 } 176 }
164 177
178 // static
179 bool SyncSetupWizard::IsTerminalState(State advance_state) {
180 return advance_state == GAIA_SUCCESS ||
181 advance_state == DONE ||
182 advance_state == DONE_FIRST_TIME ||
183 advance_state == FATAL_ERROR;
184 }
185
165 bool SyncSetupWizard::IsVisible() const { 186 bool SyncSetupWizard::IsVisible() const {
166 return flow_container_->get_flow() != NULL; 187 return flow_container_->get_flow() != NULL;
167 } 188 }
168 189
169 // static 190 // static
170 SyncSetupWizard::State SyncSetupWizard::GetEndStateForDiscreteRun( 191 SyncSetupWizard::State SyncSetupWizard::GetEndStateForDiscreteRun(
171 State start_state) { 192 State start_state) {
172 State result = start_state == GAIA_LOGIN ? GAIA_SUCCESS : DONE; 193 State result = start_state == GAIA_LOGIN ? GAIA_SUCCESS : DONE;
173 DCHECK_NE(DONE, result) << 194 DCHECK_NE(DONE, result) <<
174 "Invalid start state for discrete run: " << start_state; 195 "Invalid start state for discrete run: " << start_state;
175 return result; 196 return result;
176 } 197 }
177 198
178 #endif // CHROME_PERSONALIZATION 199 #endif // CHROME_PERSONALIZATION
OLDNEW
« no previous file with comments | « chrome/browser/views/sync/sync_setup_wizard.h ('k') | chrome/browser/views/sync/sync_setup_wizard_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698