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

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: Final review comments 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
« no previous file with comments | « chrome/browser/net/gaia/token_service.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | 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) 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 "chrome/browser/sync/engine/http_post_provider_factory.h" 7 #include "chrome/browser/sync/engine/http_post_provider_factory.h"
8 #include "chrome/browser/sync/engine/http_post_provider_interface.h" 8 #include "chrome/browser/sync/engine/http_post_provider_interface.h"
9 #include "chrome/browser/sync/engine/syncapi.h" 9 #include "chrome/browser/sync/engine/syncapi.h"
10 #include "chrome/browser/sync/util/oauth.h"
10 #include "chrome/common/net/http_return.h" 11 #include "chrome/common/net/http_return.h"
11 12
12 using browser_sync::HttpResponse; 13 using browser_sync::HttpResponse;
13 14
14 namespace sync_api { 15 namespace sync_api {
15 16
16 SyncAPIBridgedPost::SyncAPIBridgedPost( 17 SyncAPIBridgedPost::SyncAPIBridgedPost(
17 browser_sync::ServerConnectionManager* scm, 18 browser_sync::ServerConnectionManager* scm,
18 HttpPostProviderFactory* factory) 19 HttpPostProviderFactory* factory)
19 : Post(scm), factory_(factory) { 20 : Post(scm), factory_(factory) {
20 } 21 }
21 22
22 SyncAPIBridgedPost::~SyncAPIBridgedPost() {} 23 SyncAPIBridgedPost::~SyncAPIBridgedPost() {}
23 24
24 bool SyncAPIBridgedPost::Init(const char* path, 25 bool SyncAPIBridgedPost::Init(const char* path,
25 const std::string& auth_token, 26 const std::string& auth_token,
26 const std::string& payload, 27 const std::string& payload,
27 HttpResponse* response) { 28 HttpResponse* response) {
28 std::string sync_server; 29 std::string sync_server;
29 int sync_server_port = 0; 30 int sync_server_port = 0;
30 bool use_ssl = false; 31 bool use_ssl = false;
31 GetServerParams(&sync_server, &sync_server_port, &use_ssl); 32 GetServerParams(&sync_server, &sync_server_port, &use_ssl);
32 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl); 33 std::string connection_url = MakeConnectionURL(sync_server, path, use_ssl);
33 34
34 HttpPostProviderInterface* http = factory_->Create(); 35 HttpPostProviderInterface* http = factory_->Create();
35 http->SetUserAgent(scm_->user_agent().c_str()); 36 http->SetUserAgent(scm_->user_agent().c_str());
36 http->SetURL(connection_url.c_str(), sync_server_port); 37 http->SetURL(connection_url.c_str(), sync_server_port);
37 38
38 if (!auth_token.empty()) { 39 if (!auth_token.empty()) {
39 std::string headers = "Authorization: GoogleLogin auth=" + auth_token; 40 std::string headers;
41 if (browser_sync::IsUsingOAuth()) {
42 headers = "Authorization: OAuth " + auth_token;
43 } else {
44 headers = "Authorization: GoogleLogin auth=" + auth_token;
45 }
40 http->SetExtraRequestHeaders(headers.c_str()); 46 http->SetExtraRequestHeaders(headers.c_str());
41 } 47 }
42 48
43 // Must be octet-stream, or the payload may be parsed for a cookie. 49 // Must be octet-stream, or the payload may be parsed for a cookie.
44 http->SetPostPayload("application/octet-stream", payload.length(), 50 http->SetPostPayload("application/octet-stream", payload.length(),
45 payload.data()); 51 payload.data());
46 52
47 // Issue the POST, blocking until it finishes. 53 // Issue the POST, blocking until it finishes.
48 int os_error_code = 0; 54 int os_error_code = 0;
49 int response_code = 0; 55 int response_code = 0;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 } 96 }
91 97
92 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {} 98 SyncAPIServerConnectionManager::~SyncAPIServerConnectionManager() {}
93 99
94 browser_sync::ServerConnectionManager::Post* 100 browser_sync::ServerConnectionManager::Post*
95 SyncAPIServerConnectionManager::MakePost() { 101 SyncAPIServerConnectionManager::MakePost() {
96 return new SyncAPIBridgedPost(this, post_provider_factory_.get()); 102 return new SyncAPIBridgedPost(this, post_provider_factory_.get());
97 } 103 }
98 104
99 } // namespace sync_api 105 } // namespace sync_api
OLDNEW
« no previous file with comments | « chrome/browser/net/gaia/token_service.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698