| 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_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 int http_code) override; | 98 int http_code) override; |
| 99 #endif | 99 #endif |
| 100 | 100 |
| 101 int regenerate_preview_request_count() const { | 101 int regenerate_preview_request_count() const { |
| 102 return regenerate_preview_request_count_; | 102 return regenerate_preview_request_count_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 // Sets |pdf_file_saved_closure_| to |closure|. | 105 // Sets |pdf_file_saved_closure_| to |closure|. |
| 106 void SetPdfSavedClosureForTesting(const base::Closure& closure); | 106 void SetPdfSavedClosureForTesting(const base::Closure& closure); |
| 107 | 107 |
| 108 protected: |
| 109 // If |prompt_user| is true, displays a modal dialog, prompting the user to |
| 110 // select a file. Otherwise, just accept |default_path| and uniquify it. |
| 111 // Protected so unit tests can access. |
| 112 virtual void SelectFile(const base::FilePath& default_path, bool prompt_user); |
| 113 |
| 114 // Handles printing to PDF. Protected to expose to unit tests. |
| 115 void PrintToPdf(); |
| 116 |
| 117 // The underlying dialog object. Protected to expose to unit tests. |
| 118 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; |
| 119 |
| 108 private: | 120 private: |
| 109 friend class PrintPreviewPdfGeneratedBrowserTest; | 121 friend class PrintPreviewPdfGeneratedBrowserTest; |
| 110 FRIEND_TEST_ALL_PREFIXES(PrintPreviewPdfGeneratedBrowserTest, | 122 FRIEND_TEST_ALL_PREFIXES(PrintPreviewPdfGeneratedBrowserTest, |
| 111 MANUAL_DummyTest); | 123 MANUAL_DummyTest); |
| 112 class AccessTokenService; | 124 class AccessTokenService; |
| 113 | 125 |
| 114 content::WebContents* preview_web_contents() const; | 126 content::WebContents* preview_web_contents() const; |
| 115 | 127 |
| 116 PrintPreviewUI* print_preview_ui() const; | 128 PrintPreviewUI* print_preview_ui() const; |
| 117 | 129 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 242 |
| 231 // Send the list of printers to the Web UI. | 243 // Send the list of printers to the Web UI. |
| 232 void SetupPrinterList(const printing::PrinterList& printer_list); | 244 void SetupPrinterList(const printing::PrinterList& printer_list); |
| 233 | 245 |
| 234 // Send whether cloud print integration should be enabled. | 246 // Send whether cloud print integration should be enabled. |
| 235 void SendCloudPrintEnabled(); | 247 void SendCloudPrintEnabled(); |
| 236 | 248 |
| 237 // Send the PDF data to the cloud to print. | 249 // Send the PDF data to the cloud to print. |
| 238 void SendCloudPrintJob(const base::RefCountedBytes* data); | 250 void SendCloudPrintJob(const base::RefCountedBytes* data); |
| 239 | 251 |
| 240 // Handles printing to PDF. | |
| 241 void PrintToPdf(); | |
| 242 | |
| 243 // Gets the initiator for the print preview dialog. | 252 // Gets the initiator for the print preview dialog. |
| 244 content::WebContents* GetInitiator() const; | 253 content::WebContents* GetInitiator() const; |
| 245 | 254 |
| 246 // Closes the preview dialog. | 255 // Closes the preview dialog. |
| 247 void ClosePreviewDialog(); | 256 void ClosePreviewDialog(); |
| 248 | 257 |
| 249 // Adds all the recorded stats taken so far to histogram counts. | 258 // Adds all the recorded stats taken so far to histogram counts. |
| 250 void ReportStats(); | 259 void ReportStats(); |
| 251 | 260 |
| 252 // Clears initiator details for the print preview dialog. | 261 // Clears initiator details for the print preview dialog. |
| 253 void ClearInitiatorDetails(); | 262 void ClearInitiatorDetails(); |
| 254 | 263 |
| 255 // Posts a task to save |data| to pdf at |print_to_pdf_path_|. | 264 // Posts a task to save |data| to pdf at |print_to_pdf_path_|. |
| 256 void PostPrintToPdfTask(); | 265 void PostPrintToPdfTask(); |
| 257 | 266 |
| 258 // Populates |settings| according to the current locale. | 267 // Populates |settings| according to the current locale. |
| 259 void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings); | 268 void GetNumberFormatAndMeasurementSystem(base::DictionaryValue* settings); |
| 260 | 269 |
| 261 bool GetPreviewDataAndTitle(scoped_refptr<base::RefCountedBytes>* data, | 270 bool GetPreviewDataAndTitle(scoped_refptr<base::RefCountedBytes>* data, |
| 262 base::string16* title) const; | 271 base::string16* title) const; |
| 263 | 272 |
| 264 // If |prompt_user| is true, displays a modal dialog, prompting the user to | |
| 265 // select a file. Otherwise, just accept |default_path| and uniquify it. | |
| 266 void SelectFile(const base::FilePath& default_path, bool prompt_user); | |
| 267 | |
| 268 // Helper for getting a unique file name for SelectFile() without prompting | 273 // Helper for getting a unique file name for SelectFile() without prompting |
| 269 // the user. Just an adaptor for FileSelected(). | 274 // the user. Just an adaptor for FileSelected(). |
| 270 void OnGotUniqueFileName(const base::FilePath& path); | 275 void OnGotUniqueFileName(const base::FilePath& path); |
| 271 | 276 |
| 272 #if defined(USE_CUPS) | 277 #if defined(USE_CUPS) |
| 273 void SaveCUPSColorSetting(const base::DictionaryValue* settings); | 278 void SaveCUPSColorSetting(const base::DictionaryValue* settings); |
| 274 | 279 |
| 275 void ConvertColorSettingToCUPSColorModel( | 280 void ConvertColorSettingToCUPSColorModel( |
| 276 base::DictionaryValue* settings) const; | 281 base::DictionaryValue* settings) const; |
| 277 #endif | 282 #endif |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 // |success|: Whether the job succeeded. | 342 // |success|: Whether the job succeeded. |
| 338 // |status|: The returned print job status. Useful for reporting a specific | 343 // |status|: The returned print job status. Useful for reporting a specific |
| 339 // error. | 344 // error. |
| 340 void OnExtensionPrintResult(bool success, const std::string& status); | 345 void OnExtensionPrintResult(bool success, const std::string& status); |
| 341 | 346 |
| 342 // Register/unregister from notifications of changes done to the GAIA | 347 // Register/unregister from notifications of changes done to the GAIA |
| 343 // cookie. | 348 // cookie. |
| 344 void RegisterForGaiaCookieChanges(); | 349 void RegisterForGaiaCookieChanges(); |
| 345 void UnregisterForGaiaCookieChanges(); | 350 void UnregisterForGaiaCookieChanges(); |
| 346 | 351 |
| 347 // The underlying dialog object. | |
| 348 scoped_refptr<ui::SelectFileDialog> select_file_dialog_; | |
| 349 | |
| 350 // A count of how many requests received to regenerate preview data. | 352 // A count of how many requests received to regenerate preview data. |
| 351 // Initialized to 0 then incremented and emitted to a histogram. | 353 // Initialized to 0 then incremented and emitted to a histogram. |
| 352 int regenerate_preview_request_count_; | 354 int regenerate_preview_request_count_; |
| 353 | 355 |
| 354 // A count of how many requests received to show manage printers dialog. | 356 // A count of how many requests received to show manage printers dialog. |
| 355 int manage_printers_dialog_request_count_; | 357 int manage_printers_dialog_request_count_; |
| 356 int manage_cloud_printers_dialog_request_count_; | 358 int manage_cloud_printers_dialog_request_count_; |
| 357 | 359 |
| 358 // Whether we have already logged a failed print preview. | 360 // Whether we have already logged a failed print preview. |
| 359 bool reported_failed_preview_; | 361 bool reported_failed_preview_; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 // Proxy for calls to the print backend. Lazily initialized since web_ui() is | 400 // Proxy for calls to the print backend. Lazily initialized since web_ui() is |
| 399 // not available at construction time. | 401 // not available at construction time. |
| 400 std::unique_ptr<printing::PrinterBackendProxy> printer_backend_proxy_; | 402 std::unique_ptr<printing::PrinterBackendProxy> printer_backend_proxy_; |
| 401 | 403 |
| 402 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; | 404 base::WeakPtrFactory<PrintPreviewHandler> weak_factory_; |
| 403 | 405 |
| 404 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 406 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
| 405 }; | 407 }; |
| 406 | 408 |
| 407 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ | 409 #endif // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_PRINT_PREVIEW_HANDLER_H_ |
| OLD | NEW |