OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/sync/glue/sync_backend_host.h" | 7 #include "chrome/browser/sync/glue/sync_backend_host.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/file_path.h" | 15 #include "base/file_path.h" |
16 #include "base/file_util.h" | 16 #include "base/file_util.h" |
17 #include "base/location.h" | 17 #include "base/location.h" |
18 #include "base/memory/ref_counted.h" | |
18 #include "base/metrics/histogram.h" | 19 #include "base/metrics/histogram.h" |
19 #include "base/threading/sequenced_worker_pool.h" | 20 #include "base/threading/sequenced_worker_pool.h" |
20 #include "base/threading/thread_restrictions.h" | 21 #include "base/threading/thread_restrictions.h" |
21 #include "base/timer.h" | 22 #include "base/timer.h" |
22 #include "base/tracked_objects.h" | 23 #include "base/tracked_objects.h" |
23 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
25 #if defined(OS_WIN) | |
26 #include "base/win/windows_version.h" | |
27 #endif | |
24 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/signin/token_service.h" | 29 #include "chrome/browser/signin/token_service.h" |
30 #if defined(OS_WIN) | |
31 #include "chrome/browser/sync/credential_cache_win.h" | |
32 #endif | |
26 #include "chrome/browser/sync/glue/bridged_sync_notifier.h" | 33 #include "chrome/browser/sync/glue/bridged_sync_notifier.h" |
27 #include "chrome/browser/sync/glue/change_processor.h" | 34 #include "chrome/browser/sync/glue/change_processor.h" |
28 #include "chrome/browser/sync/glue/chrome_encryptor.h" | 35 #include "chrome/browser/sync/glue/chrome_encryptor.h" |
29 #include "chrome/browser/sync/glue/sync_backend_registrar.h" | 36 #include "chrome/browser/sync/glue/sync_backend_registrar.h" |
30 #include "chrome/browser/sync/invalidations/invalidator_storage.h" | 37 #include "chrome/browser/sync/invalidations/invalidator_storage.h" |
31 #include "chrome/browser/sync/sync_prefs.h" | 38 #include "chrome/browser/sync/sync_prefs.h" |
32 #include "chrome/common/chrome_notification_types.h" | 39 #include "chrome/common/chrome_notification_types.h" |
40 #include "chrome/common/chrome_paths_internal.h" | |
33 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
34 #include "chrome/common/chrome_version_info.h" | 42 #include "chrome/common/chrome_version_info.h" |
35 #include "chrome/common/net/gaia/gaia_constants.h" | 43 #include "chrome/common/net/gaia/gaia_constants.h" |
36 #include "content/public/browser/browser_thread.h" | 44 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/notification_service.h" | 45 #include "content/public/browser/notification_service.h" |
38 #include "content/public/common/content_client.h" | 46 #include "content/public/common/content_client.h" |
39 #include "jingle/notifier/base/notification_method.h" | 47 #include "jingle/notifier/base/notification_method.h" |
40 #include "jingle/notifier/base/notifier_options.h" | 48 #include "jingle/notifier/base/notifier_options.h" |
41 #include "net/base/host_port_pair.h" | 49 #include "net/base/host_port_pair.h" |
42 #include "net/url_request/url_request_context_getter.h" | 50 #include "net/url_request/url_request_context_getter.h" |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1301 break; | 1309 break; |
1302 default: | 1310 default: |
1303 NOTREACHED(); | 1311 NOTREACHED(); |
1304 } | 1312 } |
1305 } | 1313 } |
1306 | 1314 |
1307 void SyncBackendHost::PersistEncryptionBootstrapToken( | 1315 void SyncBackendHost::PersistEncryptionBootstrapToken( |
1308 const std::string& token) { | 1316 const std::string& token) { |
1309 CHECK(sync_prefs_.get()); | 1317 CHECK(sync_prefs_.get()); |
1310 sync_prefs_->SetEncryptionBootstrapToken(token); | 1318 sync_prefs_->SetEncryptionBootstrapToken(token); |
1319 | |
1320 #if defined(OS_WIN) | |
1321 // On Windows 8, we persist the encryption bootstrap token to a separate cache | |
1322 // for sync credentials on Desktop (or Metro) Chrome so that when the | |
1323 // corresponding Metro (or Desktop) Chrome is subsequently launched, we can | |
1324 // automatically bootstrap sync for encrypted types without the user having to | |
1325 // manually enter a sync passphrase all over again. | |
1326 // Note: We currently do this only for the "Default" profile, because there is | |
1327 // no 1:1 correspondence between non-default profiles on Metro and Desktop. | |
1328 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | |
1329 csync::CredentialCache::IsDefaultProfileDir(profile_->GetPath())) { | |
1330 scoped_refptr<csync::CredentialCache> credentials = | |
1331 new csync::CredentialCache("", "", "", token, profile_->GetPath()); | |
1332 BrowserThread::PostTask( | |
1333 BrowserThread::FILE, | |
1334 FROM_HERE, | |
1335 base::Bind(&csync::CredentialCache::PersistEncryptionBootstrapToken, | |
1336 credentials)); | |
Roger Tawa OOO till Jul 10th
2012/06/27 21:23:28
why create a csync::CredentialCache instead of jus
Raghu Simha
2012/07/19 06:57:07
We now create a CredentialCacheService using a Cre
| |
1337 } | |
1338 #endif // OS_WIN | |
1311 } | 1339 } |
1312 | 1340 |
1313 void SyncBackendHost::HandleActionableErrorEventOnFrontendLoop( | 1341 void SyncBackendHost::HandleActionableErrorEventOnFrontendLoop( |
1314 const csync::SyncProtocolError& sync_error) { | 1342 const csync::SyncProtocolError& sync_error) { |
1315 if (!frontend_) | 1343 if (!frontend_) |
1316 return; | 1344 return; |
1317 DCHECK_EQ(MessageLoop::current(), frontend_loop_); | 1345 DCHECK_EQ(MessageLoop::current(), frontend_loop_); |
1318 frontend_->OnActionableError(sync_error); | 1346 frontend_->OnActionableError(sync_error); |
1319 } | 1347 } |
1320 | 1348 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1425 FROM_HERE, | 1453 FROM_HERE, |
1426 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, | 1454 base::Bind(&SyncBackendHost::Core::DoRefreshNigori, |
1427 core_.get(), sync_thread_done_callback)); | 1455 core_.get(), sync_thread_done_callback)); |
1428 } | 1456 } |
1429 | 1457 |
1430 #undef SDVLOG | 1458 #undef SDVLOG |
1431 | 1459 |
1432 #undef SLOG | 1460 #undef SLOG |
1433 | 1461 |
1434 } // namespace browser_sync | 1462 } // namespace browser_sync |
OLD | NEW |