OLD | NEW |
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> |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 base::Closure callback_; | 152 base::Closure callback_; |
153 | 153 |
154 DISALLOW_COPY_AND_ASSIGN(CloudPrintFlowHandler); | 154 DISALLOW_COPY_AND_ASSIGN(CloudPrintFlowHandler); |
155 }; | 155 }; |
156 | 156 |
157 // State machine used to run the printing dialog. This class is used | 157 // State machine used to run the printing dialog. This class is used |
158 // to open and run the web dialog and deletes itself when the dialog | 158 // to open and run the web dialog and deletes itself when the dialog |
159 // is closed. | 159 // is closed. |
160 class CloudPrintWebDialogDelegate : public WebDialogDelegate { | 160 class CloudPrintWebDialogDelegate : public WebDialogDelegate { |
161 public: | 161 public: |
162 CloudPrintWebDialogDelegate(const FilePath& path_to_file, | 162 CloudPrintWebDialogDelegate(content::BrowserContext* browser_context, |
163 int width, int height, | 163 gfx::NativeWindow modal_parent, |
| 164 const FilePath& path_to_file, |
164 const std::string& json_arguments, | 165 const std::string& json_arguments, |
165 const string16& print_job_title, | 166 const string16& print_job_title, |
166 const string16& print_ticket, | 167 const string16& print_ticket, |
167 const std::string& file_type, | 168 const std::string& file_type, |
168 bool modal, | |
169 bool delete_on_close, | 169 bool delete_on_close, |
170 bool close_after_signin, | 170 bool close_after_signin, |
171 const base::Closure& callback); | 171 const base::Closure& callback); |
172 virtual ~CloudPrintWebDialogDelegate(); | 172 virtual ~CloudPrintWebDialogDelegate(); |
173 | 173 |
174 // WebDialogDelegate implementation: | 174 // WebDialogDelegate implementation: |
175 virtual ui::ModalType GetDialogModalType() const OVERRIDE; | 175 virtual ui::ModalType GetDialogModalType() const OVERRIDE; |
176 virtual string16 GetDialogTitle() const OVERRIDE; | 176 virtual string16 GetDialogTitle() const OVERRIDE; |
177 virtual GURL GetDialogContentURL() const OVERRIDE; | 177 virtual GURL GetDialogContentURL() const OVERRIDE; |
178 virtual void GetWebUIMessageHandlers( | 178 virtual void GetWebUIMessageHandlers( |
179 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; | 179 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; |
180 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 180 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
181 virtual std::string GetDialogArgs() const OVERRIDE; | 181 virtual std::string GetDialogArgs() const OVERRIDE; |
182 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 182 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
183 virtual void OnCloseContents(content::WebContents* source, | 183 virtual void OnCloseContents(content::WebContents* source, |
184 bool* out_close_dialog) OVERRIDE; | 184 bool* out_close_dialog) OVERRIDE; |
185 virtual bool ShouldShowDialogTitle() const OVERRIDE; | 185 virtual bool ShouldShowDialogTitle() const OVERRIDE; |
186 virtual bool HandleContextMenu( | 186 virtual bool HandleContextMenu( |
187 const content::ContextMenuParams& params) OVERRIDE; | 187 const content::ContextMenuParams& params) OVERRIDE; |
188 | 188 |
189 private: | 189 private: |
190 friend class ::CloudPrintWebDialogDelegateTest; | 190 friend class ::CloudPrintWebDialogDelegateTest; |
191 | 191 |
192 // For unit testing. | 192 // For unit testing. |
193 CloudPrintWebDialogDelegate(CloudPrintFlowHandler* flow_handler, | 193 CloudPrintWebDialogDelegate(const FilePath& path_to_file, |
194 int width, int height, | 194 CloudPrintFlowHandler* flow_handler, |
195 const std::string& json_arguments, | 195 const std::string& json_arguments, |
196 bool modal, | |
197 bool delete_on_close); | 196 bool delete_on_close); |
198 void Init(int width, int height, const std::string& json_arguments); | 197 void Init(content::BrowserContext* browser_context, |
| 198 const std::string& json_arguments); |
199 | 199 |
200 bool delete_on_close_; | 200 bool delete_on_close_; |
201 CloudPrintFlowHandler* flow_handler_; | 201 CloudPrintFlowHandler* flow_handler_; |
202 bool modal_; | 202 gfx::NativeWindow modal_parent_; |
203 mutable bool owns_flow_handler_; | 203 mutable bool owns_flow_handler_; |
204 FilePath path_to_file_; | 204 FilePath path_to_file_; |
| 205 bool keep_alive_when_non_modal_; |
205 | 206 |
206 // The parameters needed to display a modal web dialog. | 207 // The parameters needed to display a modal web dialog. |
207 WebDialogUI::WebDialogParams params_; | 208 WebDialogUI::WebDialogParams params_; |
208 | 209 |
209 DISALLOW_COPY_AND_ASSIGN(CloudPrintWebDialogDelegate); | 210 DISALLOW_COPY_AND_ASSIGN(CloudPrintWebDialogDelegate); |
210 }; | 211 }; |
211 | 212 |
212 void CreateDialogFullImpl(const FilePath& path_to_file, | 213 void CreateDialogFullImpl(content::BrowserContext* browser_context, |
| 214 gfx::NativeWindow modal_parent, |
| 215 const FilePath& path_to_file, |
213 const string16& print_job_title, | 216 const string16& print_job_title, |
214 const string16& print_ticket, | 217 const string16& print_ticket, |
215 const std::string& file_type, | 218 const std::string& file_type, |
216 bool modal, | |
217 bool delete_on_close); | 219 bool delete_on_close); |
218 void CreateDialogSigninImpl(const base::Closure& callback); | 220 void CreateDialogSigninImpl(content::BrowserContext* browser_context, |
| 221 gfx::NativeWindow modal_parent, |
| 222 const base::Closure& callback); |
219 | 223 |
220 void Delete(const FilePath& path_to_file); | 224 void Delete(const FilePath& path_to_file); |
221 | 225 |
222 } // namespace internal_cloud_print_helpers | 226 } // namespace internal_cloud_print_helpers |
223 | 227 |
224 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_ | 228 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_ |
OLD | NEW |