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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 | 49 |
50 namespace gdata { | 50 namespace gdata { |
51 | 51 |
52 //================================ AuthOperation =============================== | 52 //================================ AuthOperation =============================== |
53 | 53 |
54 AuthOperation::AuthOperation(GDataOperationRegistry* registry, | 54 AuthOperation::AuthOperation(GDataOperationRegistry* registry, |
55 Profile* profile, | 55 Profile* profile, |
56 const AuthStatusCallback& callback, | 56 const AuthStatusCallback& callback, |
57 const std::string& refresh_token) | 57 const std::string& refresh_token) |
58 : GDataOperationRegistry::Operation(registry), | 58 : GDataOperationRegistry::Operation(registry), |
59 profile_(profile), token_(refresh_token), callback_(callback) { | 59 profile_(profile), refresh_token_(refresh_token), callback_(callback) { |
60 } | 60 } |
61 | 61 |
62 AuthOperation::~AuthOperation() {} | 62 AuthOperation::~AuthOperation() {} |
63 | 63 |
64 void AuthOperation::Start() { | 64 void AuthOperation::Start() { |
65 DCHECK(!token_.empty()); | 65 DCHECK(!refresh_token_.empty()); |
66 std::vector<std::string> scopes; | 66 std::vector<std::string> scopes; |
67 scopes.push_back(kDocsListScope); | 67 scopes.push_back(kDocsListScope); |
68 scopes.push_back(kSpreadsheetsScope); | 68 scopes.push_back(kSpreadsheetsScope); |
69 scopes.push_back(kUserContentScope); | 69 scopes.push_back(kUserContentScope); |
70 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher( | 70 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher( |
71 this, g_browser_process->system_request_context())); | 71 this, g_browser_process->system_request_context())); |
72 NotifyStart(); | 72 NotifyStart(); |
73 oauth2_access_token_fetcher_->Start( | 73 oauth2_access_token_fetcher_->Start( |
74 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), | 74 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), |
75 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), | 75 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), |
76 token_, | 76 refresh_token_, |
77 scopes); | 77 scopes); |
78 } | 78 } |
79 | 79 |
80 void AuthOperation::DoCancel() { | 80 void AuthOperation::DoCancel() { |
81 oauth2_access_token_fetcher_->CancelRequest(); | 81 oauth2_access_token_fetcher_->CancelRequest(); |
82 if (!callback_.is_null()) | 82 if (!callback_.is_null()) |
83 callback_.Run(GDATA_CANCELLED, std::string()); | 83 callback_.Run(GDATA_CANCELLED, std::string()); |
84 } | 84 } |
85 | 85 |
86 // Callback for OAuth2AccessTokenFetcher on success. |access_token| is the token | 86 // Callback for OAuth2AccessTokenFetcher on success. |access_token| is the token |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 << ", code: " | 376 << ", code: " |
377 << error_code | 377 << error_code |
378 << ", data:\n" | 378 << ", data:\n" |
379 << data; | 379 << data; |
380 return NULL; | 380 return NULL; |
381 } | 381 } |
382 return root_value.release(); | 382 return root_value.release(); |
383 } | 383 } |
384 | 384 |
385 } // namespace gdata | 385 } // namespace gdata |
OLD | NEW |