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/printing/print_view_manager.cc

Issue 8761014: Print Preview: Set source modifiable bit for scripted printing. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: remove logging statement Created 9 years 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) 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/printing/print_view_manager.h" 5 #include "chrome/browser/printing/print_view_manager.h"
6 6
7 #include <map>
8
7 #include "base/bind.h" 9 #include "base/bind.h"
8 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
9 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
10 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/printing/print_job.h" 14 #include "chrome/browser/printing/print_job.h"
13 #include "chrome/browser/printing/print_job_manager.h" 15 #include "chrome/browser/printing/print_job_manager.h"
14 #include "chrome/browser/printing/print_preview_tab_controller.h" 16 #include "chrome/browser/printing/print_preview_tab_controller.h"
15 #include "chrome/browser/printing/printer_query.h" 17 #include "chrome/browser/printing/printer_query.h"
16 #include "chrome/browser/printing/print_view_manager_observer.h" 18 #include "chrome/browser/printing/print_view_manager_observer.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 253
252 void PrintViewManager::OnPrintingFailed(int cookie) { 254 void PrintViewManager::OnPrintingFailed(int cookie) {
253 ReleasePrinterQuery(cookie); 255 ReleasePrinterQuery(cookie);
254 256
255 content::NotificationService::current()->Notify( 257 content::NotificationService::current()->Notify(
256 chrome::NOTIFICATION_PRINT_JOB_RELEASED, 258 chrome::NOTIFICATION_PRINT_JOB_RELEASED,
257 content::Source<TabContents>(tab_contents()), 259 content::Source<TabContents>(tab_contents()),
258 content::NotificationService::NoDetails()); 260 content::NotificationService::NoDetails());
259 } 261 }
260 262
261 void PrintViewManager::OnScriptedPrintPreview(IPC::Message* reply_msg) { 263 void PrintViewManager::OnScriptedPrintPreview(bool source_is_modifiable,
264 IPC::Message* reply_msg) {
262 BrowserThread::CurrentlyOn(BrowserThread::UI); 265 BrowserThread::CurrentlyOn(BrowserThread::UI);
263 ScriptedPrintPreviewClosureMap& map = 266 ScriptedPrintPreviewClosureMap& map =
264 g_scripted_print_preview_closure_map.Get(); 267 g_scripted_print_preview_closure_map.Get();
265 content::RenderProcessHost* rph = 268 content::RenderProcessHost* rph =
266 tab_contents()->render_view_host()->process(); 269 tab_contents()->render_view_host()->process();
267 270
268 // This should always be 0 once we get modal window.print(). 271 // This should always be 0 once we get modal window.print().
269 if (map.count(rph) != 0) { 272 if (map.count(rph) != 0) {
270 // Renderer already handling window.print() in another View. 273 // Renderer already handling window.print() in another View.
271 Send(reply_msg); 274 Send(reply_msg);
272 return; 275 return;
273 } 276 }
274 if (print_preview_state_ != NOT_PREVIEWING) { 277 if (print_preview_state_ != NOT_PREVIEWING) {
275 // If a user initiated print dialog is already open, ignore the scripted 278 // If a user initiated print dialog is already open, ignore the scripted
276 // print message. 279 // print message.
277 DCHECK_EQ(USER_INITIATED_PREVIEW, print_preview_state_); 280 DCHECK_EQ(USER_INITIATED_PREVIEW, print_preview_state_);
278 Send(reply_msg); 281 Send(reply_msg);
279 return; 282 return;
280 } 283 }
281 284
285 PrintPreviewTabController* tab_controller =
286 PrintPreviewTabController::GetInstance();
287 if (!tab_controller) {
288 Send(reply_msg);
289 return;
290 }
291
282 print_preview_state_ = SCRIPTED_PREVIEW; 292 print_preview_state_ = SCRIPTED_PREVIEW;
283 base::Closure callback = 293 base::Closure callback =
284 base::Bind(&PrintViewManager::OnScriptedPrintPreviewReply, 294 base::Bind(&PrintViewManager::OnScriptedPrintPreviewReply,
285 base::Unretained(this), 295 base::Unretained(this),
286 reply_msg); 296 reply_msg);
287 map[rph] = callback; 297 map[rph] = callback;
288 scripted_print_preview_rph_ = rph; 298 scripted_print_preview_rph_ = rph;
289 299
290 PrintPreviewTabController::PrintPreview(tab_); 300 tab_controller->PrintPreview(tab_);
301 PrintPreviewUI::SetSourceIsModifiable(
302 tab_controller->GetPrintPreviewForTab(tab_),
303 source_is_modifiable);
291 } 304 }
292 305
293 void PrintViewManager::OnScriptedPrintPreviewReply(IPC::Message* reply_msg) { 306 void PrintViewManager::OnScriptedPrintPreviewReply(IPC::Message* reply_msg) {
294 BrowserThread::CurrentlyOn(BrowserThread::UI); 307 BrowserThread::CurrentlyOn(BrowserThread::UI);
295 Send(reply_msg); 308 Send(reply_msg);
296 } 309 }
297 310
298 bool PrintViewManager::OnMessageReceived(const IPC::Message& message) { 311 bool PrintViewManager::OnMessageReceived(const IPC::Message& message) {
299 bool handled = true; 312 bool handled = true;
300 IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message) 313 IPC_BEGIN_MESSAGE_MAP(PrintViewManager, message)
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 } 594 }
582 595
583 bool PrintViewManager::PrintNowInternal(IPC::Message* message) { 596 bool PrintViewManager::PrintNowInternal(IPC::Message* message) {
584 // Don't print / print preview interstitials. 597 // Don't print / print preview interstitials.
585 if (tab_contents()->showing_interstitial_page()) 598 if (tab_contents()->showing_interstitial_page())
586 return false; 599 return false;
587 return Send(message); 600 return Send(message);
588 } 601 }
589 602
590 } // namespace printing 603 } // namespace printing
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_view_manager.h ('k') | chrome/browser/ui/webui/print_preview_ui.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698