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

Side by Side Diff: chrome/browser/ui/webui/options/sync_setup_handler.cc

Issue 7057038: dom-ui sync: Eliminate jank when customizing sync settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: win/linux tweaks Created 9 years, 7 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) 2011 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/ui/webui/options/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/options/sync_setup_handler.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/google/google_util.h" 10 #include "chrome/browser/google/google_util.h"
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, 248 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX },
249 }; 249 };
250 250
251 RegisterStrings(localized_strings, resources, arraysize(resources)); 251 RegisterStrings(localized_strings, resources, arraysize(resources));
252 } 252 }
253 253
254 void SyncSetupHandler::Initialize() { 254 void SyncSetupHandler::Initialize() {
255 } 255 }
256 256
257 void SyncSetupHandler::RegisterMessages() { 257 void SyncSetupHandler::RegisterMessages() {
258 web_ui_->RegisterMessageCallback("didShowPage", 258 web_ui_->RegisterMessageCallback("SyncSetupDidClosePage",
259 NewCallback(this, &SyncSetupHandler::OnDidShowPage));
260 web_ui_->RegisterMessageCallback("didClosePage",
261 NewCallback(this, &SyncSetupHandler::OnDidClosePage)); 259 NewCallback(this, &SyncSetupHandler::OnDidClosePage));
262 web_ui_->RegisterMessageCallback("SubmitAuth", 260 web_ui_->RegisterMessageCallback("SyncSetupSubmitAuth",
263 NewCallback(this, &SyncSetupHandler::HandleSubmitAuth)); 261 NewCallback(this, &SyncSetupHandler::HandleSubmitAuth));
264 web_ui_->RegisterMessageCallback("Configure", 262 web_ui_->RegisterMessageCallback("SyncSetupConfigure",
265 NewCallback(this, &SyncSetupHandler::HandleConfigure)); 263 NewCallback(this, &SyncSetupHandler::HandleConfigure));
266 web_ui_->RegisterMessageCallback("Passphrase", 264 web_ui_->RegisterMessageCallback("SyncSetupPassphrase",
267 NewCallback(this, &SyncSetupHandler::HandlePassphraseEntry)); 265 NewCallback(this, &SyncSetupHandler::HandlePassphraseEntry));
268 web_ui_->RegisterMessageCallback("PassphraseCancel", 266 web_ui_->RegisterMessageCallback("SyncSetupPassphraseCancel",
269 NewCallback(this, &SyncSetupHandler::HandlePassphraseCancel)); 267 NewCallback(this, &SyncSetupHandler::HandlePassphraseCancel));
268 web_ui_->RegisterMessageCallback("SyncSetupAttachHandler",
269 NewCallback(this, &SyncSetupHandler::HandleAttachHandler));
270 } 270 }
271 271
272 void SyncSetupHandler::ShowGaiaLogin(const DictionaryValue& args) { 272 void SyncSetupHandler::ShowGaiaLogin(const DictionaryValue& args) {
273 StringValue page("login"); 273 StringValue page("login");
274 web_ui_->CallJavascriptFunction( 274 web_ui_->CallJavascriptFunction(
275 "SyncSetupOverlay.showSyncSetupPage", page, args); 275 "SyncSetupOverlay.showSyncSetupPage", page, args);
276 } 276 }
277 277
278 void SyncSetupHandler::ShowGaiaSuccessAndClose() { 278 void SyncSetupHandler::ShowGaiaSuccessAndClose() {
279 web_ui_->CallJavascriptFunction("SyncSetupOverlay.showSuccessAndClose"); 279 web_ui_->CallJavascriptFunction("SyncSetupOverlay.showSuccessAndClose");
(...skipping 24 matching lines...) Expand all
304 void SyncSetupHandler::ShowSetupDone(const std::wstring& user) { 304 void SyncSetupHandler::ShowSetupDone(const std::wstring& user) {
305 StringValue page("done"); 305 StringValue page("done");
306 web_ui_->CallJavascriptFunction( 306 web_ui_->CallJavascriptFunction(
307 "SyncSetupOverlay.showSyncSetupPage", page); 307 "SyncSetupOverlay.showSyncSetupPage", page);
308 } 308 }
309 309
310 void SyncSetupHandler::SetFlow(SyncSetupFlow* flow) { 310 void SyncSetupHandler::SetFlow(SyncSetupFlow* flow) {
311 flow_ = flow; 311 flow_ = flow;
312 } 312 }
313 313
314 void SyncSetupHandler::OnDidShowPage(const ListValue* args) {
315 DCHECK(web_ui_);
316
317 ProfileSyncService* sync_service =
318 web_ui_->GetProfile()->GetProfileSyncService();
319 if (!sync_service)
320 return;
321
322 flow_ = sync_service->get_wizard().AttachSyncSetupHandler(this);
323 }
324
325 void SyncSetupHandler::OnDidClosePage(const ListValue* args) { 314 void SyncSetupHandler::OnDidClosePage(const ListValue* args) {
326 flow_->OnDialogClosed(std::string()); 315 flow_->OnDialogClosed(std::string());
327 flow_ = NULL; 316 flow_ = NULL;
328 } 317 }
329 318
330 void SyncSetupHandler::HandleSubmitAuth(const ListValue* args) { 319 void SyncSetupHandler::HandleSubmitAuth(const ListValue* args) {
331 std::string json; 320 std::string json;
332 if (!args->GetString(0, &json)) { 321 if (!args->GetString(0, &json)) {
333 NOTREACHED() << "Could not read JSON argument"; 322 NOTREACHED() << "Could not read JSON argument";
334 return; 323 return;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 } 379 }
391 380
392 DCHECK(flow_); 381 DCHECK(flow_);
393 flow_->OnPassphraseEntry(passphrase); 382 flow_->OnPassphraseEntry(passphrase);
394 } 383 }
395 384
396 void SyncSetupHandler::HandlePassphraseCancel(const ListValue* args) { 385 void SyncSetupHandler::HandlePassphraseCancel(const ListValue* args) {
397 DCHECK(flow_); 386 DCHECK(flow_);
398 flow_->OnPassphraseCancel(); 387 flow_->OnPassphraseCancel();
399 } 388 }
389
390 void SyncSetupHandler::HandleAttachHandler(const ListValue* args) {
391 DCHECK(web_ui_);
392
393 ProfileSyncService* sync_service =
394 web_ui_->GetProfile()->GetProfileSyncService();
395 if (!sync_service)
396 return;
397
398 if (!flow_)
399 flow_ = sync_service->get_wizard().AttachSyncSetupHandler(this);
400 }
401
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698