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

Side by Side Diff: chrome/browser/sync/engine/net/syncapi_server_connection_manager.cc

Issue 7497069: Support Sync following Gaia OAuth authentication (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporating code review comments from Roger. Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
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/engine/net/syncapi_server_connection_manager.h" 5 #include "chrome/browser/sync/engine/net/syncapi_server_connection_manager.h"
6 6
7 #include "base/command_line.h"
7 #include "chrome/browser/sync/engine/http_post_provider_factory.h" 8 #include "chrome/browser/sync/engine/http_post_provider_factory.h"
8 #include "chrome/browser/sync/engine/http_post_provider_interface.h" 9 #include "chrome/browser/sync/engine/http_post_provider_interface.h"
9 #include "chrome/browser/sync/engine/syncapi.h" 10 #include "chrome/browser/sync/engine/syncapi.h"
11 #include "chrome/browser/sync/sync_setup_wizard.h"
tim (not reviewing) 2011/08/10 19:39:36 Although we don't have a DEPS rule enforcing this,
Rick Campbell 2011/08/11 03:58:23 Done. Eliminated SyncSetupWizard::IsUsingOAuth()
12 #include "chrome/common/chrome_switches.h"
10 #include "chrome/common/net/http_return.h" 13 #include "chrome/common/net/http_return.h"
11 14
12 using browser_sync::HttpResponse; 15 using browser_sync::HttpResponse;
13 16
14 namespace sync_api { 17 namespace sync_api {
15 18
16 SyncAPIBridgedPost::SyncAPIBridgedPost( 19 SyncAPIBridgedPost::SyncAPIBridgedPost(
17 browser_sync::ServerConnectionManager* scm, 20 browser_sync::ServerConnectionManager* scm,
18 HttpPostProviderFactory* factory) 21 HttpPostProviderFactory* factory)
19 : Post(scm), factory_(factory) { 22 : Post(scm), factory_(factory) {
20 } 23 }
21 24
22 SyncAPIBridgedPost::~SyncAPIBridgedPost() {} 25 SyncAPIBridgedPost::~SyncAPIBridgedPost() {}
23 26
24 bool SyncAPIBridgedPost::Init(const char* path, 27 bool SyncAPIBridgedPost::Init(const char* path,
25 const std::string& auth_token, 28 const std::string& auth_token,
26 const std::string& payload, 29 const std::string& payload,
27 HttpResponse* response) { 30 HttpResponse* response) {
28 std::string sync_server; 31 std::string sync_server;
29 int sync_server_port = 0; 32 int sync_server_port = 0;
30 bool use_ssl = false; 33 bool use_ssl = false;
31 GetServerParams(&sync_server, &sync_server_port, &use_ssl); 34 GetServerParams(&sync_server, &sync_server_port, &use_ssl);
32 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl); 35 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl);
33 36
34 HttpPostProviderInterface* http = factory_->Create(); 37 HttpPostProviderInterface* http = factory_->Create();
35 http->SetUserAgent(scm_->user_agent().c_str()); 38 http->SetUserAgent(scm_->user_agent().c_str());
36 http->SetURL(connection_url.c_str(), sync_server_port); 39 http->SetURL(connection_url.c_str(), sync_server_port);
37 40
38 if (!auth_token.empty()) { 41 if (!auth_token.empty()) {
39 std::string headers = "Authorization: GoogleLogin auth=" + auth_token; 42 std::string headers;
43 if (SyncSetupWizard::IsUsingOAuth()) {
44 headers = "Authorization: OAuth " + auth_token;
45 } else {
46 headers = "Authorization: GoogleLogin auth=" + auth_token;
47 }
40 http->SetExtraRequestHeaders(headers.c_str()); 48 http->SetExtraRequestHeaders(headers.c_str());
41 } 49 }
42 50
43 // Must be octet-stream, or the payload may be parsed for a cookie. 51 // Must be octet-stream, or the payload may be parsed for a cookie.
44 http->SetPostPayload("application/octet-stream", payload.length(), 52 http->SetPostPayload("application/octet-stream", payload.length(),
45 payload.data()); 53 payload.data());
46 54
47 // Issue the POST, blocking until it finishes. 55 // Issue the POST, blocking until it finishes.
48 int os_error_code = 0; 56 int os_error_code = 0;
49 int response_code = 0; 57 int response_code = 0;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 98 }
91 99
92 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} 100 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {}
93 101
94 browser_sync::ServerConnectionManager::Post* 102 browser_sync::ServerConnectionManager::Post*
95 SyncAPIServerConnectionManager::MakePost() { 103 SyncAPIServerConnectionManager::MakePost() {
96 return new SyncAPIBridgedPost(this, post_provider_factory_.get()); 104 return new SyncAPIBridgedPost(this, post_provider_factory_.get());
97 } 105 }
98 106
99 } // namespace sync_api 107 } // namespace sync_api
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698