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

Side by Side Diff: chrome/browser/local_discovery/cloud_print_base_api_flow.h

Issue 23658020: Printer list for Google Cloud Print (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_ 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_ 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/local_discovery/privet_constants.h"
10 #include "chrome/browser/local_discovery/privet_http.h" 11 #include "chrome/browser/local_discovery/privet_http.h"
11 #include "google_apis/gaia/oauth2_token_service.h" 12 #include "google_apis/gaia/oauth2_token_service.h"
12 #include "net/url_request/url_fetcher.h" 13 #include "net/url_request/url_fetcher.h"
13 #include "net/url_request/url_fetcher_delegate.h" 14 #include "net/url_request/url_fetcher_delegate.h"
14 #include "net/url_request/url_request_context_getter.h" 15 #include "net/url_request/url_request_context_getter.h"
15 16
16 namespace local_discovery { 17 namespace local_discovery {
17 18
18 // API call flow for communicating with cloud print. 19 // API call flow for communicating with cloud print.
19 class CloudPrintBaseApiFlow : public net::URLFetcherDelegate, 20 class CloudPrintBaseApiFlow : public net::URLFetcherDelegate,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // net::URLFetcherDelegate implementation: 70 // net::URLFetcherDelegate implementation:
70 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 71 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
71 72
72 // OAuth2TokenService::Consumer implementation: 73 // OAuth2TokenService::Consumer implementation:
73 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 74 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
74 const std::string& access_token, 75 const std::string& access_token,
75 const base::Time& expiration_time) OVERRIDE; 76 const base::Time& expiration_time) OVERRIDE;
76 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, 77 virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request,
77 const GoogleServiceAuthError& error) OVERRIDE; 78 const GoogleServiceAuthError& error) OVERRIDE;
78 79
80 // Return the user index or kAccountIndexUseOAuth2 if none is available.
81 int user_index() { return user_index_; }
82
79 private: 83 private:
80 bool UseOAuth2() { return token_service_ != NULL; } 84 bool UseOAuth2() { return user_index_ == kAccountIndexUseOAuth2; }
81 85
82 void CreateRequest(const GURL& url); 86 void CreateRequest(const GURL& url);
83 87
84 scoped_ptr<net::URLFetcher> url_fetcher_; 88 scoped_ptr<net::URLFetcher> url_fetcher_;
85 scoped_ptr<OAuth2TokenService::Request> oauth_request_; 89 scoped_ptr<OAuth2TokenService::Request> oauth_request_;
86 scoped_refptr<net::URLRequestContextGetter> request_context_; 90 scoped_refptr<net::URLRequestContextGetter> request_context_;
87 OAuth2TokenService* token_service_; 91 OAuth2TokenService* token_service_;
88 int user_index_; 92 int user_index_;
89 std::string xsrf_token_; 93 std::string xsrf_token_;
90 GURL url_; 94 GURL url_;
91 Delegate* delegate_; 95 Delegate* delegate_;
92 }; 96 };
93 97
94 } // namespace local_discovery 98 } // namespace local_discovery
95 99
96 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_ 100 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_CLOUD_PRINT_BASE_API_FLOW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698