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

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

Issue 10214001: WebDialogs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 #ifndef CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_ 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_ 6 #define CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/file_path.h" 13 #include "base/file_path.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "chrome/browser/ui/webui/html_dialog_ui.h" 16 #include "chrome/browser/ui/webui/web_dialog_ui.h"
17 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_ui_message_handler.h" 19 #include "content/public/browser/web_ui_message_handler.h"
20 20
21 class GURL; 21 class GURL;
22 class CloudPrintHtmlDialogDelegateTest; 22 class CloudPrintWebDialogDelegateTest;
23 23
24 namespace base { 24 namespace base {
25 class ListValue; 25 class ListValue;
26 class StringValue; 26 class StringValue;
27 class Value; 27 class Value;
28 } 28 }
29 29
30 namespace internal_cloud_print_helpers { 30 namespace internal_cloud_print_helpers {
31 31
32 // Small class to virtualize a few functions to aid with unit testing. 32 // Small class to virtualize a few functions to aid with unit testing.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 base::Lock lock_; 86 base::Lock lock_;
87 CloudPrintDataSenderHelper* volatile helper_; 87 CloudPrintDataSenderHelper* volatile helper_;
88 scoped_ptr<base::StringValue> print_data_; 88 scoped_ptr<base::StringValue> print_data_;
89 string16 print_job_title_; 89 string16 print_job_title_;
90 string16 print_ticket_; 90 string16 print_ticket_;
91 std::string file_type_; 91 std::string file_type_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(CloudPrintDataSender); 93 DISALLOW_COPY_AND_ASSIGN(CloudPrintDataSender);
94 }; 94 };
95 95
96 class CloudPrintHtmlDialogDelegate; 96 class CloudPrintWebDialogDelegate;
97 97
98 // The CloudPrintFlowHandler connects the state machine (the UI delegate) 98 // The CloudPrintFlowHandler connects the state machine (the UI delegate)
99 // to the dialog backing HTML and JS by providing WebUIMessageHandler 99 // to the dialog backing HTML and JS by providing WebUIMessageHandler
100 // functions for the JS to use. This include refreshing the page 100 // functions for the JS to use. This include refreshing the page
101 // setup parameters (which will cause a re-generation of the PDF in 101 // setup parameters (which will cause a re-generation of the PDF in
102 // the renderer process - do we want a progress throbber shown? 102 // the renderer process - do we want a progress throbber shown?
103 // Probably..), and packing up the PDF and job parameters and sending 103 // Probably..), and packing up the PDF and job parameters and sending
104 // them to the cloud. 104 // them to the cloud.
105 class CloudPrintFlowHandler : public content::WebUIMessageHandler, 105 class CloudPrintFlowHandler : public content::WebUIMessageHandler,
106 public content::NotificationObserver { 106 public content::NotificationObserver {
(...skipping 12 matching lines...) Expand all
119 // content::NotificationObserver implementation. 119 // content::NotificationObserver implementation.
120 virtual void Observe(int type, 120 virtual void Observe(int type,
121 const content::NotificationSource& source, 121 const content::NotificationSource& source,
122 const content::NotificationDetails& details) OVERRIDE; 122 const content::NotificationDetails& details) OVERRIDE;
123 123
124 // Callbacks from the page. 124 // Callbacks from the page.
125 void HandleShowDebugger(const base::ListValue* args); 125 void HandleShowDebugger(const base::ListValue* args);
126 void HandleSendPrintData(const base::ListValue* args); 126 void HandleSendPrintData(const base::ListValue* args);
127 void HandleSetPageParameters(const base::ListValue* args); 127 void HandleSetPageParameters(const base::ListValue* args);
128 128
129 virtual void SetDialogDelegate(CloudPrintHtmlDialogDelegate *delegate); 129 virtual void SetDialogDelegate(CloudPrintWebDialogDelegate *delegate);
130 void StoreDialogClientSize() const; 130 void StoreDialogClientSize() const;
131 131
132 private: 132 private:
133 virtual scoped_refptr<CloudPrintDataSender> CreateCloudPrintDataSender(); 133 virtual scoped_refptr<CloudPrintDataSender> CreateCloudPrintDataSender();
134 134
135 // Call to get the debugger loaded on our hosted dialog page 135 // Call to get the debugger loaded on our hosted dialog page
136 // specifically. Since we're not in an official browser tab, only 136 // specifically. Since we're not in an official browser tab, only
137 // way to get the debugger going. 137 // way to get the debugger going.
138 void ShowDebugger(); 138 void ShowDebugger();
139 139
140 void CancelAnyRunningTask(); 140 void CancelAnyRunningTask();
141 141
142 CloudPrintHtmlDialogDelegate* dialog_delegate_; 142 CloudPrintWebDialogDelegate* dialog_delegate_;
143 content::NotificationRegistrar registrar_; 143 content::NotificationRegistrar registrar_;
144 FilePath path_to_file_; 144 FilePath path_to_file_;
145 string16 print_job_title_; 145 string16 print_job_title_;
146 string16 print_ticket_; 146 string16 print_ticket_;
147 std::string file_type_; 147 std::string file_type_;
148 scoped_refptr<CloudPrintDataSender> print_data_sender_; 148 scoped_refptr<CloudPrintDataSender> print_data_sender_;
149 scoped_ptr<CloudPrintDataSenderHelper> print_data_helper_; 149 scoped_ptr<CloudPrintDataSenderHelper> print_data_helper_;
150 bool close_after_signin_; 150 bool close_after_signin_;
151 base::Closure callback_; 151 base::Closure callback_;
152 152
153 DISALLOW_COPY_AND_ASSIGN(CloudPrintFlowHandler); 153 DISALLOW_COPY_AND_ASSIGN(CloudPrintFlowHandler);
154 }; 154 };
155 155
156 // State machine used to run the printing dialog. This class is used 156 // State machine used to run the printing dialog. This class is used
157 // to open and run the html dialog and deletes itself when the dialog 157 // to open and run the web dialog and deletes itself when the dialog
158 // is closed. 158 // is closed.
159 class CloudPrintHtmlDialogDelegate : public HtmlDialogUIDelegate { 159 class CloudPrintWebDialogDelegate : public WebDialogDelegate {
160 public: 160 public:
161 CloudPrintHtmlDialogDelegate(const FilePath& path_to_file, 161 CloudPrintWebDialogDelegate(const FilePath& path_to_file,
162 int width, int height, 162 int width, int height,
163 const std::string& json_arguments, 163 const std::string& json_arguments,
164 const string16& print_job_title, 164 const string16& print_job_title,
165 const string16& print_ticket, 165 const string16& print_ticket,
166 const std::string& file_type, 166 const std::string& file_type,
167 bool modal, 167 bool modal,
168 bool delete_on_close, 168 bool delete_on_close,
169 bool close_after_signin, 169 bool close_after_signin,
170 const base::Closure& callback); 170 const base::Closure& callback);
171 virtual ~CloudPrintHtmlDialogDelegate(); 171 virtual ~CloudPrintWebDialogDelegate();
172 172
173 // HTMLDialogUIDelegate implementation: 173 // WebDialogDelegate implementation:
174 virtual ui::ModalType GetDialogModalType() const OVERRIDE; 174 virtual ui::ModalType GetDialogModalType() const OVERRIDE;
175 virtual string16 GetDialogTitle() const OVERRIDE; 175 virtual string16 GetDialogTitle() const OVERRIDE;
176 virtual GURL GetDialogContentURL() const OVERRIDE; 176 virtual GURL GetDialogContentURL() const OVERRIDE;
177 virtual void GetWebUIMessageHandlers( 177 virtual void GetWebUIMessageHandlers(
178 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; 178 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE;
179 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; 179 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
180 virtual std::string GetDialogArgs() const OVERRIDE; 180 virtual std::string GetDialogArgs() const OVERRIDE;
181 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; 181 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
182 virtual void OnCloseContents(content::WebContents* source, 182 virtual void OnCloseContents(content::WebContents* source,
183 bool* out_close_dialog) OVERRIDE; 183 bool* out_close_dialog) OVERRIDE;
184 virtual bool ShouldShowDialogTitle() const OVERRIDE; 184 virtual bool ShouldShowDialogTitle() const OVERRIDE;
185 virtual bool HandleContextMenu( 185 virtual bool HandleContextMenu(
186 const content::ContextMenuParams& params) OVERRIDE; 186 const content::ContextMenuParams& params) OVERRIDE;
187 187
188 private: 188 private:
189 friend class ::CloudPrintHtmlDialogDelegateTest; 189 friend class ::CloudPrintWebDialogDelegateTest;
190 190
191 // For unit testing. 191 // For unit testing.
192 CloudPrintHtmlDialogDelegate(CloudPrintFlowHandler* flow_handler, 192 CloudPrintWebDialogDelegate(CloudPrintFlowHandler* flow_handler,
193 int width, int height, 193 int width, int height,
194 const std::string& json_arguments, 194 const std::string& json_arguments,
195 bool modal, 195 bool modal,
196 bool delete_on_close); 196 bool delete_on_close);
197 void Init(int width, int height, const std::string& json_arguments); 197 void Init(int width, int height, const std::string& json_arguments);
198 198
199 bool delete_on_close_; 199 bool delete_on_close_;
200 CloudPrintFlowHandler* flow_handler_; 200 CloudPrintFlowHandler* flow_handler_;
201 bool modal_; 201 bool modal_;
202 mutable bool owns_flow_handler_; 202 mutable bool owns_flow_handler_;
203 FilePath path_to_file_; 203 FilePath path_to_file_;
204 204
205 // The parameters needed to display a modal HTML dialog. 205 // The parameters needed to display a modal web dialog.
206 HtmlDialogUI::HtmlDialogParams params_; 206 WebDialogUI::WebDialogParams params_;
207 207
208 DISALLOW_COPY_AND_ASSIGN(CloudPrintHtmlDialogDelegate); 208 DISALLOW_COPY_AND_ASSIGN(CloudPrintWebDialogDelegate);
209 }; 209 };
210 210
211 void CreateDialogFullImpl(const FilePath& path_to_file, 211 void CreateDialogFullImpl(const FilePath& path_to_file,
212 const string16& print_job_title, 212 const string16& print_job_title,
213 const string16& print_ticket, 213 const string16& print_ticket,
214 const std::string& file_type, 214 const std::string& file_type,
215 bool modal, 215 bool modal,
216 bool delete_on_close); 216 bool delete_on_close);
217 void CreateDialogSigninImpl(const base::Closure& callback); 217 void CreateDialogSigninImpl(const base::Closure& callback);
218 218
219 void Delete(const FilePath& path_to_file); 219 void Delete(const FilePath& path_to_file);
220 220
221 } // namespace internal_cloud_print_helpers 221 } // namespace internal_cloud_print_helpers
222 222
223 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_ 223 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_dialog_cloud.cc ('k') | chrome/browser/printing/print_dialog_cloud_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698