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

Side by Side Diff: chrome/browser/chromeos/gdata/operations_base.cc

Issue 10821065: Add Drive API specific operations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update for comments. Created 8 years, 5 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) 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"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chromeos/gdata/gdata_util.h"
13 #include "chrome/common/net/gaia/gaia_urls.h" 14 #include "chrome/common/net/gaia/gaia_urls.h"
14 #include "chrome/common/net/gaia/google_service_auth_error.h" 15 #include "chrome/common/net/gaia/google_service_auth_error.h"
15 #include "chrome/common/net/gaia/oauth2_access_token_fetcher.h" 16 #include "chrome/common/net/gaia/oauth2_access_token_fetcher.h"
16 #include "chrome/common/net/url_util.h" 17 #include "chrome/common/net/url_util.h"
17 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
18 #include "net/base/load_flags.h" 19 #include "net/base/load_flags.h"
19 #include "net/http/http_util.h" 20 #include "net/http/http_util.h"
20 #include "net/url_request/url_fetcher.h" 21 #include "net/url_request/url_fetcher.h"
21 #include "net/url_request/url_request_status.h" 22 #include "net/url_request/url_request_status.h"
22 23
(...skipping 15 matching lines...) Expand all
38 const char kGDataVersionHeader[] = "GData-Version: 3.0"; 39 const char kGDataVersionHeader[] = "GData-Version: 3.0";
39 40
40 // Maximum number of attempts for re-authentication per operation. 41 // Maximum number of attempts for re-authentication per operation.
41 const int kMaxReAuthenticateAttemptsPerOperation = 1; 42 const int kMaxReAuthenticateAttemptsPerOperation = 1;
42 43
43 // OAuth scope for the documents API. 44 // OAuth scope for the documents API.
44 const char kDocsListScope[] = "https://docs.google.com/feeds/"; 45 const char kDocsListScope[] = "https://docs.google.com/feeds/";
45 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/"; 46 const char kSpreadsheetsScope[] = "https://spreadsheets.google.com/feeds/";
46 const char kUserContentScope[] = "https://docs.googleusercontent.com/"; 47 const char kUserContentScope[] = "https://docs.googleusercontent.com/";
47 48
49 // OAuth scope for Drive API.
50 const char kDriveAppsScope[] = "https://www.googleapis.com/auth/drive.apps";
51
48 } // namespace 52 } // namespace
49 53
50 namespace gdata { 54 namespace gdata {
51 55
52 //================================ AuthOperation =============================== 56 //================================ AuthOperation ===============================
53 57
54 AuthOperation::AuthOperation(GDataOperationRegistry* registry, 58 AuthOperation::AuthOperation(GDataOperationRegistry* registry,
55 Profile* profile, 59 Profile* profile,
56 const AuthStatusCallback& callback, 60 const AuthStatusCallback& callback,
57 const std::string& refresh_token) 61 const std::string& refresh_token)
58 : GDataOperationRegistry::Operation(registry), 62 : GDataOperationRegistry::Operation(registry),
59 profile_(profile), refresh_token_(refresh_token), callback_(callback) { 63 profile_(profile), refresh_token_(refresh_token), callback_(callback) {
60 } 64 }
61 65
62 AuthOperation::~AuthOperation() {} 66 AuthOperation::~AuthOperation() {}
63 67
64 void AuthOperation::Start() { 68 void AuthOperation::Start() {
65 DCHECK(!refresh_token_.empty()); 69 DCHECK(!refresh_token_.empty());
66 std::vector<std::string> scopes; 70 std::vector<std::string> scopes;
67 scopes.push_back(kDocsListScope); 71 scopes.push_back(kDocsListScope);
68 scopes.push_back(kSpreadsheetsScope); 72 scopes.push_back(kSpreadsheetsScope);
69 scopes.push_back(kUserContentScope); 73 scopes.push_back(kUserContentScope);
74 if (gdata::util::IsDriveV2ApiEnabled())
75 scopes.push_back(kDriveAppsScope);
70 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher( 76 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher(
71 this, g_browser_process->system_request_context())); 77 this, g_browser_process->system_request_context()));
72 NotifyStart(); 78 NotifyStart();
73 oauth2_access_token_fetcher_->Start( 79 oauth2_access_token_fetcher_->Start(
74 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), 80 GaiaUrls::GetInstance()->oauth2_chrome_client_id(),
75 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), 81 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(),
76 refresh_token_, 82 refresh_token_,
77 scopes); 83 scopes);
78 } 84 }
79 85
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 << ", code: " 382 << ", code: "
377 << error_code 383 << error_code
378 << ", data:\n" 384 << ", data:\n"
379 << data; 385 << data;
380 return NULL; 386 return NULL;
381 } 387 }
382 return root_value.release(); 388 return root_value.release();
383 } 389 }
384 390
385 } // namespace gdata 391 } // namespace gdata
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/gdata/mock_gdata_documents_service.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698