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/dom_ui/print_preview_ui.h" | 5 #include "chrome/browser/dom_ui/print_preview_ui.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/browser/browser_thread.h" | 8 #include "chrome/browser/browser_thread.h" |
9 #include "chrome/browser/dom_ui/print_preview_handler.h" | 9 #include "chrome/browser/dom_ui/print_preview_handler.h" |
10 #include "chrome/browser/dom_ui/print_preview_ui_html_source.h" | 10 #include "chrome/browser/dom_ui/print_preview_ui_html_source.h" |
| 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/tab_contents/tab_contents.h" |
11 | 13 |
12 PrintPreviewUI::PrintPreviewUI(TabContents* contents) | 14 PrintPreviewUI::PrintPreviewUI(TabContents* contents) |
13 : DOMUI(contents), | 15 : DOMUI(contents), |
14 html_source_(new PrintPreviewUIHTMLSource()) { | 16 html_source_(new PrintPreviewUIHTMLSource()) { |
15 // PrintPreviewUI owns |handler|. | 17 // PrintPreviewUI owns |handler|. |
16 PrintPreviewHandler* handler = new PrintPreviewHandler(); | 18 PrintPreviewHandler* handler = new PrintPreviewHandler(); |
17 AddMessageHandler(handler->Attach(this)); | 19 AddMessageHandler(handler->Attach(this)); |
18 | 20 |
19 // Set up the chrome://print/ source. | 21 // Set up the chrome://print/ source. |
20 BrowserThread::PostTask( | 22 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source_); |
21 BrowserThread::IO, FROM_HERE, | |
22 NewRunnableMethod( | |
23 ChromeURLDataManager::GetInstance(), | |
24 &ChromeURLDataManager::AddDataSource, | |
25 html_source_)); | |
26 } | 23 } |
27 | 24 |
28 PrintPreviewUI::~PrintPreviewUI() { | 25 PrintPreviewUI::~PrintPreviewUI() { |
29 } | 26 } |
30 | 27 |
31 PrintPreviewUIHTMLSource* PrintPreviewUI::html_source() { | 28 PrintPreviewUIHTMLSource* PrintPreviewUI::html_source() { |
32 return html_source_.get(); | 29 return html_source_.get(); |
33 } | 30 } |
34 | 31 |
35 void PrintPreviewUI::PreviewDataIsAvailable() { | 32 void PrintPreviewUI::PreviewDataIsAvailable() { |
36 StringValue dummy_url("chrome://print/print.pdf"); | 33 StringValue dummy_url("chrome://print/print.pdf"); |
37 CallJavascriptFunction(L"createPDFPlugin", dummy_url); | 34 CallJavascriptFunction(L"createPDFPlugin", dummy_url); |
38 } | 35 } |
OLD | NEW |