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

Side by Side Diff: chrome/browser/printing/print_preview_message_handler.cc

Issue 10911351: Switch PrintViewManager, PrintPreviewMessageHandler to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix typo Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/printing/print_preview_message_handler.h" 5 #include "chrome/browser/printing/print_preview_message_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/public/browser/browser_thread.h" 21 #include "content/public/browser/browser_thread.h"
22 #include "content/public/browser/render_view_host.h" 22 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
24 #include "content/public/browser/web_ui.h" 24 #include "content/public/browser/web_ui.h"
25 #include "printing/page_size_margins.h" 25 #include "printing/page_size_margins.h"
26 #include "printing/print_job_constants.h" 26 #include "printing/print_job_constants.h"
27 27
28 using content::BrowserThread; 28 using content::BrowserThread;
29 using content::WebContents; 29 using content::WebContents;
30 30
31 int printing::PrintPreviewMessageHandler::kUserDataKey;
32
31 namespace { 33 namespace {
32 34
33 void StopWorker(int document_cookie) { 35 void StopWorker(int document_cookie) {
34 if (document_cookie <= 0) 36 if (document_cookie <= 0)
35 return; 37 return;
36 38
37 printing::PrintJobManager* print_job_manager = 39 printing::PrintJobManager* print_job_manager =
38 g_browser_process->print_job_manager(); 40 g_browser_process->print_job_manager();
39 scoped_refptr<printing::PrinterQuery> printer_query; 41 scoped_refptr<printing::PrinterQuery> printer_query;
40 print_job_manager->PopPrinterQuery(document_cookie, &printer_query); 42 print_job_manager->PopPrinterQuery(document_cookie, &printer_query);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 74
73 PrintPreviewMessageHandler::~PrintPreviewMessageHandler() { 75 PrintPreviewMessageHandler::~PrintPreviewMessageHandler() {
74 } 76 }
75 77
76 TabContents* PrintPreviewMessageHandler::GetPrintPreviewTab() { 78 TabContents* PrintPreviewMessageHandler::GetPrintPreviewTab() {
77 PrintPreviewTabController* tab_controller = 79 PrintPreviewTabController* tab_controller =
78 PrintPreviewTabController::GetInstance(); 80 PrintPreviewTabController::GetInstance();
79 if (!tab_controller) 81 if (!tab_controller)
80 return NULL; 82 return NULL;
81 83
82 return tab_controller->GetPrintPreviewForTab(tab_contents()); 84 return tab_controller->GetPrintPreviewForTab(
83 } 85 TabContents::FromWebContents(web_contents()));
84
85 TabContents* PrintPreviewMessageHandler::tab_contents() {
86 return TabContents::FromWebContents(web_contents());
87 } 86 }
88 87
89 PrintPreviewUI* PrintPreviewMessageHandler::GetPrintPreviewUI() { 88 PrintPreviewUI* PrintPreviewMessageHandler::GetPrintPreviewUI() {
90 TabContents* tab = GetPrintPreviewTab(); 89 TabContents* tab = GetPrintPreviewTab();
91 if (!tab || !tab->web_contents()->GetWebUI()) 90 if (!tab || !tab->web_contents()->GetWebUI())
92 return NULL; 91 return NULL;
93 return static_cast<PrintPreviewUI*>( 92 return static_cast<PrintPreviewUI*>(
94 tab->web_contents()->GetWebUI()->GetController()); 93 tab->web_contents()->GetWebUI()->GetController());
95 } 94 }
96 95
97 void PrintPreviewMessageHandler::OnRequestPrintPreview( 96 void PrintPreviewMessageHandler::OnRequestPrintPreview(
98 bool source_is_modifiable, bool webnode_only) { 97 bool source_is_modifiable, bool webnode_only) {
99 TabContents* tab = tab_contents(); 98 if (webnode_only) {
100 if (webnode_only) 99 printing::PrintViewManager::FromWebContents(web_contents())->
101 tab->print_view_manager()->PrintPreviewForWebNode(); 100 PrintPreviewForWebNode();
102 PrintPreviewTabController::PrintPreview(tab); 101 }
102 PrintPreviewTabController::PrintPreview(
103 TabContents::FromWebContents(web_contents()));
103 PrintPreviewUI::SetSourceIsModifiable(GetPrintPreviewTab(), 104 PrintPreviewUI::SetSourceIsModifiable(GetPrintPreviewTab(),
104 source_is_modifiable); 105 source_is_modifiable);
105 } 106 }
106 107
107 void PrintPreviewMessageHandler::OnDidGetPreviewPageCount( 108 void PrintPreviewMessageHandler::OnDidGetPreviewPageCount(
108 const PrintHostMsg_DidGetPreviewPageCount_Params& params) { 109 const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
109 if (params.page_count <= 0) { 110 if (params.page_count <= 0) {
110 NOTREACHED(); 111 NOTREACHED();
111 return; 112 return;
112 } 113 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, 242 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
242 OnInvalidPrinterSettings) 243 OnInvalidPrinterSettings)
243 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewScalingDisabled, 244 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewScalingDisabled,
244 OnPrintPreviewScalingDisabled) 245 OnPrintPreviewScalingDisabled)
245 IPC_MESSAGE_UNHANDLED(handled = false) 246 IPC_MESSAGE_UNHANDLED(handled = false)
246 IPC_END_MESSAGE_MAP() 247 IPC_END_MESSAGE_MAP()
247 return handled; 248 return handled;
248 } 249 }
249 250
250 } // namespace printing 251 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_message_handler.h ('k') | chrome/browser/printing/print_preview_tab_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698