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

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: . 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 kDriveFileScope[] = "https://www.googleapis.com/auth/drive.file";
hashimoto 2012/07/27 06:48:37 What is this for?
kochi 2012/07/27 06:56:58 This will be used for file access for Drive v2 API
51 const char kDriveAppsScope[] = "https://www.googleapis.com/auth/drive.apps";
52
48 } // namespace 53 } // namespace
49 54
50 namespace gdata { 55 namespace gdata {
51 56
52 //================================ AuthOperation =============================== 57 //================================ AuthOperation ===============================
53 58
54 AuthOperation::AuthOperation(GDataOperationRegistry* registry, 59 AuthOperation::AuthOperation(GDataOperationRegistry* registry,
55 Profile* profile, 60 Profile* profile,
56 const AuthStatusCallback& callback, 61 const AuthStatusCallback& callback,
57 const std::string& refresh_token) 62 const std::string& refresh_token)
58 : GDataOperationRegistry::Operation(registry), 63 : GDataOperationRegistry::Operation(registry),
59 profile_(profile), refresh_token_(refresh_token), callback_(callback) { 64 profile_(profile), refresh_token_(refresh_token), callback_(callback) {
60 } 65 }
61 66
62 AuthOperation::~AuthOperation() {} 67 AuthOperation::~AuthOperation() {}
63 68
64 void AuthOperation::Start() { 69 void AuthOperation::Start() {
65 DCHECK(!refresh_token_.empty()); 70 DCHECK(!refresh_token_.empty());
66 std::vector<std::string> scopes; 71 std::vector<std::string> scopes;
67 scopes.push_back(kDocsListScope); 72 scopes.push_back(kDocsListScope);
68 scopes.push_back(kSpreadsheetsScope); 73 scopes.push_back(kSpreadsheetsScope);
69 scopes.push_back(kUserContentScope); 74 scopes.push_back(kUserContentScope);
75 if (gdata::util::IsDriveV2ApiEnabled())
76 scopes.push_back(kDriveAppsScope);
70 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher( 77 oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher(
71 this, g_browser_process->system_request_context())); 78 this, g_browser_process->system_request_context()));
72 NotifyStart(); 79 NotifyStart();
73 oauth2_access_token_fetcher_->Start( 80 oauth2_access_token_fetcher_->Start(
74 GaiaUrls::GetInstance()->oauth2_chrome_client_id(), 81 GaiaUrls::GetInstance()->oauth2_chrome_client_id(),
75 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(), 82 GaiaUrls::GetInstance()->oauth2_chrome_client_secret(),
76 refresh_token_, 83 refresh_token_,
77 scopes); 84 scopes);
78 } 85 }
79 86
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 << ", code: " 383 << ", code: "
377 << error_code 384 << error_code
378 << ", data:\n" 385 << ", data:\n"
379 << data; 386 << data;
380 return NULL; 387 return NULL;
381 } 388 }
382 return root_value.release(); 389 return root_value.release();
383 } 390 }
384 391
385 } // namespace gdata 392 } // namespace gdata
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698