OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/singleton.h" | 8 #include "base/singleton.h" |
9 #include "chrome/browser/browser_thread.h" | 9 #include "chrome/browser/browser_thread.h" |
10 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" | 10 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 GURL original_url(url); | 253 GURL original_url(url); |
254 DCHECK(original_url.is_valid()); | 254 DCHECK(original_url.is_valid()); |
255 GURL localized_url = google_util::AppendGoogleLocaleParam(original_url); | 255 GURL localized_url = google_util::AppendGoogleLocaleParam(original_url); |
256 return localized_url.spec(); | 256 return localized_url.spec(); |
257 } | 257 } |
258 | 258 |
259 SyncSetupWizard::SyncSetupWizard(ProfileSyncService* service) | 259 SyncSetupWizard::SyncSetupWizard(ProfileSyncService* service) |
260 : service_(service), | 260 : service_(service), |
261 flow_container_(new SyncSetupFlowContainer()), | 261 flow_container_(new SyncSetupFlowContainer()), |
262 parent_window_(NULL) { | 262 parent_window_(NULL) { |
263 // If we're in a unit test, we may not have an IO thread. Avoid | 263 // If we're in a unit test, we may not have an IO thread or profile. Avoid |
264 // creating a SyncResourcesSource since we may leak it (since it's | 264 // creating a SyncResourcesSource since we may leak it (since it's |
265 // DeleteOnUIThread). | 265 // DeleteOnUIThread). |
266 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO)) { | 266 if (BrowserThread::IsMessageLoopValid(BrowserThread::IO) && |
| 267 service_->profile()) { |
267 // Add our network layer data source for 'cloudy' URLs. | 268 // Add our network layer data source for 'cloudy' URLs. |
268 SyncResourcesSource* sync_source = new SyncResourcesSource(); | 269 SyncResourcesSource* sync_source = new SyncResourcesSource(); |
269 bool posted = | 270 service_->profile()->GetChromeURLDataManager()->AddDataSource(sync_source); |
270 BrowserThread::PostTask( | |
271 BrowserThread::IO, FROM_HERE, | |
272 NewRunnableMethod(ChromeURLDataManager::GetInstance(), | |
273 &ChromeURLDataManager::AddDataSource, | |
274 make_scoped_refptr(sync_source))); | |
275 DCHECK(posted); | |
276 } | 271 } |
277 } | 272 } |
278 | 273 |
279 SyncSetupWizard::~SyncSetupWizard() { | 274 SyncSetupWizard::~SyncSetupWizard() { |
280 delete flow_container_; | 275 delete flow_container_; |
281 } | 276 } |
282 | 277 |
283 void SyncSetupWizard::Step(State advance_state) { | 278 void SyncSetupWizard::Step(State advance_state) { |
284 SyncSetupFlow* flow = flow_container_->get_flow(); | 279 SyncSetupFlow* flow = flow_container_->get_flow(); |
285 if (flow) { | 280 if (flow) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 result = GAIA_SUCCESS; | 332 result = GAIA_SUCCESS; |
338 } else if (start_state == ENTER_PASSPHRASE || | 333 } else if (start_state == ENTER_PASSPHRASE || |
339 start_state == CONFIGURE || | 334 start_state == CONFIGURE || |
340 start_state == PASSPHRASE_MIGRATION) { | 335 start_state == PASSPHRASE_MIGRATION) { |
341 result = DONE; | 336 result = DONE; |
342 } | 337 } |
343 DCHECK_NE(FATAL_ERROR, result) << | 338 DCHECK_NE(FATAL_ERROR, result) << |
344 "Invalid start state for discrete run: " << start_state; | 339 "Invalid start state for discrete run: " << start_state; |
345 return result; | 340 return result; |
346 } | 341 } |
OLD | NEW |