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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/printing/print_preview_data_service.h" | 10 #include "chrome/browser/printing/print_preview_data_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/webui/print_preview_data_source.h" | 12 #include "chrome/browser/ui/webui/print_preview_data_source.h" |
13 #include "chrome/browser/ui/webui/print_preview_handler.h" | 13 #include "chrome/browser/ui/webui/print_preview_handler.h" |
14 #include "content/browser/tab_contents/tab_contents.h" | 14 #include "content/browser/tab_contents/tab_contents.h" |
15 | 15 |
16 PrintPreviewUI::PrintPreviewUI(TabContents* contents) | 16 PrintPreviewUI::PrintPreviewUI(TabContents* contents) |
17 : ChromeWebUI(contents), | 17 : ChromeWebUI(contents), |
18 initial_preview_start_time_(base::TimeTicks::Now()) { | 18 initial_preview_start_time_(base::TimeTicks::Now()), |
| 19 is_tab_hidden_for_print_(false) { |
19 // PrintPreviewUI owns |handler|. | 20 // PrintPreviewUI owns |handler|. |
20 PrintPreviewHandler* handler = new PrintPreviewHandler(); | 21 PrintPreviewHandler* handler = new PrintPreviewHandler(); |
21 AddMessageHandler(handler->Attach(this)); | 22 AddMessageHandler(handler->Attach(this)); |
22 | 23 |
23 // Set up the chrome://print/ data source. | 24 // Set up the chrome://print/ data source. |
24 contents->profile()->GetChromeURLDataManager()->AddDataSource( | 25 contents->profile()->GetChromeURLDataManager()->AddDataSource( |
25 new PrintPreviewDataSource()); | 26 new PrintPreviewDataSource()); |
26 | 27 |
27 // Store the PrintPreviewUIAddress as a string. | 28 // Store the PrintPreviewUIAddress as a string. |
28 // "0x" + deadc0de + '\0' = 2 + 2 * sizeof(this) + 1; | 29 // "0x" + deadc0de + '\0' = 2 + 2 * sizeof(this) + 1; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 StringValue title(job_title); | 66 StringValue title(job_title); |
66 FundamentalValue is_preview_modifiable(modifiable); | 67 FundamentalValue is_preview_modifiable(modifiable); |
67 StringValue ui_identifier(preview_ui_addr_str_); | 68 StringValue ui_identifier(preview_ui_addr_str_); |
68 CallJavascriptFunction("updatePrintPreview", pages_count, title, | 69 CallJavascriptFunction("updatePrintPreview", pages_count, title, |
69 is_preview_modifiable, ui_identifier); | 70 is_preview_modifiable, ui_identifier); |
70 } | 71 } |
71 | 72 |
72 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { | 73 PrintPreviewDataService* PrintPreviewUI::print_preview_data_service() { |
73 return PrintPreviewDataService::GetInstance(); | 74 return PrintPreviewDataService::GetInstance(); |
74 } | 75 } |
OLD | NEW |