OLD | NEW |
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/sync/sync_setup_flow.h" | 5 #include "chrome/browser/sync/sync_setup_flow.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/platform_util.h" | 14 #include "chrome/browser/platform_util.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/sync/profile_sync_service.h" | 17 #include "chrome/browser/sync/profile_sync_service.h" |
18 #include "chrome/browser/sync/sync_setup_flow_handler.h" | 18 #include "chrome/browser/sync/sync_setup_flow_handler.h" |
19 #include "chrome/browser/ui/browser.h" | |
20 #include "chrome/browser/ui/browser_dialogs.h" | |
21 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
22 #include "chrome/common/net/gaia/google_service_auth_error.h" | 20 #include "chrome/common/net/gaia/google_service_auth_error.h" |
23 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
24 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
25 #include "content/browser/renderer_host/render_view_host.h" | 23 #include "content/browser/renderer_host/render_view_host.h" |
26 #include "content/browser/tab_contents/tab_contents.h" | 24 #include "content/browser/tab_contents/tab_contents.h" |
27 #include "grit/generated_resources.h" | 25 #include "grit/generated_resources.h" |
28 #include "grit/locale_settings.h" | 26 #include "grit/locale_settings.h" |
29 #include "ui/base/l10n/l10n_font_util.h" | 27 #include "ui/base/l10n/l10n_font_util.h" |
30 #include "ui/gfx/font.h" | 28 #include "ui/gfx/font.h" |
(...skipping 30 matching lines...) Expand all Loading... |
61 if (start == SyncSetupWizard::GAIA_LOGIN) | 59 if (start == SyncSetupWizard::GAIA_LOGIN) |
62 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); | 60 SyncSetupFlow::GetArgsForGaiaLogin(service, &args); |
63 else if (start == SyncSetupWizard::CONFIGURE) | 61 else if (start == SyncSetupWizard::CONFIGURE) |
64 SyncSetupFlow::GetArgsForConfigure(service, &args); | 62 SyncSetupFlow::GetArgsForConfigure(service, &args); |
65 else if (start == SyncSetupWizard::ENTER_PASSPHRASE) | 63 else if (start == SyncSetupWizard::ENTER_PASSPHRASE) |
66 SyncSetupFlow::GetArgsForEnterPassphrase(false, false, &args); | 64 SyncSetupFlow::GetArgsForEnterPassphrase(false, false, &args); |
67 | 65 |
68 std::string json_args; | 66 std::string json_args; |
69 base::JSONWriter::Write(&args, false, &json_args); | 67 base::JSONWriter::Write(&args, false, &json_args); |
70 | 68 |
71 SyncSetupFlow* flow = new SyncSetupFlow(start, end, json_args, | 69 return new SyncSetupFlow(start, end, json_args, container, service); |
72 container, service); | |
73 | |
74 Browser* b = BrowserList::GetLastActive(); | |
75 b->ShowOptionsTab(chrome::kSyncSetupSubPage); | |
76 return flow; | |
77 } | 70 } |
78 | 71 |
79 // static | 72 // static |
80 void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service, | 73 void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service, |
81 DictionaryValue* args) { | 74 DictionaryValue* args) { |
82 const GoogleServiceAuthError& error = service->GetAuthError(); | 75 const GoogleServiceAuthError& error = service->GetAuthError(); |
83 if (!service->last_attempted_user_email().empty()) { | 76 if (!service->last_attempted_user_email().empty()) { |
84 args->SetString("user", service->last_attempted_user_email()); | 77 args->SetString("user", service->last_attempted_user_email()); |
85 args->SetInteger("error", error.state()); | 78 args->SetInteger("error", error.state()); |
86 args->SetBoolean("editable_user", true); | 79 args->SetBoolean("editable_user", true); |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 366 } |
374 case SyncSetupWizard::DONE: | 367 case SyncSetupWizard::DONE: |
375 flow_handler_->ShowSetupDone( | 368 flow_handler_->ShowSetupDone( |
376 UTF16ToWide(service_->GetAuthenticatedUsername())); | 369 UTF16ToWide(service_->GetAuthenticatedUsername())); |
377 break; | 370 break; |
378 default: | 371 default: |
379 NOTREACHED() << "Invalid advance state: " << state; | 372 NOTREACHED() << "Invalid advance state: " << state; |
380 } | 373 } |
381 current_state_ = state; | 374 current_state_ = state; |
382 } | 375 } |
OLD | NEW |