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