Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(557)

Side by Side Diff: chrome/browser/printing/cloud_print/cloud_print_setup_flow.h

Issue 3450021: Cloud print proxy management UI. (Closed)
Patch Set: Fix nits. Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_
6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "app/l10n_util.h"
12 #include "base/time.h"
13 #include "chrome/browser/dom_ui/html_dialog_ui.h"
14 #include "chrome/common/net/gaia/gaia_auth_consumer.h"
15 #include "chrome/common/net/gaia/gaia_authenticator2.h"
16 #include "gfx/native_widget_types.h"
17 #include "grit/generated_resources.h"
18
19 class GaiaAuthenticator2;
20 class CloudPrintServiceProcessHelper;
21 class CloudPrintSetupMessageHandler;
22 class ServiceProcessControl;
23 class GoogleServiceAuthError;
24 class Browser;
25
26 // This class is responsible for showing a cloud print setup dialog
27 // and perform operations to fill the content of the dialog and handle
28 // user actions in the dialog.
29 //
30 // It is responsible for:
31 // 1. Showing the setup dialog.
32 // 2. Providing the URL for the content of the dialog.
33 // 3. Providing a data source to provide the content HTML files.
34 // 4. Providing a message handler to handle user actions in the DOM UI.
35 // 5. Responding to actions received in the message handler.
36 //
37 // The architecture for DOMUI is designed such that only the message handler
38 // can access the DOMUI. This splits the flow control across the message
39 // handler and this class. In order to centralize all the flow control and
40 // content in the DOMUI, the DOMUI object is given to this object by the
41 // message handler through the Attach(DOMUI*) method.
42 class CloudPrintSetupFlow : public HtmlDialogUIDelegate,
43 public GaiaAuthConsumer {
44 public:
45 virtual ~CloudPrintSetupFlow();
46
47 // Runs a flow from |start| to |end|, and does the work of actually showing
48 // the HTML dialog. |container| is kept up-to-date with the lifetime of the
49 // flow (e.g it is emptied on dialog close).
50 static CloudPrintSetupFlow* OpenDialog(Profile* service);
51
52 // Disables the cloud print proxy if it's enabled and running.
53 static void DisableCloudPrintProxy(Profile* profile);
54
55 // Ping the cloud print proxy service in order to get the true
56 // enablement state and user e-mail that the service is using, and
57 // reflect those back into the browser preferences.
58 static void RefreshPreferencesFromService(
59 Profile* profile, Callback2<bool, std::string>::Type* callback);
60
61 // Focuses the dialog. This is useful in cases where the dialog has been
62 // obscured by a browser window.
63 void Focus();
64
65 // HtmlDialogUIDelegate implementation.
66 virtual GURL GetDialogContentURL() const;
67 virtual void GetDOMMessageHandlers(
68 std::vector<DOMMessageHandler*>* handlers) const;
69 virtual void GetDialogSize(gfx::Size* size) const;
70 virtual std::string GetDialogArgs() const;
71 virtual void OnDialogClosed(const std::string& json_retval);
72 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog);
73 virtual std::wstring GetDialogTitle() const;
74 virtual bool IsDialogModal() const;
75
76 // GaiaAuthConsumer implementation.
77 virtual void OnClientLoginFailure(
78 const GoogleServiceAuthError& error);
79 virtual void OnClientLoginSuccess(
80 const GaiaAuthConsumer::ClientLoginResult& credentials);
81
82 private:
83 friend class CloudPrintServiceProcessHelper;
84 friend class CloudPrintSetupMessageHandler;
85
86 // Use static Run method to get an instance. This class takes
87 // ownership of browser and is responsible for it's destruction.
88 CloudPrintSetupFlow(const std::string& args, Browser* browser);
89
90 // Called CloudPrintSetupMessageHandler when a DOM is attached. This method
91 // is called when the HTML page is fully loaded. We then operate on this
92 // DOMUI object directly.
93 void Attach(DOMUI* dom_ui);
94
95 // Called by CloudPrintSetupMessageHandler when user authentication is
96 // registered.
97 void OnUserSubmittedAuth(const std::string& user,
98 const std::string& password,
99 const std::string& captcha);
100
101 // Event triggered when the service process was launched.
102 void OnProcessLaunched();
103
104 // The following methods control which iframe is visible.
105 void ShowGaiaLogin(const DictionaryValue& args);
106 void ShowGaiaSuccessAndSettingUp();
107 void ShowGaiaFailed(const GoogleServiceAuthError& error);
108 void ShowSetupDone();
109 void ExecuteJavascriptInIFrame(const std::wstring& iframe_xpath,
110 const std::wstring& js);
111
112 // Pointer to the DOM UI. This is provided by CloudPrintSetupMessageHandler
113 // when attached.
114 DOMUI* dom_ui_;
115
116 // The args to pass to the initial page.
117 std::string dialog_start_args_;
118 scoped_ptr<Browser> browser_;
119
120 // Fetcher to obtain the Chromoting Directory token.
121 scoped_ptr<GaiaAuthenticator2> authenticator_;
122 std::string login_;
123 std::string lsid_;
124
125 // Handle to the ServiceProcessControl which talks to the service process.
126 ServiceProcessControl* process_control_;
127 scoped_refptr<CloudPrintServiceProcessHelper> service_process_helper_;
128
129 DISALLOW_COPY_AND_ASSIGN(CloudPrintSetupFlow);
130 };
131
132 #endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_FLOW_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser.cc ('k') | chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698