OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/printing/cloud_print/cloud_print_setup_message_handler.
h" | 5 #include "chrome/browser/printing/cloud_print/cloud_print_setup_message_handler.
h" |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" | 10 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 void CloudPrintSetupMessageHandler::HandleSubmitAuth(const ListValue* args) { | 27 void CloudPrintSetupMessageHandler::HandleSubmitAuth(const ListValue* args) { |
28 std::string json; | 28 std::string json; |
29 bool ret = args->GetString(0, &json); | 29 bool ret = args->GetString(0, &json); |
30 std::string username, password, captcha, access_code; | 30 std::string username, password, captcha, access_code; |
31 if (!ret || json.empty()) { | 31 if (!ret || json.empty()) { |
32 NOTREACHED() << "Empty json string"; | 32 NOTREACHED() << "Empty json string"; |
33 return; | 33 return; |
34 } | 34 } |
35 | 35 |
36 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); | 36 scoped_ptr<Value> parsed_value(base::JSONReader::Read(json, false)); |
37 if (!parsed_value.get() || !parsed_value->IsType(Value::TYPE_DICTIONARY)) { | 37 if (!parsed_value.get() || !parsed_value->IsDictionary()) { |
38 NOTREACHED() << "Unable to parse auth data"; | 38 NOTREACHED() << "Unable to parse auth data"; |
39 return; | 39 return; |
40 } | 40 } |
41 | 41 |
42 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); | 42 DictionaryValue* result = static_cast<DictionaryValue*>(parsed_value.get()); |
43 if (!result->GetString("user", &username) || | 43 if (!result->GetString("user", &username) || |
44 !result->GetString("pass", &password) || | 44 !result->GetString("pass", &password) || |
45 !result->GetString("captcha", &captcha) || | 45 !result->GetString("captcha", &captcha) || |
46 !result->GetString("access_code", &access_code)) { | 46 !result->GetString("access_code", &access_code)) { |
47 NOTREACHED() << "Unable to parse auth data"; | 47 NOTREACHED() << "Unable to parse auth data"; |
48 return; | 48 return; |
49 } | 49 } |
50 | 50 |
51 // Pass the information to the flow. | 51 // Pass the information to the flow. |
52 if (flow_) | 52 if (flow_) |
53 flow_->OnUserSubmittedAuth(username, password, captcha, access_code); | 53 flow_->OnUserSubmittedAuth(username, password, captcha, access_code); |
54 } | 54 } |
55 | 55 |
56 void CloudPrintSetupMessageHandler::HandlePrintTestPage(const ListValue* args) { | 56 void CloudPrintSetupMessageHandler::HandlePrintTestPage(const ListValue* args) { |
57 if (flow_) | 57 if (flow_) |
58 flow_->OnUserClickedPrintTestPage(); | 58 flow_->OnUserClickedPrintTestPage(); |
59 } | 59 } |
60 | 60 |
61 void CloudPrintSetupMessageHandler::HandleLearnMore(const ListValue* args) { | 61 void CloudPrintSetupMessageHandler::HandleLearnMore(const ListValue* args) { |
62 if (flow_) | 62 if (flow_) |
63 flow_->OnUserClickedLearnMore(); | 63 flow_->OnUserClickedLearnMore(); |
64 } | 64 } |
OLD | NEW |