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 "chrome/browser/chromeos/gdata/operations_base.h" | 5 #include "chrome/browser/chromeos/gdata/operations_base.h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
(...skipping 27 matching lines...) Expand all Loading... |
38 const char kGDataVersionHeader[] = "GData-Version: 3.0"; | 38 const char kGDataVersionHeader[] = "GData-Version: 3.0"; |
39 | 39 |
40 // Maximum number of attempts for re-authentication per operation. | 40 // Maximum number of attempts for re-authentication per operation. |
41 const int kMaxReAuthenticateAttemptsPerOperation = 1; | 41 const int kMaxReAuthenticateAttemptsPerOperation = 1; |
42 | 42 |
43 // OAuth scope for the documents API. | 43 // OAuth scope for the documents API. |
44 const char kDocsListScope[] = "https://docs.google.com/feeds/"; | 44 const char kDocsListScope[] = "https://docs.google.com/feeds/"; |
45 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/"; | 45 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/"; |
46 const char kUserContentScope[] = "https://docs.googleusercontent.com/"; | 46 const char kUserContentScope[] = "https://docs.googleusercontent.com/"; |
47 | 47 |
| 48 // OAuth scope for the Contacts API. |
| 49 const char kContactsScope[] = "https://www.google.com/m8/feeds/"; |
| 50 |
48 } // namespace | 51 } // namespace |
49 | 52 |
50 namespace gdata { | 53 namespace gdata { |
51 | 54 |
52 //================================ AuthOperation =============================== | 55 //================================ AuthOperation =============================== |
53 | 56 |
54 AuthOperation::AuthOperation(GDataOperationRegistry* registry, | 57 AuthOperation::AuthOperation(GDataOperationRegistry* registry, |
55 Profile* profile, | 58 Profile* profile, |
56 const AuthStatusCallback& callback, | 59 const AuthStatusCallback& callback, |
57 const std::string& refresh_token) | 60 const std::string& refresh_token) |
58 : GDataOperationRegistry::Operation(registry), | 61 : GDataOperationRegistry::Operation(registry), |
59 profile_(profile), token_(refresh_token), callback_(callback) { | 62 profile_(profile), token_(refresh_token), callback_(callback) { |
60 } | 63 } |
61 | 64 |
62 AuthOperation::~AuthOperation() {} | 65 AuthOperation::~AuthOperation() {} |
63 | 66 |
64 void AuthOperation::Start() { | 67 void AuthOperation::Start() { |
65 DCHECK(!token_.empty()); | 68 DCHECK(!token_.empty()); |
66 std::vector<std::string> scopes; | 69 std::vector<std::string> scopes; |
67 scopes.push_back(kDocsListScope); | 70 scopes.push_back(kDocsListScope); |
68 scopes.push_back(kSpreadsheetsScope); | 71 scopes.push_back(kSpreadsheetsScope); |
69 scopes.push_back(kUserContentScope); | 72 scopes.push_back(kUserContentScope); |
| 73 scopes.push_back(kContactsScope); |
70 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher( | 74 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher( |
71 this, g_browser_process->system_request_context())); | 75 this, g_browser_process->system_request_context())); |
72 NotifyStart(); | 76 NotifyStart(); |
73 oauth2_access_token_fetcher_->Start( | 77 oauth2_access_token_fetcher_->Start( |
74 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), | 78 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), |
75 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), | 79 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), |
76 token_, | 80 token_, |
77 scopes); | 81 scopes); |
78 } | 82 } |
79 | 83 |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 << ", code: " | 380 << ", code: " |
377 << error_code | 381 << error_code |
378 << ", data:\n" | 382 << ", data:\n" |
379 << data; | 383 << data; |
380 return NULL; | 384 return NULL; |
381 } | 385 } |
382 return root_value.release(); | 386 return root_value.release(); |
383 } | 387 } |
384 | 388 |
385 } // namespace gdata | 389 } // namespace gdata |
OLD | NEW |