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

Side by Side Diff: chrome/browser/sync/glue/sync_backend_host.cc

Issue 15421011: Use OAuth2 token for sync (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 7 years, 6 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
OLDNEW
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>
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 316
317 namespace { 317 namespace {
318 318
319 // Parses the given command line for notifier options. 319 // Parses the given command line for notifier options.
320 notifier::NotifierOptions ParseNotifierOptions( 320 notifier::NotifierOptions ParseNotifierOptions(
321 const CommandLine& command_line, 321 const CommandLine& command_line,
322 const scoped_refptr<net::URLRequestContextGetter>& 322 const scoped_refptr<net::URLRequestContextGetter>&
323 request_context_getter) { 323 request_context_getter) {
324 notifier::NotifierOptions notifier_options; 324 notifier::NotifierOptions notifier_options;
325 notifier_options.request_context_getter = request_context_getter; 325 notifier_options.request_context_getter = request_context_getter;
326 if (!command_line.HasSwitch(switches::kSyncDisableOAuth2Token))
327 notifier_options.auth_mechanism = "X-OAUTH2";
326 328
327 if (command_line.HasSwitch(switches::kSyncNotificationHostPort)) { 329 if (command_line.HasSwitch(switches::kSyncNotificationHostPort)) {
328 notifier_options.xmpp_host_port = 330 notifier_options.xmpp_host_port =
329 net::HostPortPair::FromString( 331 net::HostPortPair::FromString(
330 command_line.GetSwitchValueASCII( 332 command_line.GetSwitchValueASCII(
331 switches::kSyncNotificationHostPort)); 333 switches::kSyncNotificationHostPort));
332 DVLOG(1) << "Using " << notifier_options.xmpp_host_port.ToString() 334 DVLOG(1) << "Using " << notifier_options.xmpp_host_port.ToString()
333 << " for test sync notification server."; 335 << " for test sync notification server.";
334 } 336 }
335 337
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 NetworkTimeTracker::BuildNotifierUpdateCallback()), 475 NetworkTimeTracker::BuildNotifierUpdateCallback()),
474 credentials, 476 credentials,
475 android_invalidator_bridge_.get(), 477 android_invalidator_bridge_.get(),
476 &invalidator_factory_, 478 &invalidator_factory_,
477 sync_manager_factory, 479 sync_manager_factory,
478 delete_sync_data_folder, 480 delete_sync_data_folder,
479 sync_prefs_->GetEncryptionBootstrapToken(), 481 sync_prefs_->GetEncryptionBootstrapToken(),
480 sync_prefs_->GetKeystoreEncryptionBootstrapToken(), 482 sync_prefs_->GetKeystoreEncryptionBootstrapToken(),
481 new InternalComponentsFactoryImpl(factory_switches), 483 new InternalComponentsFactoryImpl(factory_switches),
482 unrecoverable_error_handler, 484 unrecoverable_error_handler,
483 report_unrecoverable_error_function)); 485 report_unrecoverable_error_function,
486 !cl->HasSwitch(switches::kSyncDisableOAuth2Token)));
484 } 487 }
485 488
486 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) { 489 void SyncBackendHost::UpdateCredentials(const SyncCredentials& credentials) {
487 DCHECK(sync_thread_.IsRunning()); 490 DCHECK(sync_thread_.IsRunning());
488 sync_thread_.message_loop()->PostTask(FROM_HERE, 491 sync_thread_.message_loop()->PostTask(FROM_HERE,
489 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(), 492 base::Bind(&SyncBackendHost::Core::DoUpdateCredentials, core_.get(),
490 credentials)); 493 credentials));
491 } 494 }
492 495
493 void SyncBackendHost::UpdateRegisteredInvalidationIds( 496 void SyncBackendHost::UpdateRegisteredInvalidationIds(
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 const syncer::SyncCredentials& credentials, 960 const syncer::SyncCredentials& credentials,
958 AndroidInvalidatorBridge* android_invalidator_bridge, 961 AndroidInvalidatorBridge* android_invalidator_bridge,
959 syncer::InvalidatorFactory* invalidator_factory, 962 syncer::InvalidatorFactory* invalidator_factory,
960 syncer::SyncManagerFactory* sync_manager_factory, 963 syncer::SyncManagerFactory* sync_manager_factory,
961 bool delete_sync_data_folder, 964 bool delete_sync_data_folder,
962 const std::string& restored_key_for_bootstrapping, 965 const std::string& restored_key_for_bootstrapping,
963 const std::string& restored_keystore_key_for_bootstrapping, 966 const std::string& restored_keystore_key_for_bootstrapping,
964 InternalComponentsFactory* internal_components_factory, 967 InternalComponentsFactory* internal_components_factory,
965 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler, 968 syncer::UnrecoverableErrorHandler* unrecoverable_error_handler,
966 syncer::ReportUnrecoverableErrorFunction 969 syncer::ReportUnrecoverableErrorFunction
967 report_unrecoverable_error_function) 970 report_unrecoverable_error_function,
971 bool use_oauth2_token)
968 : sync_loop(sync_loop), 972 : sync_loop(sync_loop),
969 registrar(registrar), 973 registrar(registrar),
970 routing_info(routing_info), 974 routing_info(routing_info),
971 workers(workers), 975 workers(workers),
972 extensions_activity_monitor(extensions_activity_monitor), 976 extensions_activity_monitor(extensions_activity_monitor),
973 event_handler(event_handler), 977 event_handler(event_handler),
974 service_url(service_url), 978 service_url(service_url),
975 make_http_bridge_factory_fn(make_http_bridge_factory_fn), 979 make_http_bridge_factory_fn(make_http_bridge_factory_fn),
976 credentials(credentials), 980 credentials(credentials),
977 android_invalidator_bridge(android_invalidator_bridge), 981 android_invalidator_bridge(android_invalidator_bridge),
978 invalidator_factory(invalidator_factory), 982 invalidator_factory(invalidator_factory),
979 sync_manager_factory(sync_manager_factory), 983 sync_manager_factory(sync_manager_factory),
980 delete_sync_data_folder(delete_sync_data_folder), 984 delete_sync_data_folder(delete_sync_data_folder),
981 restored_key_for_bootstrapping(restored_key_for_bootstrapping), 985 restored_key_for_bootstrapping(restored_key_for_bootstrapping),
982 restored_keystore_key_for_bootstrapping( 986 restored_keystore_key_for_bootstrapping(
983 restored_keystore_key_for_bootstrapping), 987 restored_keystore_key_for_bootstrapping),
984 internal_components_factory(internal_components_factory), 988 internal_components_factory(internal_components_factory),
985 unrecoverable_error_handler(unrecoverable_error_handler), 989 unrecoverable_error_handler(unrecoverable_error_handler),
986 report_unrecoverable_error_function( 990 report_unrecoverable_error_function(
987 report_unrecoverable_error_function) { 991 report_unrecoverable_error_function),
992 use_oauth2_token(use_oauth2_token) {
988 } 993 }
989 994
990 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {} 995 SyncBackendHost::DoInitializeOptions::~DoInitializeOptions() {}
991 996
992 SyncBackendHost::Core::Core(const std::string& name, 997 SyncBackendHost::Core::Core(const std::string& name,
993 const base::FilePath& sync_data_folder_path, 998 const base::FilePath& sync_data_folder_path,
994 const base::WeakPtr<SyncBackendHost>& backend) 999 const base::WeakPtr<SyncBackendHost>& backend)
995 : name_(name), 1000 : name_(name),
996 sync_data_folder_path_(sync_data_folder_path), 1001 sync_data_folder_path_(sync_data_folder_path),
997 host_(backend), 1002 host_(backend),
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 scoped_ptr<syncer::Invalidator>( 1259 scoped_ptr<syncer::Invalidator>(
1255 options.invalidator_factory->CreateInvalidator()), 1260 options.invalidator_factory->CreateInvalidator()),
1256 #endif 1261 #endif
1257 options.invalidator_factory->GetInvalidatorClientId(), 1262 options.invalidator_factory->GetInvalidatorClientId(),
1258 options.restored_key_for_bootstrapping, 1263 options.restored_key_for_bootstrapping,
1259 options.restored_keystore_key_for_bootstrapping, 1264 options.restored_keystore_key_for_bootstrapping,
1260 scoped_ptr<InternalComponentsFactory>( 1265 scoped_ptr<InternalComponentsFactory>(
1261 options.internal_components_factory), 1266 options.internal_components_factory),
1262 &encryptor_, 1267 &encryptor_,
1263 options.unrecoverable_error_handler, 1268 options.unrecoverable_error_handler,
1264 options.report_unrecoverable_error_function); 1269 options.report_unrecoverable_error_function,
1270 options.use_oauth2_token);
1265 1271
1266 // |sync_manager_| may end up being NULL here in tests (in 1272 // |sync_manager_| may end up being NULL here in tests (in
1267 // synchronous initialization mode). 1273 // synchronous initialization mode).
1268 // 1274 //
1269 // TODO(akalin): Fix this behavior (see http://crbug.com/140354). 1275 // TODO(akalin): Fix this behavior (see http://crbug.com/140354).
1270 if (sync_manager_) { 1276 if (sync_manager_) {
1271 sync_manager_->RegisterInvalidationHandler(this); 1277 sync_manager_->RegisterInvalidationHandler(this);
1272 registered_as_invalidation_handler_ = true; 1278 registered_as_invalidation_handler_ = true;
1273 1279
1274 // Now check the command line to see if we need to simulate an 1280 // Now check the command line to see if we need to simulate an
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 DVLOG(1) << "Connection status changed: " 1726 DVLOG(1) << "Connection status changed: "
1721 << syncer::ConnectionStatusToString(status); 1727 << syncer::ConnectionStatusToString(status);
1722 frontend_->OnConnectionStatusChange(status); 1728 frontend_->OnConnectionStatusChange(status);
1723 } 1729 }
1724 1730
1725 #undef SDVLOG 1731 #undef SDVLOG
1726 1732
1727 #undef SLOG 1733 #undef SLOG
1728 1734
1729 } // namespace browser_sync 1735 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/profile_sync_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698