| 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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 | 679 |
| 680 void PrintPreviewHandler::HandleGetPrivetPrinters(const base::ListValue* args) { | 680 void PrintPreviewHandler::HandleGetPrivetPrinters(const base::ListValue* args) { |
| 681 std::string callback_id; | 681 std::string callback_id; |
| 682 CHECK(args->GetString(0, &callback_id)); | 682 CHECK(args->GetString(0, &callback_id)); |
| 683 CHECK(!callback_id.empty()); | 683 CHECK(!callback_id.empty()); |
| 684 | 684 |
| 685 AllowJavascript(); | 685 AllowJavascript(); |
| 686 | 686 |
| 687 if (!PrivetPrintingEnabled()) { | 687 if (!PrivetPrintingEnabled()) { |
| 688 RejectJavascriptCallback(base::Value(callback_id), base::Value()); | 688 RejectJavascriptCallback(base::Value(callback_id), base::Value()); |
| 689 return; |
| 689 } | 690 } |
| 690 #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) | 691 #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) |
| 691 using local_discovery::ServiceDiscoverySharedClient; | 692 using local_discovery::ServiceDiscoverySharedClient; |
| 692 scoped_refptr<ServiceDiscoverySharedClient> service_discovery = | 693 scoped_refptr<ServiceDiscoverySharedClient> service_discovery = |
| 693 ServiceDiscoverySharedClient::GetInstance(); | 694 ServiceDiscoverySharedClient::GetInstance(); |
| 694 DCHECK(privet_search_callback_id_.empty()); | 695 DCHECK(privet_search_callback_id_.empty()); |
| 695 privet_search_callback_id_ = callback_id; | 696 privet_search_callback_id_ = callback_id; |
| 696 StartPrivetLister(service_discovery); | 697 StartPrivetLister(service_discovery); |
| 697 #endif | 698 #endif |
| 698 } | 699 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 // before printing. | 878 // before printing. |
| 878 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", | 879 UMA_HISTOGRAM_COUNTS("PrintPreview.RegeneratePreviewRequest.BeforePrint", |
| 879 regenerate_preview_request_count_); | 880 regenerate_preview_request_count_); |
| 880 | 881 |
| 881 AllowJavascript(); | 882 AllowJavascript(); |
| 882 | 883 |
| 883 std::string callback_id; | 884 std::string callback_id; |
| 884 CHECK(args->GetString(0, &callback_id)); | 885 CHECK(args->GetString(0, &callback_id)); |
| 885 CHECK(!callback_id.empty()); | 886 CHECK(!callback_id.empty()); |
| 886 std::string json_str; | 887 std::string json_str; |
| 887 if (!args->GetString(1, &json_str)) | 888 CHECK(args->GetString(1, &json_str)); |
| 888 RejectJavascriptCallback(base::Value(callback_id), base::Value(-1)); | |
| 889 | 889 |
| 890 std::unique_ptr<base::DictionaryValue> settings = | 890 std::unique_ptr<base::DictionaryValue> settings = |
| 891 GetSettingsDictionary(json_str); | 891 GetSettingsDictionary(json_str); |
| 892 if (!settings) | 892 if (!settings) { |
| 893 RejectJavascriptCallback(base::Value(callback_id), base::Value(-1)); | 893 RejectJavascriptCallback(base::Value(callback_id), base::Value(-1)); |
| 894 return; |
| 895 } |
| 894 | 896 |
| 895 ReportPrintSettingsStats(*settings); | 897 ReportPrintSettingsStats(*settings); |
| 896 | 898 |
| 897 // Report whether the user printed a PDF or an HTML document. | 899 // Report whether the user printed a PDF or an HTML document. |
| 898 ReportPrintDocumentTypeHistogram(print_preview_ui()->source_is_modifiable() ? | 900 ReportPrintDocumentTypeHistogram(print_preview_ui()->source_is_modifiable() ? |
| 899 HTML_DOCUMENT : PDF_DOCUMENT); | 901 HTML_DOCUMENT : PDF_DOCUMENT); |
| 900 | 902 |
| 901 bool print_to_pdf = false; | 903 bool print_to_pdf = false; |
| 902 bool is_cloud_printer = false; | 904 bool is_cloud_printer = false; |
| 903 bool print_with_privet = false; | 905 bool print_with_privet = false; |
| (...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1922 | 1924 |
| 1923 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { | 1925 void PrintPreviewHandler::UnregisterForGaiaCookieChanges() { |
| 1924 if (gaia_cookie_manager_service_) | 1926 if (gaia_cookie_manager_service_) |
| 1925 gaia_cookie_manager_service_->RemoveObserver(this); | 1927 gaia_cookie_manager_service_->RemoveObserver(this); |
| 1926 } | 1928 } |
| 1927 | 1929 |
| 1928 void PrintPreviewHandler::SetPdfSavedClosureForTesting( | 1930 void PrintPreviewHandler::SetPdfSavedClosureForTesting( |
| 1929 const base::Closure& closure) { | 1931 const base::Closure& closure) { |
| 1930 pdf_file_saved_closure_ = closure; | 1932 pdf_file_saved_closure_ = closure; |
| 1931 } | 1933 } |
| OLD | NEW |