| 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_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_ |
| 6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_ | 6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/time.h" | 12 #include "base/time.h" |
| 13 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 13 #include "chrome/browser/ui/webui/web_dialog_ui.h" |
| 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
| 15 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 15 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 16 #include "chrome/common/net/gaia/google_service_auth_error.h" | 16 #include "chrome/common/net/gaia/google_service_auth_error.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
| 20 | 20 |
| 21 class CloudPrintServiceProcessHelper; | 21 class CloudPrintServiceProcessHelper; |
| 22 class CloudPrintSetupMessageHandler; | 22 class CloudPrintSetupMessageHandler; |
| 23 class GaiaAuthFetcher; | 23 class GaiaAuthFetcher; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 38 // 2. Providing the URL for the content of the dialog. | 38 // 2. Providing the URL for the content of the dialog. |
| 39 // 3. Providing a data source to provide the content HTML files. | 39 // 3. Providing a data source to provide the content HTML files. |
| 40 // 4. Providing a message handler to handle user actions in the Web UI. | 40 // 4. Providing a message handler to handle user actions in the Web UI. |
| 41 // 5. Responding to actions received in the message handler. | 41 // 5. Responding to actions received in the message handler. |
| 42 // | 42 // |
| 43 // The architecture for WebUI is designed such that only the message handler | 43 // The architecture for WebUI is designed such that only the message handler |
| 44 // can access the WebUI. This splits the flow control across the message | 44 // can access the WebUI. This splits the flow control across the message |
| 45 // handler and this class. In order to centralize all the flow control and | 45 // handler and this class. In order to centralize all the flow control and |
| 46 // content in the WebUI, the WebUI object is given to this object by the | 46 // content in the WebUI, the WebUI object is given to this object by the |
| 47 // message handler through the Attach(WebUI*) method. | 47 // message handler through the Attach(WebUI*) method. |
| 48 class CloudPrintSetupFlow : public HtmlDialogUIDelegate, | 48 class CloudPrintSetupFlow : public WebDialogDelegate, |
| 49 public GaiaAuthConsumer { | 49 public GaiaAuthConsumer { |
| 50 public: | 50 public: |
| 51 class Delegate { | 51 class Delegate { |
| 52 public: | 52 public: |
| 53 virtual ~Delegate() {} | 53 virtual ~Delegate() {} |
| 54 // Called when the setup dialog is closed. | 54 // Called when the setup dialog is closed. |
| 55 virtual void OnDialogClosed() = 0; | 55 virtual void OnDialogClosed() = 0; |
| 56 }; | 56 }; |
| 57 virtual ~CloudPrintSetupFlow(); | 57 virtual ~CloudPrintSetupFlow(); |
| 58 | 58 |
| 59 // Runs a flow from |start| to |end|, and does the work of actually showing | 59 // Runs a flow from |start| to |end|, and does the work of actually showing |
| 60 // the HTML dialog. |container| is kept up-to-date with the lifetime of the | 60 // the HTML dialog. |container| is kept up-to-date with the lifetime of the |
| 61 // flow (e.g it is emptied on dialog close). | 61 // flow (e.g it is emptied on dialog close). |
| 62 static CloudPrintSetupFlow* OpenDialog( | 62 static CloudPrintSetupFlow* OpenDialog( |
| 63 Profile* service, | 63 Profile* service, |
| 64 const base::WeakPtr<Delegate>& delegate, | 64 const base::WeakPtr<Delegate>& delegate, |
| 65 gfx::NativeWindow parent_window); | 65 gfx::NativeWindow parent_window); |
| 66 | 66 |
| 67 // Focuses the dialog. This is useful in cases where the dialog has been | 67 // Focuses the dialog. This is useful in cases where the dialog has been |
| 68 // obscured by a browser window. | 68 // obscured by a browser window. |
| 69 void Focus(); | 69 void Focus(); |
| 70 | 70 |
| 71 // HtmlDialogUIDelegate implementation. | 71 // WebDialogDelegate implementation. |
| 72 virtual GURL GetDialogContentURL() const OVERRIDE; | 72 virtual GURL GetDialogContentURL() const OVERRIDE; |
| 73 virtual void GetWebUIMessageHandlers( | 73 virtual void GetWebUIMessageHandlers( |
| 74 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; | 74 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE; |
| 75 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 75 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
| 76 virtual std::string GetDialogArgs() const OVERRIDE; | 76 virtual std::string GetDialogArgs() const OVERRIDE; |
| 77 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 77 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
| 78 virtual void OnCloseContents(content::WebContents* source, | 78 virtual void OnCloseContents(content::WebContents* source, |
| 79 bool* out_close_dialog) OVERRIDE; | 79 bool* out_close_dialog) OVERRIDE; |
| 80 virtual string16 GetDialogTitle() const OVERRIDE; | 80 virtual string16 GetDialogTitle() const OVERRIDE; |
| 81 virtual ui::ModalType GetDialogModalType() const OVERRIDE; | 81 virtual ui::ModalType GetDialogModalType() const OVERRIDE; |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 bool setup_done_; | 143 bool setup_done_; |
| 144 | 144 |
| 145 // Handle to the ServiceProcessControl which talks to the service process. | 145 // Handle to the ServiceProcessControl which talks to the service process. |
| 146 ServiceProcessControl* process_control_; | 146 ServiceProcessControl* process_control_; |
| 147 base::WeakPtr<Delegate> delegate_; | 147 base::WeakPtr<Delegate> delegate_; |
| 148 | 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(CloudPrintSetupFlow); | 149 DISALLOW_COPY_AND_ASSIGN(CloudPrintSetupFlow); |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_ | 152 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_ |
| OLD | NEW |