| 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/ui/webui/print_preview_ui.h" | 5 #include "chrome/browser/ui/webui/print_preview_ui.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 preview_ui_addr_str_); | 109 preview_ui_addr_str_); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void PrintPreviewUI::SetInitiatorTabURLAndTitle( | 112 void PrintPreviewUI::SetInitiatorTabURLAndTitle( |
| 113 const std::string& initiator_url, | 113 const std::string& initiator_url, |
| 114 const string16& job_title) { | 114 const string16& job_title) { |
| 115 initiator_url_ = initiator_url; | 115 initiator_url_ = initiator_url; |
| 116 initiator_tab_title_ = job_title; | 116 initiator_tab_title_ = job_title; |
| 117 } | 117 } |
| 118 | 118 |
| 119 void PrintPreviewUI::SetSourceIsModifiable(bool source_is_modifiable) { | |
| 120 source_is_modifiable_ = source_is_modifiable; | |
| 121 } | |
| 122 | |
| 123 // static | 119 // static |
| 124 void PrintPreviewUI::GetCurrentPrintPreviewStatus( | 120 void PrintPreviewUI::GetCurrentPrintPreviewStatus( |
| 125 const std::string& preview_ui_addr, | 121 const std::string& preview_ui_addr, |
| 126 int request_id, | 122 int request_id, |
| 127 bool* cancel) { | 123 bool* cancel) { |
| 128 int current_id = -1; | 124 int current_id = -1; |
| 129 if (!g_print_preview_request_id_map.Get().Get(preview_ui_addr, ¤t_id)) { | 125 if (!g_print_preview_request_id_map.Get().Get(preview_ui_addr, ¤t_id)) { |
| 130 *cancel = true; | 126 *cancel = true; |
| 131 return; | 127 return; |
| 132 } | 128 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 156 } | 152 } |
| 157 | 153 |
| 158 void PrintPreviewUI::OnShowSystemDialog() { | 154 void PrintPreviewUI::OnShowSystemDialog() { |
| 159 CallJavascriptFunction("onSystemDialogLinkClicked"); | 155 CallJavascriptFunction("onSystemDialogLinkClicked"); |
| 160 } | 156 } |
| 161 | 157 |
| 162 void PrintPreviewUI::OnDidGetPreviewPageCount( | 158 void PrintPreviewUI::OnDidGetPreviewPageCount( |
| 163 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { | 159 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { |
| 164 DCHECK_GT(params.page_count, 0); | 160 DCHECK_GT(params.page_count, 0); |
| 165 base::FundamentalValue count(params.page_count); | 161 base::FundamentalValue count(params.page_count); |
| 162 base::FundamentalValue modifiable(params.is_modifiable); |
| 166 base::FundamentalValue request_id(params.preview_request_id); | 163 base::FundamentalValue request_id(params.preview_request_id); |
| 167 CallJavascriptFunction("onDidGetPreviewPageCount", count,request_id); | 164 CallJavascriptFunction("onDidGetPreviewPageCount", count, modifiable, |
| 165 request_id); |
| 168 } | 166 } |
| 169 | 167 |
| 170 void PrintPreviewUI::OnDidGetDefaultPageLayout( | 168 void PrintPreviewUI::OnDidGetDefaultPageLayout( |
| 171 const PageSizeMargins& page_layout) { | 169 const PageSizeMargins& page_layout) { |
| 172 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || | 170 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || |
| 173 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || | 171 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || |
| 174 page_layout.content_width < 0 || page_layout.content_height < 0) { | 172 page_layout.content_width < 0 || page_layout.content_height < 0) { |
| 175 NOTREACHED(); | 173 NOTREACHED(); |
| 176 return; | 174 return; |
| 177 } | 175 } |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 CallJavascriptFunction("printPreviewFailed"); | 236 CallJavascriptFunction("printPreviewFailed"); |
| 239 } | 237 } |
| 240 | 238 |
| 241 void PrintPreviewUI::OnInvalidPrinterSettings() { | 239 void PrintPreviewUI::OnInvalidPrinterSettings() { |
| 242 CallJavascriptFunction("invalidPrinterSettings"); | 240 CallJavascriptFunction("invalidPrinterSettings"); |
| 243 } | 241 } |
| 244 | 242 |
| 245 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { | 243 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { |
| 246 return PrintPreviewDataService::GetInstance(); | 244 return PrintPreviewDataService::GetInstance(); |
| 247 } | 245 } |
| OLD | NEW |