Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(238)

Side by Side Diff: chrome/browser/dom_ui/print_ui.cc

Issue 155067: Hookup Print HTML page to the DOM UI for Print Preview and Settings... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/dom_ui/print_ui.h ('k') | chrome/browser/resources/print_tab.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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_ui.h" 5 #include "chrome/browser/dom_ui/print_ui.h"
6 6
7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h"
9 #include "base/message_loop.h"
10 #include "base/thread.h"
11 #include "base/values.h"
12 #include "chrome/browser/browser_process.h"
13 #include "chrome/common/jstemplate_builder.h"
14 #include "chrome/common/url_constants.h"
15
16 #include "grit/browser_resources.h"
17 #include "grit/generated_resources.h"
18
7 /////////////////////////////////////////////////////////////////////////////// 19 ///////////////////////////////////////////////////////////////////////////////
8 // 20 //
9 // PrintUI 21 // PrintUI
10 // 22 //
11 /////////////////////////////////////////////////////////////////////////////// 23 ///////////////////////////////////////////////////////////////////////////////
12 24
13 PrintUI::PrintUI(TabContents* contents) : DOMUI(contents) { 25 PrintUI::PrintUI(TabContents* contents) : DOMUI(contents) {
14 NOTIMPLEMENTED(); 26 PrintUIHTMLSource* html_source = new PrintUIHTMLSource();
27
28 // Set up the print:url source.
29 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
30 NewRunnableMethod(&chrome_url_data_manager,
31 &ChromeURLDataManager::AddDataSource,
32 html_source));
15 } 33 }
34
35 ////////////////////////////////////////////////////////////////////////////////
36 //
37 // PrintUIHTMLSource
38 //
39 ////////////////////////////////////////////////////////////////////////////////
40
41 PrintUIHTMLSource::PrintUIHTMLSource()
42 : DataSource(chrome::kPrintScheme, MessageLoop::current()) {
43 }
44
45 void PrintUIHTMLSource::StartDataRequest(const std::string& path,
46 int request_id) {
47 // Setup a dictionary so that the html page could read the values.
48 DictionaryValue localized_strings;
49 localized_strings.SetString(L"title",
50 l10n_util::GetString(IDS_PRINT));
51
52 SetFontAndTextDirection(&localized_strings);
53
54 // Setup the print html page.
55 static const StringPiece print_html(
56 ResourceBundle::GetSharedInstance().GetRawDataResource(
57 IDR_PRINT_TAB_HTML));
58 const std::string full_html = jstemplate_builder::GetTemplateHtml(
59 print_html, &localized_strings, "t");
60
61 // Load the print html page into the tab contents.
62 scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
63 html_bytes->data.resize(full_html.size());
64 std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
65 SendResponse(request_id, html_bytes);
66 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/print_ui.h ('k') | chrome/browser/resources/print_tab.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698