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

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

Issue 385103: Moved the various Google Accounts URLs out of gaia_login.html and into sync_s... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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
« no previous file with comments | « chrome/browser/sync/resources/gaia_login.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/sync/sync_setup_wizard.h" 5 #include "chrome/browser/sync/sync_setup_wizard.h"
6 6
7 #include "app/resource_bundle.h" 7 #include "app/resource_bundle.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/singleton.h" 9 #include "base/singleton.h"
10 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
11 #include "chrome/common/pref_service.h" 11 #include "chrome/common/pref_service.h"
12 #include "chrome/browser/chrome_thread.h" 12 #include "chrome/browser/chrome_thread.h"
13 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" 13 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
14 #include "chrome/browser/google_util.h"
14 #include "chrome/browser/sync/profile_sync_service.h" 15 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/browser/sync/sync_setup_flow.h" 16 #include "chrome/browser/sync/sync_setup_flow.h"
16 #include "chrome/common/jstemplate_builder.h" 17 #include "chrome/common/jstemplate_builder.h"
17 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
19 #include "googleurl/src/gurl.h"
18 #include "grit/app_resources.h" 20 #include "grit/app_resources.h"
19 #include "grit/browser_resources.h" 21 #include "grit/browser_resources.h"
20 22
21 class SyncResourcesSource : public ChromeURLDataManager::DataSource { 23 class SyncResourcesSource : public ChromeURLDataManager::DataSource {
22 public: 24 public:
23 SyncResourcesSource() 25 SyncResourcesSource()
24 : DataSource(chrome::kSyncResourcesHost, MessageLoop::current()) { 26 : DataSource(chrome::kSyncResourcesHost, MessageLoop::current()) {
25 } 27 }
26 28
27 virtual void StartDataRequest(const std::string& path, int request_id); 29 virtual void StartDataRequest(const std::string& path, int request_id);
28 30
29 virtual std::string GetMimeType(const std::string& path) const { 31 virtual std::string GetMimeType(const std::string& path) const {
30 if (path == chrome::kSyncThrobberPath) 32 if (path == chrome::kSyncThrobberPath)
31 return "image/png"; 33 return "image/png";
32 else 34 else
33 return "text/html"; 35 return "text/html";
34 } 36 }
35 37
38 static const char* kInvalidPasswordHelpUrl;
39 static const char* kCanNotAccessAccountUrl;
40 static const char* kCreateNewAccountUrl;
41
36 private: 42 private:
37 virtual ~SyncResourcesSource() {} 43 virtual ~SyncResourcesSource() {}
38 44
45 // Takes a string containing an URL and returns an URL containing a CGI
46 // parameter of the form "&hl=xy" where 'xy' is the language code of the
47 // current locale.
48 std::string GetLocalizedUrl(const std::string& url) const;
49
39 DISALLOW_COPY_AND_ASSIGN(SyncResourcesSource); 50 DISALLOW_COPY_AND_ASSIGN(SyncResourcesSource);
40 }; 51 };
41 52
53 const char* SyncResourcesSource::kInvalidPasswordHelpUrl =
54 "http://www.google.com/support/accounts/bin/answer.py?ctx=ch&answer=27444";
55 const char* SyncResourcesSource::kCanNotAccessAccountUrl =
56 "http://www.google.com/support/accounts/bin/answer.py?answer=48598";
57 const char* SyncResourcesSource::kCreateNewAccountUrl =
58 "https://www.google.com/accounts/NewAccount?service=chromiumsync";
59
42 void SyncResourcesSource::StartDataRequest(const std::string& path_raw, 60 void SyncResourcesSource::StartDataRequest(const std::string& path_raw,
43 int request_id) { 61 int request_id) {
44 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes); 62 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
45 if (path_raw == chrome::kSyncThrobberPath) { 63 if (path_raw == chrome::kSyncThrobberPath) {
46 scoped_refptr<RefCountedMemory> throbber( 64 scoped_refptr<RefCountedMemory> throbber(
47 ResourceBundle::GetSharedInstance().LoadImageResourceBytes( 65 ResourceBundle::GetSharedInstance().LoadImageResourceBytes(
48 IDR_THROBBER)); 66 IDR_THROBBER));
49 SendResponse(request_id, throbber); 67 SendResponse(request_id, throbber);
50 return; 68 return;
51 } 69 }
52 70
53 std::string response; 71 std::string response;
54 if (path_raw == chrome::kSyncGaiaLoginPath) { 72 if (path_raw == chrome::kSyncGaiaLoginPath) {
55 DictionaryValue localized_strings; 73 DictionaryValue localized_strings;
74
75 // Start by setting the per-locale URLs we show on the setup wizard.
76 localized_strings.SetString(L"invalidpasswordhelpurl",
77 GetLocalizedUrl(kInvalidPasswordHelpUrl));
78 localized_strings.SetString(L"cannotaccessaccounturl",
79 GetLocalizedUrl(kCanNotAccessAccountUrl));
80 localized_strings.SetString(L"createnewaccounturl",
81 GetLocalizedUrl(kCreateNewAccountUrl));
82
56 localized_strings.SetString(L"settingupsync", 83 localized_strings.SetString(L"settingupsync",
57 l10n_util::GetString(IDS_SYNC_LOGIN_SETTING_UP_SYNC)); 84 l10n_util::GetString(IDS_SYNC_LOGIN_SETTING_UP_SYNC));
58 localized_strings.SetString(L"introduction", 85 localized_strings.SetString(L"introduction",
59 l10n_util::GetString(IDS_SYNC_LOGIN_INTRODUCTION)); 86 l10n_util::GetString(IDS_SYNC_LOGIN_INTRODUCTION));
60 localized_strings.SetString(L"signinprefix", 87 localized_strings.SetString(L"signinprefix",
61 l10n_util::GetString(IDS_SYNC_LOGIN_SIGNIN_PREFIX)); 88 l10n_util::GetString(IDS_SYNC_LOGIN_SIGNIN_PREFIX));
62 localized_strings.SetString(L"signinsuffix", 89 localized_strings.SetString(L"signinsuffix",
63 l10n_util::GetString(IDS_SYNC_LOGIN_SIGNIN_SUFFIX)); 90 l10n_util::GetString(IDS_SYNC_LOGIN_SIGNIN_SUFFIX));
64 localized_strings.SetString(L"cannotbeblank", 91 localized_strings.SetString(L"cannotbeblank",
65 l10n_util::GetString(IDS_SYNC_CANNOT_BE_BLANK)); 92 l10n_util::GetString(IDS_SYNC_CANNOT_BE_BLANK));
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 static const base::StringPiece html(ResourceBundle::GetSharedInstance() 158 static const base::StringPiece html(ResourceBundle::GetSharedInstance()
132 .GetRawDataResource(IDR_SYNC_SETUP_FLOW_HTML)); 159 .GetRawDataResource(IDR_SYNC_SETUP_FLOW_HTML));
133 response = html.as_string(); 160 response = html.as_string();
134 } 161 }
135 // Send the response. 162 // Send the response.
136 html_bytes->data.resize(response.size()); 163 html_bytes->data.resize(response.size());
137 std::copy(response.begin(), response.end(), html_bytes->data.begin()); 164 std::copy(response.begin(), response.end(), html_bytes->data.begin());
138 SendResponse(request_id, html_bytes); 165 SendResponse(request_id, html_bytes);
139 } 166 }
140 167
168 std::string SyncResourcesSource::GetLocalizedUrl(
169 const std::string& url) const {
170 GURL original_url(url);
171 DCHECK(original_url.is_valid());
172 GURL localized_url = google_util::AppendGoogleLocaleParam(original_url);
173 return localized_url.spec();
174 }
175
141 SyncSetupWizard::SyncSetupWizard(ProfileSyncService* service) 176 SyncSetupWizard::SyncSetupWizard(ProfileSyncService* service)
142 : service_(service), 177 : service_(service),
143 flow_container_(new SyncSetupFlowContainer()) { 178 flow_container_(new SyncSetupFlowContainer()) {
144 // Add our network layer data source for 'cloudy' URLs. 179 // Add our network layer data source for 'cloudy' URLs.
145 SyncResourcesSource* sync_source = new SyncResourcesSource(); 180 SyncResourcesSource* sync_source = new SyncResourcesSource();
146 bool posted = ChromeThread::PostTask( 181 bool posted = ChromeThread::PostTask(
147 ChromeThread::IO, FROM_HERE, 182 ChromeThread::IO, FROM_HERE,
148 NewRunnableMethod(Singleton<ChromeURLDataManager>::get(), 183 NewRunnableMethod(Singleton<ChromeURLDataManager>::get(),
149 &ChromeURLDataManager::AddDataSource, 184 &ChromeURLDataManager::AddDataSource,
150 sync_source)); 185 sync_source));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 } 229 }
195 230
196 // static 231 // static
197 SyncSetupWizard::State SyncSetupWizard::GetEndStateForDiscreteRun( 232 SyncSetupWizard::State SyncSetupWizard::GetEndStateForDiscreteRun(
198 State start_state) { 233 State start_state) {
199 State result = start_state == GAIA_LOGIN ? GAIA_SUCCESS : DONE; 234 State result = start_state == GAIA_LOGIN ? GAIA_SUCCESS : DONE;
200 DCHECK_NE(DONE, result) << 235 DCHECK_NE(DONE, result) <<
201 "Invalid start state for discrete run: " << start_state; 236 "Invalid start state for discrete run: " << start_state;
202 return result; 237 return result;
203 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/resources/gaia_login.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698