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

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

Issue 8879046: Print preview: Disable the right context menu items in print preview. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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_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"
11 #include "base/memory/ref_counted_memory.h" 11 #include "base/memory/ref_counted_memory.h"
12 #include "base/shared_memory.h" 12 #include "base/shared_memory.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/printing/print_job_manager.h" 14 #include "chrome/browser/printing/print_job_manager.h"
15 #include "chrome/browser/printing/print_preview_tab_controller.h" 15 #include "chrome/browser/printing/print_preview_tab_controller.h"
16 #include "chrome/browser/printing/print_view_manager.h" 16 #include "chrome/browser/printing/print_view_manager.h"
17 #include "chrome/browser/printing/printer_query.h" 17 #include "chrome/browser/printing/printer_query.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
19 #include "chrome/browser/ui/webui/print_preview_ui.h" 19 #include "chrome/browser/ui/webui/print_preview_ui.h"
20 #include "chrome/common/print_messages.h" 20 #include "chrome/common/print_messages.h"
21 #include "content/browser/renderer_host/render_view_host.h" 21 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/browser/tab_contents/tab_contents.h" 22 #include "content/browser/tab_contents/tab_contents.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/common/content_restriction.h"
24 #include "printing/page_size_margins.h" 25 #include "printing/page_size_margins.h"
25 #include "printing/print_job_constants.h" 26 #include "printing/print_job_constants.h"
26 27
27 using content::BrowserThread; 28 using content::BrowserThread;
28 29
29 namespace { 30 namespace {
30 31
31 void StopWorker(int document_cookie) { 32 void StopWorker(int document_cookie) {
32 if (document_cookie <= 0) 33 if (document_cookie <= 0)
33 return; 34 return;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 OnDidGetDefaultPageLayout) 237 OnDidGetDefaultPageLayout)
237 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled, 238 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewCancelled,
238 OnPrintPreviewCancelled) 239 OnPrintPreviewCancelled)
239 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings, 240 IPC_MESSAGE_HANDLER(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
240 OnInvalidPrinterSettings) 241 OnInvalidPrinterSettings)
241 IPC_MESSAGE_UNHANDLED(handled = false) 242 IPC_MESSAGE_UNHANDLED(handled = false)
242 IPC_END_MESSAGE_MAP() 243 IPC_END_MESSAGE_MAP()
243 return handled; 244 return handled;
244 } 245 }
245 246
247 void PrintPreviewMessageHandler::DidStartLoading() {
248 // This helps prevents the print preview tab from being able to print.
Lei Zhang 2011/12/09 07:07:49 Should not have removed this earlier.
249 // It also disables the print menu entry.
250 if (tab_contents()->delegate() &&
251 PrintPreviewTabController::IsPrintPreviewTab(tab_contents_wrapper())) {
252 tab_contents()->SetContentRestrictions(content::CONTENT_RESTRICTION_PRINT);
253 }
254 }
255
246 void PrintPreviewMessageHandler::NavigateToPendingEntry( 256 void PrintPreviewMessageHandler::NavigateToPendingEntry(
247 const GURL& url, 257 const GURL& url,
248 NavigationController::ReloadType reload_type) { 258 NavigationController::ReloadType reload_type) {
249 TabContentsWrapper* tab = tab_contents_wrapper(); 259 TabContentsWrapper* tab = tab_contents_wrapper();
250 TabContentsWrapper* preview_tab = GetPrintPreviewTab(); 260 TabContentsWrapper* preview_tab = GetPrintPreviewTab();
251 if (tab == preview_tab) { 261 if (tab == preview_tab) {
252 // Cloud print sign-in reloads the page. 262 // Cloud print sign-in reloads the page.
253 DCHECK(PrintPreviewTabController::IsPrintPreviewURL(url)); 263 DCHECK(PrintPreviewTabController::IsPrintPreviewURL(url));
254 DCHECK_EQ(NavigationController::RELOAD, reload_type); 264 DCHECK_EQ(NavigationController::RELOAD, reload_type);
255 return; 265 return;
256 } 266 }
257 // If |tab| is navigating and it has a print preview tab, notify |tab| to 267 // If |tab| is navigating and it has a print preview tab, notify |tab| to
258 // consider print preview done so it unfreezes the renderer in the case of 268 // consider print preview done so it unfreezes the renderer in the case of
259 // window.print(). 269 // window.print().
260 if (preview_tab) 270 if (preview_tab)
261 tab->print_view_manager()->PrintPreviewDone(); 271 tab->print_view_manager()->PrintPreviewDone();
262 } 272 }
263 273
264 } // namespace printing 274 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698