| 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::OnGetInitiatorTabTitle() { |
| 120 base::StringValue tab_title(initiator_tab_title_); |
| 121 CallJavascriptFunction("setInitiatorTabTitle", tab_title); |
| 122 } |
| 123 |
| 119 // static | 124 // static |
| 120 void PrintPreviewUI::GetCurrentPrintPreviewStatus( | 125 void PrintPreviewUI::GetCurrentPrintPreviewStatus( |
| 121 const std::string& preview_ui_addr, | 126 const std::string& preview_ui_addr, |
| 122 int request_id, | 127 int request_id, |
| 123 bool* cancel) { | 128 bool* cancel) { |
| 124 int current_id = -1; | 129 int current_id = -1; |
| 125 if (!g_print_preview_request_id_map.Get().Get(preview_ui_addr, ¤t_id)) { | 130 if (!g_print_preview_request_id_map.Get().Get(preview_ui_addr, ¤t_id)) { |
| 126 *cancel = true; | 131 *cancel = true; |
| 127 return; | 132 return; |
| 128 } | 133 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 154 void PrintPreviewUI::OnShowSystemDialog() { | 159 void PrintPreviewUI::OnShowSystemDialog() { |
| 155 CallJavascriptFunction("onSystemDialogLinkClicked"); | 160 CallJavascriptFunction("onSystemDialogLinkClicked"); |
| 156 } | 161 } |
| 157 | 162 |
| 158 void PrintPreviewUI::OnDidGetPreviewPageCount( | 163 void PrintPreviewUI::OnDidGetPreviewPageCount( |
| 159 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { | 164 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { |
| 160 DCHECK_GT(params.page_count, 0); | 165 DCHECK_GT(params.page_count, 0); |
| 161 base::FundamentalValue count(params.page_count); | 166 base::FundamentalValue count(params.page_count); |
| 162 base::FundamentalValue modifiable(params.is_modifiable); | 167 base::FundamentalValue modifiable(params.is_modifiable); |
| 163 base::FundamentalValue request_id(params.preview_request_id); | 168 base::FundamentalValue request_id(params.preview_request_id); |
| 164 StringValue title(initiator_tab_title_); | |
| 165 CallJavascriptFunction("onDidGetPreviewPageCount", count, modifiable, | 169 CallJavascriptFunction("onDidGetPreviewPageCount", count, modifiable, |
| 166 request_id, title); | 170 request_id); |
| 167 } | 171 } |
| 168 | 172 |
| 169 void PrintPreviewUI::OnDidGetDefaultPageLayout( | 173 void PrintPreviewUI::OnDidGetDefaultPageLayout( |
| 170 const PageSizeMargins& page_layout) { | 174 const PageSizeMargins& page_layout) { |
| 171 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || | 175 if (page_layout.margin_top < 0 || page_layout.margin_left < 0 || |
| 172 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || | 176 page_layout.margin_bottom < 0 || page_layout.margin_right < 0 || |
| 173 page_layout.content_width < 0 || page_layout.content_height < 0) { | 177 page_layout.content_width < 0 || page_layout.content_height < 0) { |
| 174 NOTREACHED(); | 178 NOTREACHED(); |
| 175 return; | 179 return; |
| 176 } | 180 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 237 } |
| 234 | 238 |
| 235 void PrintPreviewUI::OnPrintPreviewFailed() { | 239 void PrintPreviewUI::OnPrintPreviewFailed() { |
| 236 handler_->OnPrintPreviewFailed(); | 240 handler_->OnPrintPreviewFailed(); |
| 237 CallJavascriptFunction("printPreviewFailed"); | 241 CallJavascriptFunction("printPreviewFailed"); |
| 238 } | 242 } |
| 239 | 243 |
| 240 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { | 244 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { |
| 241 return PrintPreviewDataService::GetInstance(); | 245 return PrintPreviewDataService::GetInstance(); |
| 242 } | 246 } |
| OLD | NEW |