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