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

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

Issue 7202012: Print Preview: Display a throbber when the user requests the system print (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 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
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 #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ 6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "content/browser/tab_contents/tab_contents_observer.h" 11 #include "content/browser/tab_contents/tab_contents_observer.h"
12 #include "content/common/notification_observer.h" 12 #include "content/common/notification_observer.h"
13 #include "content/common/notification_registrar.h" 13 #include "content/common/notification_registrar.h"
14 #include "printing/printed_pages_source.h" 14 #include "printing/printed_pages_source.h"
15 15
16 class RenderViewHost; 16 class RenderViewHost;
17 class TabContentsWrapper; 17 class TabContentsWrapper;
18 struct PrintHostMsg_DidPrintPage_Params; 18 struct PrintHostMsg_DidPrintPage_Params;
19 19
20 namespace printing { 20 namespace printing {
21 21
22 class JobEventDetails; 22 class JobEventDetails;
23 class PrintJob; 23 class PrintJob;
24 class PrintJobWorkerOwner; 24 class PrintJobWorkerOwner;
25 class PrintViewManagerObserver;
25 26
26 // Manages the print commands in relation to a TabContents. TabContents 27 // Manages the print commands in relation to a TabContents. TabContents
27 // delegates a few printing related commands to this instance. 28 // delegates a few printing related commands to this instance.
28 class PrintViewManager : public NotificationObserver, 29 class PrintViewManager : public NotificationObserver,
29 public PrintedPagesSource, 30 public PrintedPagesSource,
30 public TabContentsObserver { 31 public TabContentsObserver {
31 public: 32 public:
32 explicit PrintViewManager(TabContentsWrapper* tab); 33 explicit PrintViewManager(TabContentsWrapper* tab);
33 virtual ~PrintViewManager(); 34 virtual ~PrintViewManager();
34 35
35 // Override the title for this PrintViewManager's PrintJobs using the title 36 // Override the title for this PrintViewManager's PrintJobs using the title
36 // in |tab_contents|. 37 // in |tab_contents|.
37 void OverrideTitle(TabContents* tab_contents); 38 void OverrideTitle(TabContents* tab_contents);
38 39
39 // Prints the current document immediately. Since the rendering is 40 // Prints the current document immediately. Since the rendering is
40 // asynchronous, the actual printing will not be completed on the return of 41 // asynchronous, the actual printing will not be completed on the return of
41 // this function. Returns false if printing is impossible at the moment. 42 // this function. Returns false if printing is impossible at the moment.
42 bool PrintNow(); 43 bool PrintNow();
43 44
44 // Initiate print preview of the current document by first notifying the 45 // Initiate print preview of the current document by first notifying the
45 // renderer. Since this happens asynchronous, the print preview tab creation 46 // renderer. Since this happens asynchronous, the print preview tab creation
46 // will not be completed on the return of this function. Returns false if 47 // will not be completed on the return of this function. Returns false if
47 // print preview is impossible at the moment. 48 // print preview is impossible at the moment.
48 bool PrintPreviewNow(); 49 bool PrintPreviewNow();
49 50
50 // Handles cancelled preview printing request. 51 // Handles cancelled preview printing request.
51 void PreviewPrintingRequestCancelled(); 52 void PreviewPrintingRequestCancelled();
52 53
54 // Sets |observer| as the current PrintViewManagerObserver. Pass in NULL to
55 // remove the current observer. |observer| may always be NULL, but |observer_|
56 // must be NULL if |observer| is non-NULL.
57 void set_observer(PrintViewManagerObserver* observer);
58
53 // PrintedPagesSource implementation. 59 // PrintedPagesSource implementation.
54 virtual string16 RenderSourceName(); 60 virtual string16 RenderSourceName();
55 virtual GURL RenderSourceUrl(); 61 virtual GURL RenderSourceUrl();
56 62
57 // NotificationObserver implementation. 63 // NotificationObserver implementation.
58 virtual void Observe(NotificationType type, 64 virtual void Observe(NotificationType type,
59 const NotificationSource& source, 65 const NotificationSource& source,
60 const NotificationDetails& details); 66 const NotificationDetails& details);
61 67
62 // TabContentsObserver implementation. 68 // TabContentsObserver implementation.
63 virtual bool OnMessageReceived(const IPC::Message& message); 69 virtual bool OnMessageReceived(const IPC::Message& message);
64 70
65 // Terminates or cancels the print job if one was pending. 71 // Terminates or cancels the print job if one was pending.
66 virtual void RenderViewGone(); 72 virtual void RenderViewGone();
67 73
68 // Cancels the print job. 74 // Cancels the print job.
69 virtual void StopNavigation(); 75 virtual void StopNavigation();
70 76
71 private: 77 private:
72 // IPC Message handlers. 78 // IPC Message handlers.
73 void OnDidGetPrintedPagesCount(int cookie, int number_pages); 79 void OnDidGetPrintedPagesCount(int cookie, int number_pages);
80 void OnDidShowPrintDialog();
74 void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params); 81 void OnDidPrintPage(const PrintHostMsg_DidPrintPage_Params& params);
75 void OnPrintingFailed(int cookie); 82 void OnPrintingFailed(int cookie);
76 83
77 // Processes a NOTIFY_PRINT_JOB_EVENT notification. 84 // Processes a NOTIFY_PRINT_JOB_EVENT notification.
78 void OnNotifyPrintJobEvent(const JobEventDetails& event_details); 85 void OnNotifyPrintJobEvent(const JobEventDetails& event_details);
79 86
80 // Requests the RenderView to render all the missing pages for the print job. 87 // Requests the RenderView to render all the missing pages for the print job.
81 // Noop if no print job is pending. Returns true if at least one page has been 88 // Noop if no print job is pending. Returns true if at least one page has been
82 // requested to the renderer. 89 // requested to the renderer.
83 bool RenderAllMissingPagesNow(); 90 bool RenderAllMissingPagesNow();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 150
144 #if defined(OS_POSIX) && !defined(OS_MACOSX) 151 #if defined(OS_POSIX) && !defined(OS_MACOSX)
145 // Set to true when OnDidPrintPage() should be expecting the first page. 152 // Set to true when OnDidPrintPage() should be expecting the first page.
146 bool expecting_first_page_; 153 bool expecting_first_page_;
147 #endif 154 #endif
148 155
149 // Title override. 156 // Title override.
150 bool is_title_overridden_; 157 bool is_title_overridden_;
151 string16 overridden_title_; 158 string16 overridden_title_;
152 159
160 // Weak pointer to an observer that is notified when the print dialog is
161 // shown.
162 PrintViewManagerObserver* observer_;
163
153 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); 164 DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
154 }; 165 };
155 166
156 } // namespace printing 167 } // namespace printing
157 168
158 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ 169 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_tab_controller.cc ('k') | chrome/browser/printing/print_view_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698