| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_helpers.h" | 5 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 job_id.c_str(), | 130 job_id.c_str(), |
| 131 status_string.c_str(), | 131 status_string.c_str(), |
| 132 details.platform_status_flags, | 132 details.platform_status_flags, |
| 133 details.status_message.c_str(), | 133 details.status_message.c_str(), |
| 134 details.total_pages, | 134 details.total_pages, |
| 135 details.pages_printed); | 135 details.pages_printed); |
| 136 replacements.SetQueryStr(query); | 136 replacements.SetQueryStr(query); |
| 137 return cloud_print_server_url.ReplaceComponents(replacements); | 137 return cloud_print_server_url.ReplaceComponents(replacements); |
| 138 } | 138 } |
| 139 | 139 |
| 140 GURL CloudPrintHelpers::GetUrlForUserMessage(const GURL& cloud_print_server_url, |
| 141 const std::string& message_id) { |
| 142 std::string path(AppendPathToUrl(cloud_print_server_url, "user/message")); |
| 143 GURL::Replacements replacements; |
| 144 replacements.SetPathStr(path); |
| 145 std::string query = StringPrintf("code=%s", message_id.c_str()); |
| 146 replacements.SetQueryStr(query); |
| 147 return cloud_print_server_url.ReplaceComponents(replacements); |
| 148 } |
| 149 |
| 140 bool CloudPrintHelpers::ParseResponseJSON( | 150 bool CloudPrintHelpers::ParseResponseJSON( |
| 141 const std::string& response_data, bool* succeeded, | 151 const std::string& response_data, bool* succeeded, |
| 142 DictionaryValue** response_dict) { | 152 DictionaryValue** response_dict) { |
| 143 scoped_ptr<Value> message_value(base::JSONReader::Read(response_data, false)); | 153 scoped_ptr<Value> message_value(base::JSONReader::Read(response_data, false)); |
| 144 if (!message_value.get()) | 154 if (!message_value.get()) |
| 145 return false; | 155 return false; |
| 146 | 156 |
| 147 if (!message_value->IsType(Value::TYPE_DICTIONARY)) | 157 if (!message_value->IsType(Value::TYPE_DICTIONARY)) |
| 148 return false; | 158 return false; |
| 149 | 159 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 } | 242 } |
| 233 | 243 |
| 234 bool CloudPrintHelpers::IsDryRunJob(const std::vector<std::string>& tags) { | 244 bool CloudPrintHelpers::IsDryRunJob(const std::vector<std::string>& tags) { |
| 235 std::vector<std::string>::const_iterator it; | 245 std::vector<std::string>::const_iterator it; |
| 236 for (it = tags.begin(); it != tags.end(); ++it) { | 246 for (it = tags.begin(); it != tags.end(); ++it) { |
| 237 if (*it == kTagDryRunFlag) | 247 if (*it == kTagDryRunFlag) |
| 238 return true; | 248 return true; |
| 239 } | 249 } |
| 240 return false; | 250 return false; |
| 241 } | 251 } |
| OLD | NEW |