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

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

Issue 23855002: Fixing spreadsheets printing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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
« no previous file with comments | « chrome/browser/printing/print_view_manager.h ('k') | chrome/common/print_messages.h » ('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) 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_view_manager.h" 5 #include "chrome/browser/printing/print_view_manager.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 if (!PrintNowInternal(new PrintMsg_InitiatePrintPreview(routing_id(), 90 if (!PrintNowInternal(new PrintMsg_InitiatePrintPreview(routing_id(),
91 selection_only))) { 91 selection_only))) {
92 return false; 92 return false;
93 } 93 }
94 94
95 print_preview_state_ = USER_INITIATED_PREVIEW; 95 print_preview_state_ = USER_INITIATED_PREVIEW;
96 return true; 96 return true;
97 } 97 }
98 98
99 void PrintViewManager::PrintPreviewForWebNode() { 99 void PrintViewManager::PrintPreviewForWebNode() {
100 DCHECK_EQ(NOT_PREVIEWING, print_preview_state_); 100 if (print_preview_state_ != NOT_PREVIEWING)
101 return;
101 print_preview_state_ = USER_INITIATED_PREVIEW; 102 print_preview_state_ = USER_INITIATED_PREVIEW;
102 } 103 }
103 104
104 void PrintViewManager::PrintPreviewDone() { 105 void PrintViewManager::PrintPreviewDone() {
105 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 106 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
106 DCHECK_NE(NOT_PREVIEWING, print_preview_state_); 107 DCHECK_NE(NOT_PREVIEWING, print_preview_state_);
107 108
108 if (print_preview_state_ == SCRIPTED_PREVIEW) { 109 if (print_preview_state_ == SCRIPTED_PREVIEW) {
109 ScriptedPrintPreviewClosureMap& map = 110 ScriptedPrintPreviewClosureMap& map =
110 g_scripted_print_preview_closure_map.Get(); 111 g_scripted_print_preview_closure_map.Get();
(...skipping 15 matching lines...) Expand all
126 void PrintViewManager::RenderProcessGone(base::TerminationStatus status) { 127 void PrintViewManager::RenderProcessGone(base::TerminationStatus status) {
127 print_preview_state_ = NOT_PREVIEWING; 128 print_preview_state_ = NOT_PREVIEWING;
128 PrintViewManagerBase::RenderProcessGone(status); 129 PrintViewManagerBase::RenderProcessGone(status);
129 } 130 }
130 131
131 void PrintViewManager::OnDidShowPrintDialog() { 132 void PrintViewManager::OnDidShowPrintDialog() {
132 if (observer_) 133 if (observer_)
133 observer_->OnPrintDialogShown(); 134 observer_->OnPrintDialogShown();
134 } 135 }
135 136
136 void PrintViewManager::OnScriptedPrintPreview(bool source_is_modifiable, 137 void PrintViewManager::OnSetupScriptedPrintPreview(IPC::Message* reply_msg) {
137 IPC::Message* reply_msg) {
138 BrowserThread::CurrentlyOn(BrowserThread::UI); 138 BrowserThread::CurrentlyOn(BrowserThread::UI);
139 ScriptedPrintPreviewClosureMap& map = 139 ScriptedPrintPreviewClosureMap& map =
140 g_scripted_print_preview_closure_map.Get(); 140 g_scripted_print_preview_closure_map.Get();
141 content::RenderProcessHost* rph = web_contents()->GetRenderProcessHost(); 141 content::RenderProcessHost* rph = web_contents()->GetRenderProcessHost();
142 142
143 // This should always be 0 once we get modal window.print(). 143 // This should always be 0 once we get modal window.print().
144 if (map.count(rph) != 0) { 144 if (map.count(rph) != 0) {
145 // Renderer already handling window.print() in another View. 145 // Renderer already handling window.print() in another View.
146 Send(reply_msg); 146 Send(reply_msg);
147 return; 147 return;
(...skipping 13 matching lines...) Expand all
161 return; 161 return;
162 } 162 }
163 163
164 print_preview_state_ = SCRIPTED_PREVIEW; 164 print_preview_state_ = SCRIPTED_PREVIEW;
165 base::Closure callback = 165 base::Closure callback =
166 base::Bind(&PrintViewManager::OnScriptedPrintPreviewReply, 166 base::Bind(&PrintViewManager::OnScriptedPrintPreviewReply,
167 base::Unretained(this), 167 base::Unretained(this),
168 reply_msg); 168 reply_msg);
169 map[rph] = callback; 169 map[rph] = callback;
170 scripted_print_preview_rph_ = rph; 170 scripted_print_preview_rph_ = rph;
171 }
171 172
173 void PrintViewManager::OnShowScriptedPrintPreview(bool source_is_modifiable) {
174 PrintPreviewDialogController* dialog_controller =
175 PrintPreviewDialogController::GetInstance();
176 if (!dialog_controller) {
177 PrintPreviewDone();
178 return;
179 }
172 dialog_controller->PrintPreview(web_contents()); 180 dialog_controller->PrintPreview(web_contents());
173 PrintHostMsg_RequestPrintPreview_Params params; 181 PrintHostMsg_RequestPrintPreview_Params params;
174 params.is_modifiable = source_is_modifiable; 182 params.is_modifiable = source_is_modifiable;
175 PrintPreviewUI::SetInitialParams( 183 PrintPreviewUI::SetInitialParams(
176 dialog_controller->GetPrintPreviewForContents(web_contents()), params); 184 dialog_controller->GetPrintPreviewForContents(web_contents()), params);
177 } 185 }
178 186
179 void PrintViewManager::OnScriptedPrintPreviewReply(IPC::Message* reply_msg) { 187 void PrintViewManager::OnScriptedPrintPreviewReply(IPC::Message* reply_msg) {
180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 188 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
181 Send(reply_msg); 189 Send(reply_msg);
182 } 190 }
183 191
184 bool PrintViewManager::OnMessageReceived(const IPC::Message& message) { 192 bool PrintViewManager::OnMessageReceived(const IPC::Message& message) {
185 bool handled = true; 193 bool handled = true;
186 IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message) 194 IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message)
187 IPC_MESSAGE_HANDLER(PrintHostMsg_DidShowPrintDialog, OnDidShowPrintDialog) 195 IPC_MESSAGE_HANDLER(PrintHostMsg_DidShowPrintDialog, OnDidShowPrintDialog)
188 IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_ScriptedPrintPreview, 196 IPC_MESSAGE_HANDLER_DELAY_REPLY(PrintHostMsg_SetupScriptedPrintPreview,
189 OnScriptedPrintPreview) 197 OnSetupScriptedPrintPreview)
198 IPC_MESSAGE_HANDLER(PrintHostMsg_ShowScriptedPrintPreview,
199 OnShowScriptedPrintPreview)
190 IPC_MESSAGE_UNHANDLED(handled = false) 200 IPC_MESSAGE_UNHANDLED(handled = false)
191 IPC_END_MESSAGE_MAP() 201 IPC_END_MESSAGE_MAP()
192 202
193 return handled ? true : PrintViewManagerBase::OnMessageReceived(message); 203 return handled ? true : PrintViewManagerBase::OnMessageReceived(message);
194 } 204 }
195 205
196 } // namespace printing 206 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_view_manager.h ('k') | chrome/common/print_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698