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

Side by Side Diff: chrome/service/cloud_print/cloud_print_url_fetcher.cc

Issue 9443007: Add Chrome To Mobile Service and Views Page Action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Bail on empty GetOAuth2LoginRefreshToken(). Created 8 years, 9 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/service/cloud_print/cloud_print_url_fetcher.h" 5 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/common/cloud_print/cloud_print_helpers.h"
9 #include "chrome/service/cloud_print/cloud_print_consts.h" 10 #include "chrome/service/cloud_print/cloud_print_consts.h"
10 #include "chrome/service/cloud_print/cloud_print_helpers.h" 11 #include "chrome/service/cloud_print/cloud_print_helpers.h"
11 #include "chrome/service/cloud_print/cloud_print_token_store.h" 12 #include "chrome/service/cloud_print/cloud_print_token_store.h"
12 #include "chrome/service/net/service_url_request_context.h" 13 #include "chrome/service/net/service_url_request_context.h"
13 #include "chrome/service/service_process.h" 14 #include "chrome/service/service_process.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 #include "net/http/http_status_code.h" 16 #include "net/http/http_status_code.h"
16 #include "net/url_request/url_request_status.h" 17 #include "net/url_request/url_request_status.h"
17 18
18 CloudPrintURLFetcher::CloudPrintURLFetcher() 19 CloudPrintURLFetcher::CloudPrintURLFetcher()
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 else 84 else
84 action = delegate_->HandleRawData(source, source->GetURL(), data); 85 action = delegate_->HandleRawData(source, source->GetURL(), data);
85 86
86 if (action == CONTINUE_PROCESSING) { 87 if (action == CONTINUE_PROCESSING) {
87 // If the delegate is not interested in handling the raw response data, 88 // If the delegate is not interested in handling the raw response data,
88 // we assume that a JSON response is expected. If we do not get a JSON 89 // we assume that a JSON response is expected. If we do not get a JSON
89 // response, we will retry (to handle the case where we got redirected 90 // response, we will retry (to handle the case where we got redirected
90 // to a non-cloudprint-server URL eg. for authentication). 91 // to a non-cloudprint-server URL eg. for authentication).
91 bool succeeded = false; 92 bool succeeded = false;
92 DictionaryValue* response_dict = NULL; 93 DictionaryValue* response_dict = NULL;
93 CloudPrintHelpers::ParseResponseJSON(data, &succeeded, &response_dict); 94 cloud_print::ParseResponseJSON(data, &succeeded, &response_dict);
94 if (response_dict) 95 if (response_dict)
95 action = delegate_->HandleJSONData(source, 96 action = delegate_->HandleJSONData(source,
96 source->GetURL(), 97 source->GetURL(),
97 response_dict, 98 response_dict,
98 succeeded); 99 succeeded);
99 else 100 else
100 action = RETRY_REQUEST; 101 action = RETRY_REQUEST;
101 } 102 }
102 } 103 }
103 // Retry the request if needed. 104 // Retry the request if needed.
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 request_->SetUploadData(post_data_mime_type, post_data); 153 request_->SetUploadData(post_data_mime_type, post_data);
153 } 154 }
154 155
155 request_->Start(); 156 request_->Start();
156 } 157 }
157 158
158 void CloudPrintURLFetcher::SetupRequestHeaders() { 159 void CloudPrintURLFetcher::SetupRequestHeaders() {
159 std::string headers = delegate_->GetAuthHeader(); 160 std::string headers = delegate_->GetAuthHeader();
160 if (!headers.empty()) 161 if (!headers.empty())
161 headers += "\r\n"; 162 headers += "\r\n";
162 headers += kChromeCloudPrintProxyHeader; 163 headers += cloud_print::kChromeCloudPrintProxyHeader;
163 if (!additional_headers_.empty()) { 164 if (!additional_headers_.empty()) {
164 headers += "\r\n"; 165 headers += "\r\n";
165 headers += additional_headers_; 166 headers += additional_headers_;
166 } 167 }
167 request_->SetExtraRequestHeaders(headers); 168 request_->SetExtraRequestHeaders(headers);
168 } 169 }
169 170
170 CloudPrintURLFetcher::~CloudPrintURLFetcher() {} 171 CloudPrintURLFetcher::~CloudPrintURLFetcher() {}
171 172
172 net::URLRequestContextGetter* CloudPrintURLFetcher::GetRequestContextGetter() { 173 net::URLRequestContextGetter* CloudPrintURLFetcher::GetRequestContextGetter() {
173 ServiceURLRequestContextGetter* getter = 174 ServiceURLRequestContextGetter* getter =
174 g_service_process->GetServiceURLRequestContextGetter(); 175 g_service_process->GetServiceURLRequestContextGetter();
175 // Now set up the user agent for cloudprint. 176 // Now set up the user agent for cloudprint.
176 std::string user_agent = getter->user_agent(); 177 std::string user_agent = getter->user_agent();
177 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); 178 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent);
178 getter->set_user_agent(user_agent); 179 getter->set_user_agent(user_agent);
179 return getter; 180 return getter;
180 } 181 }
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_helpers.cc ('k') | chrome/service/cloud_print/printer_job_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698