| 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_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/time.h" | 11 #include "base/time.h" |
| 12 #include "base/weak_ptr.h" |
| 12 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 13 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
| 13 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
| 14 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" | 15 #include "chrome/common/net/gaia/gaia_auth_fetcher.h" |
| 15 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 18 #include "ui/gfx/native_widget_types.h" |
| 18 | 19 |
| 19 class GaiaAuthFetcher; | 20 class GaiaAuthFetcher; |
| 20 class CloudPrintServiceProcessHelper; | 21 class CloudPrintServiceProcessHelper; |
| 21 class CloudPrintSetupMessageHandler; | 22 class CloudPrintSetupMessageHandler; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 46 public: | 47 public: |
| 47 virtual ~Delegate() {} | 48 virtual ~Delegate() {} |
| 48 // Called when the setup dialog is closed. | 49 // Called when the setup dialog is closed. |
| 49 virtual void OnDialogClosed() = 0; | 50 virtual void OnDialogClosed() = 0; |
| 50 }; | 51 }; |
| 51 virtual ~CloudPrintSetupFlow(); | 52 virtual ~CloudPrintSetupFlow(); |
| 52 | 53 |
| 53 // Runs a flow from |start| to |end|, and does the work of actually showing | 54 // Runs a flow from |start| to |end|, and does the work of actually showing |
| 54 // the HTML dialog. |container| is kept up-to-date with the lifetime of the | 55 // the HTML dialog. |container| is kept up-to-date with the lifetime of the |
| 55 // flow (e.g it is emptied on dialog close). | 56 // flow (e.g it is emptied on dialog close). |
| 56 static CloudPrintSetupFlow* OpenDialog(Profile* service, Delegate* delegate, | 57 static CloudPrintSetupFlow* OpenDialog( |
| 57 gfx::NativeWindow parent_window); | 58 Profile* service, |
| 59 const base::WeakPtr<Delegate>& delegate, |
| 60 gfx::NativeWindow parent_window); |
| 58 | 61 |
| 59 // Focuses the dialog. This is useful in cases where the dialog has been | 62 // Focuses the dialog. This is useful in cases where the dialog has been |
| 60 // obscured by a browser window. | 63 // obscured by a browser window. |
| 61 void Focus(); | 64 void Focus(); |
| 62 | 65 |
| 63 // HtmlDialogUIDelegate implementation. | 66 // HtmlDialogUIDelegate implementation. |
| 64 virtual GURL GetDialogContentURL() const; | 67 virtual GURL GetDialogContentURL() const; |
| 65 virtual void GetWebUIMessageHandlers( | 68 virtual void GetWebUIMessageHandlers( |
| 66 std::vector<WebUIMessageHandler*>* handlers) const; | 69 std::vector<WebUIMessageHandler*>* handlers) const; |
| 67 virtual void GetDialogSize(gfx::Size* size) const; | 70 virtual void GetDialogSize(gfx::Size* size) const; |
| 68 virtual std::string GetDialogArgs() const; | 71 virtual std::string GetDialogArgs() const; |
| 69 virtual void OnDialogClosed(const std::string& json_retval); | 72 virtual void OnDialogClosed(const std::string& json_retval); |
| 70 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); | 73 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog); |
| 71 virtual std::wstring GetDialogTitle() const; | 74 virtual std::wstring GetDialogTitle() const; |
| 72 virtual bool IsDialogModal() const; | 75 virtual bool IsDialogModal() const; |
| 73 virtual bool ShouldShowDialogTitle() const; | 76 virtual bool ShouldShowDialogTitle() const; |
| 74 | 77 |
| 75 // GaiaAuthConsumer implementation. | 78 // GaiaAuthConsumer implementation. |
| 76 virtual void OnClientLoginFailure( | 79 virtual void OnClientLoginFailure( |
| 77 const GoogleServiceAuthError& error); | 80 const GoogleServiceAuthError& error); |
| 78 virtual void OnClientLoginSuccess( | 81 virtual void OnClientLoginSuccess( |
| 79 const GaiaAuthConsumer::ClientLoginResult& credentials); | 82 const GaiaAuthConsumer::ClientLoginResult& credentials); |
| 80 | 83 |
| 81 private: | 84 private: |
| 82 friend class CloudPrintServiceProcessHelper; | 85 friend class CloudPrintServiceProcessHelper; |
| 83 friend class CloudPrintSetupMessageHandler; | 86 friend class CloudPrintSetupMessageHandler; |
| 84 | 87 |
| 85 // Use static Run method to get an instance. | 88 // Use static Run method to get an instance. |
| 86 CloudPrintSetupFlow(const std::string& args, Profile* profile, | 89 CloudPrintSetupFlow(const std::string& args, Profile* profile, |
| 87 Delegate* delegate, bool setup_done); | 90 const base::WeakPtr<Delegate>& delegate, bool setup_done); |
| 88 | 91 |
| 89 // Called CloudPrintSetupMessageHandler when a DOM is attached. This method | 92 // Called CloudPrintSetupMessageHandler when a DOM is attached. This method |
| 90 // is called when the HTML page is fully loaded. We then operate on this | 93 // is called when the HTML page is fully loaded. We then operate on this |
| 91 // WebUI object directly. | 94 // WebUI object directly. |
| 92 void Attach(WebUI* web_ui); | 95 void Attach(WebUI* web_ui); |
| 93 | 96 |
| 94 // Called by CloudPrintSetupMessageHandler when user authentication is | 97 // Called by CloudPrintSetupMessageHandler when user authentication is |
| 95 // registered. | 98 // registered. |
| 96 void OnUserSubmittedAuth(const std::string& user, | 99 void OnUserSubmittedAuth(const std::string& user, |
| 97 const std::string& password, | 100 const std::string& password, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 121 // Fetcher to obtain the Chromoting Directory token. | 124 // Fetcher to obtain the Chromoting Directory token. |
| 122 scoped_ptr<GaiaAuthFetcher> authenticator_; | 125 scoped_ptr<GaiaAuthFetcher> authenticator_; |
| 123 std::string login_; | 126 std::string login_; |
| 124 std::string lsid_; | 127 std::string lsid_; |
| 125 | 128 |
| 126 // Are we in the done state? | 129 // Are we in the done state? |
| 127 bool setup_done_; | 130 bool setup_done_; |
| 128 | 131 |
| 129 // Handle to the ServiceProcessControl which talks to the service process. | 132 // Handle to the ServiceProcessControl which talks to the service process. |
| 130 ServiceProcessControl* process_control_; | 133 ServiceProcessControl* process_control_; |
| 131 Delegate* delegate_; | 134 base::WeakPtr<Delegate> delegate_; |
| 132 | 135 |
| 133 DISALLOW_COPY_AND_ASSIGN(CloudPrintSetupFlow); | 136 DISALLOW_COPY_AND_ASSIGN(CloudPrintSetupFlow); |
| 134 }; | 137 }; |
| 135 | 138 |
| 136 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_ | 139 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_ |
| OLD | NEW |