Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/ui/webui/print_preview/print_preview_handler.h" | 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h" |
| 6 | 6 |
| 7 #include <ctype.h> | 7 #include <ctype.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1271 void PrintPreviewHandler::SendAccessToken(const std::string& type, | 1271 void PrintPreviewHandler::SendAccessToken(const std::string& type, |
| 1272 const std::string& access_token) { | 1272 const std::string& access_token) { |
| 1273 VLOG(1) << "Get getAccessToken finished"; | 1273 VLOG(1) << "Get getAccessToken finished"; |
| 1274 web_ui()->CallJavascriptFunctionUnsafe( | 1274 web_ui()->CallJavascriptFunctionUnsafe( |
| 1275 "onDidGetAccessToken", base::Value(type), base::Value(access_token)); | 1275 "onDidGetAccessToken", base::Value(type), base::Value(access_token)); |
| 1276 } | 1276 } |
| 1277 | 1277 |
| 1278 void PrintPreviewHandler::SendPrinterCapabilities( | 1278 void PrintPreviewHandler::SendPrinterCapabilities( |
| 1279 const std::string& printer_name, | 1279 const std::string& printer_name, |
| 1280 std::unique_ptr<base::DictionaryValue> settings_info) { | 1280 std::unique_ptr<base::DictionaryValue> settings_info) { |
| 1281 if (!settings_info) { | 1281 // Validate that |settings_info| is valid for the javascript. |
|
dpapad
2017/05/02 00:07:41
Nit
// Check that |settings_info| is valid.
skau
2017/05/02 01:52:47
Done.
| |
| 1282 VLOG(1) << "Get printer capabilities failed"; | 1282 if (settings_info && settings_info->Get("capabilities", nullptr)) { |
| 1283 web_ui()->CallJavascriptFunctionUnsafe("failedToGetPrinterCapabilities", | 1283 VLOG(1) << "Get printer capabilities finished"; |
| 1284 base::Value(printer_name)); | 1284 web_ui()->CallJavascriptFunctionUnsafe("updateWithPrinterCapabilities", |
| 1285 *settings_info); | |
| 1285 return; | 1286 return; |
| 1286 } | 1287 } |
| 1287 VLOG(1) << "Get printer capabilities finished"; | 1288 |
| 1288 web_ui()->CallJavascriptFunctionUnsafe("updateWithPrinterCapabilities", | 1289 VLOG(1) << "Get printer capabilities failed"; |
| 1289 *settings_info); | 1290 web_ui()->CallJavascriptFunctionUnsafe("failedToGetPrinterCapabilities", |
| 1291 base::Value(printer_name)); | |
| 1290 } | 1292 } |
| 1291 | 1293 |
| 1292 void PrintPreviewHandler::SendPrinterSetup( | 1294 void PrintPreviewHandler::SendPrinterSetup( |
| 1293 const std::string& callback_id, | 1295 const std::string& callback_id, |
| 1294 const std::string& printer_name, | 1296 const std::string& printer_name, |
| 1295 std::unique_ptr<base::DictionaryValue> destination_info) { | 1297 std::unique_ptr<base::DictionaryValue> destination_info) { |
| 1296 auto response = base::MakeUnique<base::DictionaryValue>(); | 1298 auto response = base::MakeUnique<base::DictionaryValue>(); |
| 1297 bool success = true; | 1299 bool success = true; |
| 1298 auto caps_value = base::MakeUnique<base::Value>(); | 1300 auto caps_value = base::MakeUnique<base::Value>(); |
| 1299 auto caps = base::MakeUnique<base::DictionaryValue>(); | 1301 auto caps = base::MakeUnique<base::DictionaryValue>(); |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1777 | 1779 |
| 1778 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1780 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
| 1779 if (gaia_cookie_manager_service_) | 1781 if (gaia_cookie_manager_service_) |
| 1780 gaia_cookie_manager_service_->RemoveObserver(this); | 1782 gaia_cookie_manager_service_->RemoveObserver(this); |
| 1781 } | 1783 } |
| 1782 | 1784 |
| 1783 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1785 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1784 const base::Closure& closure) { | 1786 const base::Closure& closure) { |
| 1785 pdf_file_saved_closure_ = closure; | 1787 pdf_file_saved_closure_ = closure; |
| 1786 } | 1788 } |
| OLD | NEW |