| OLD | NEW |
| 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_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/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
| 15 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 15 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 16 #include "content/browser/webui/web_ui.h" | 16 #include "content/browser/webui/web_ui.h" |
| 17 #include "content/common/notification_observer.h" | 17 #include "content/common/notification_observer.h" |
| 18 #include "content/common/notification_registrar.h" | 18 #include "content/common/notification_registrar.h" |
| 19 | 19 |
| 20 class GURL; | 20 class GURL; |
| 21 class CloudPrintHtmlDialogDelegateTest; |
| 22 |
| 23 namespace base { |
| 24 class ListValue; |
| 21 class StringValue; | 25 class StringValue; |
| 22 class CloudPrintHtmlDialogDelegateTest; | 26 class Value; |
| 27 } |
| 23 | 28 |
| 24 namespace internal_cloud_print_helpers { | 29 namespace internal_cloud_print_helpers { |
| 25 | 30 |
| 26 // Small class to virtualize a few functions to aid with unit testing. | 31 // Small class to virtualize a few functions to aid with unit testing. |
| 27 class CloudPrintDataSenderHelper { | 32 class CloudPrintDataSenderHelper { |
| 28 public: | 33 public: |
| 29 explicit CloudPrintDataSenderHelper(WebUI* web_ui) : web_ui_(web_ui) {} | 34 explicit CloudPrintDataSenderHelper(WebUI* web_ui) : web_ui_(web_ui) {} |
| 30 virtual ~CloudPrintDataSenderHelper() {} | 35 virtual ~CloudPrintDataSenderHelper() {} |
| 31 | 36 |
| 32 // Virtualize the overrides of these three functions from WebUI to | 37 // Virtualize the overrides of these three functions from WebUI to |
| 33 // facilitate unit testing. | 38 // facilitate unit testing. |
| 34 virtual void CallJavascriptFunction(const std::wstring& function_name); | 39 virtual void CallJavascriptFunction(const std::wstring& function_name); |
| 35 virtual void CallJavascriptFunction(const std::wstring& function_name, | 40 virtual void CallJavascriptFunction(const std::wstring& function_name, |
| 36 const Value& arg); | 41 const base::Value& arg); |
| 37 virtual void CallJavascriptFunction(const std::wstring& function_name, | 42 virtual void CallJavascriptFunction(const std::wstring& function_name, |
| 38 const Value& arg1, | 43 const base::Value& arg1, |
| 39 const Value& arg2); | 44 const base::Value& arg2); |
| 40 | 45 |
| 41 private: | 46 private: |
| 42 WebUI* web_ui_; | 47 WebUI* web_ui_; |
| 43 | 48 |
| 44 DISALLOW_COPY_AND_ASSIGN(CloudPrintDataSenderHelper); | 49 DISALLOW_COPY_AND_ASSIGN(CloudPrintDataSenderHelper); |
| 45 }; | 50 }; |
| 46 | 51 |
| 47 // Small helper class to get the print data loaded in from the PDF | 52 // Small helper class to get the print data loaded in from the PDF |
| 48 // file (on the FILE thread) and send it to the print dialog contents | 53 // file (on the FILE thread) and send it to the print dialog contents |
| 49 // (on the IO thread), allowing for cancellation. | 54 // (on the IO thread), allowing for cancellation. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 66 // Cancels any ramining part of the task by clearing out the WebUI | 71 // Cancels any ramining part of the task by clearing out the WebUI |
| 67 // helper_ ptr. | 72 // helper_ ptr. |
| 68 void CancelPrintDataFile(); | 73 void CancelPrintDataFile(); |
| 69 | 74 |
| 70 private: | 75 private: |
| 71 friend class base::RefCountedThreadSafe<CloudPrintDataSender>; | 76 friend class base::RefCountedThreadSafe<CloudPrintDataSender>; |
| 72 virtual ~CloudPrintDataSender(); | 77 virtual ~CloudPrintDataSender(); |
| 73 | 78 |
| 74 base::Lock lock_; | 79 base::Lock lock_; |
| 75 CloudPrintDataSenderHelper* volatile helper_; | 80 CloudPrintDataSenderHelper* volatile helper_; |
| 76 scoped_ptr<StringValue> print_data_; | 81 scoped_ptr<base::StringValue> print_data_; |
| 77 string16 print_job_title_; | 82 string16 print_job_title_; |
| 78 std::string file_type_; | 83 std::string file_type_; |
| 79 | 84 |
| 80 DISALLOW_COPY_AND_ASSIGN(CloudPrintDataSender); | 85 DISALLOW_COPY_AND_ASSIGN(CloudPrintDataSender); |
| 81 }; | 86 }; |
| 82 | 87 |
| 83 class CloudPrintHtmlDialogDelegate; | 88 class CloudPrintHtmlDialogDelegate; |
| 84 | 89 |
| 85 // The CloudPrintFlowHandler connects the state machine (the UI delegate) | 90 // The CloudPrintFlowHandler connects the state machine (the UI delegate) |
| 86 // to the dialog backing HTML and JS by providing WebUIMessageHandler | 91 // to the dialog backing HTML and JS by providing WebUIMessageHandler |
| (...skipping 12 matching lines...) Expand all Loading... |
| 99 | 104 |
| 100 // WebUIMessageHandler implementation. | 105 // WebUIMessageHandler implementation. |
| 101 virtual void RegisterMessages(); | 106 virtual void RegisterMessages(); |
| 102 | 107 |
| 103 // NotificationObserver implementation. | 108 // NotificationObserver implementation. |
| 104 virtual void Observe(int type, | 109 virtual void Observe(int type, |
| 105 const NotificationSource& source, | 110 const NotificationSource& source, |
| 106 const NotificationDetails& details); | 111 const NotificationDetails& details); |
| 107 | 112 |
| 108 // Callbacks from the page. | 113 // Callbacks from the page. |
| 109 void HandleShowDebugger(const ListValue* args); | 114 void HandleShowDebugger(const base::ListValue* args); |
| 110 void HandleSendPrintData(const ListValue* args); | 115 void HandleSendPrintData(const base::ListValue* args); |
| 111 void HandleSetPageParameters(const ListValue* args); | 116 void HandleSetPageParameters(const base::ListValue* args); |
| 112 | 117 |
| 113 virtual void SetDialogDelegate(CloudPrintHtmlDialogDelegate *delegate); | 118 virtual void SetDialogDelegate(CloudPrintHtmlDialogDelegate *delegate); |
| 114 void StoreDialogClientSize() const; | 119 void StoreDialogClientSize() const; |
| 115 | 120 |
| 116 private: | 121 private: |
| 117 virtual scoped_refptr<CloudPrintDataSender> CreateCloudPrintDataSender(); | 122 virtual scoped_refptr<CloudPrintDataSender> CreateCloudPrintDataSender(); |
| 118 | 123 |
| 119 // Call to get the debugger loaded on our hosted dialog page | 124 // Call to get the debugger loaded on our hosted dialog page |
| 120 // specifically. Since we're not in an official browser tab, only | 125 // specifically. Since we're not in an official browser tab, only |
| 121 // way to get the debugger going. | 126 // way to get the debugger going. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 void CreateDialogImpl(const FilePath& path_to_file, | 189 void CreateDialogImpl(const FilePath& path_to_file, |
| 185 const string16& print_job_title, | 190 const string16& print_job_title, |
| 186 const std::string& file_type, | 191 const std::string& file_type, |
| 187 bool modal); | 192 bool modal); |
| 188 | 193 |
| 189 void Delete(const FilePath& path_to_file); | 194 void Delete(const FilePath& path_to_file); |
| 190 | 195 |
| 191 } // namespace internal_cloud_print_helpers | 196 } // namespace internal_cloud_print_helpers |
| 192 | 197 |
| 193 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_ | 198 #endif // CHROME_BROWSER_PRINTING_PRINT_DIALOG_CLOUD_INTERNAL_H_ |
| OLD | NEW |