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

Side by Side Diff: chrome/browser/remoting/setup_flow.h

Issue 5985003: New remoting setup flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years 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 | Annotate | Revision Log
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_REMOTING_SETUP_FLOW_H_
6 #define CHROME_BROWSER_REMOTING_SETUP_FLOW_H_
7
8 #include "base/callback.h"
9 #include "base/scoped_ptr.h"
10 #include "chrome/browser/dom_ui/html_dialog_ui.h"
11
12 class ListValue;
13
14 namespace remoting {
15
16 class SetupFlow;
17
18 // SetupFlowStep represents a single step for SetupFlow, e.g. login or
19 // host registration. When a step is finished, GetNextStep() is called
20 // to get the step that must follow.
21 class SetupFlowStep {
22 public:
23 typedef Callback0::Type DoneCallback;
24
25 SetupFlowStep();
26 virtual ~SetupFlowStep();
27
28 // Start the step. Ownership of |done_callback| is given to the
29 // function. |done_callback| must be called on the same thread on
30 // which Start() is called.
31 virtual void Start(SetupFlow* flow, DoneCallback* done_callback) = 0;
Alpha Left Google 2010/12/21 21:52:04 When is done_callback called?
Sergey Ulanov 2010/12/21 22:26:49 Done.
32
33 // Called to handle |message| received from UI.
34 virtual void HandleMessage(const std::string& message,
35 const ListValue* args) = 0;
36
37 // Called if user closes the dialog.
38 virtual void Cancel() = 0;
39
40 // Returns SetupFlowStep object that corresponds to the next
41 // step. Must never return NULL.
42 virtual SetupFlowStep* GetNextStep() = 0;
43
44 private:
45 DISALLOW_COPY_AND_ASSIGN(SetupFlowStep);
46 };
47
48 // SetupFlowStepBase implements base functions common for all
49 // SetupFlowStep implementations.
50 class SetupFlowStepBase : public SetupFlowStep {
51 public:
52 SetupFlowStepBase();
53 ~SetupFlowStepBase();
54
55 // SetupFlowStep implementation.
56 virtual void Start(SetupFlow* flow, DoneCallback* done_callback);
57 virtual SetupFlowStep* GetNextStep();
58
59 protected:
60 SetupFlow* flow() { return flow_; }
61
62 void ExecuteJavascriptInIFrame(const std::wstring& iframe_xpath,
63 const std::wstring& js);
64
65 void Done(SetupFlowStep* next_step);
Alpha Left Google 2010/12/21 21:52:04 Need comments for this method. Is this transiting
Sergey Ulanov 2010/12/21 22:26:49 Done.
66
67 // Called from Start(). Child classes must override this method
68 // instead of Start().
69 virtual void DoStart() = 0;
70
71 private:
72 SetupFlow* flow_;
73 scoped_ptr<DoneCallback> done_callback_;
74 bool done_;
75
76 // Next step stored between Done() and GetNextStep();
77 SetupFlowStep* next_step_;
78 };
Alpha Left Google 2010/12/21 21:52:04 disallow_copy_and_assign
Sergey Ulanov 2010/12/21 22:26:49 Done.
79
80 // The last step in the setup flow. This step never finishes, user is
81 // expected to close dialog after that.
82 class SetupFlowDoneStep : public SetupFlowStepBase {
83 public:
84 SetupFlowDoneStep();
85 virtual ~SetupFlowDoneStep();
86
87 // SetupFlowStep implementation.
88 virtual void HandleMessage(const std::string& message, const ListValue* args);
89 virtual void Cancel();
90
91 protected:
92 void DoStart();
93 };
Alpha Left Google 2010/12/21 21:52:04 disallow_copy_and_assign
Sergey Ulanov 2010/12/21 22:26:49 Done.
94
95 // This class is responsible for showing a remoting setup dialog and
96 // perform operations to fill the content of the dialog and handle
97 // user actions in the dialog.
98 class SetupFlow : public DOMMessageHandler,
99 public HtmlDialogUIDelegate {
100 public:
101 virtual ~SetupFlow();
102
103 static SetupFlow* OpenSetupDialog(Profile* profile);
104
105 DOMUI* dom_ui() { return dom_ui_; }
106 Profile* profile() { return profile_; }
107
108 private:
109 explicit SetupFlow(const std::string& args, Profile* profile,
110 SetupFlowStep* first_step);
111
112 // HtmlDialogUIDelegate implementation.
113 virtual GURL GetDialogContentURL() const;
114 virtual void GetDOMMessageHandlers(
115 std::vector<DOMMessageHandler*>* handlers) const;
116 virtual void GetDialogSize(gfx::Size* size) const;
117 virtual std::string GetDialogArgs() const;
118 virtual void OnDialogClosed(const std::string& json_retval);
119 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog);
120 virtual std::wstring GetDialogTitle() const;
121 virtual bool IsDialogModal() const;
122 virtual bool ShouldShowDialogTitle() const;
123
124 // DOMMessageHandler implementation.
125 virtual DOMMessageHandler* Attach(DOMUI* dom_ui);
126 virtual void RegisterMessages();
Alpha Left Google 2010/12/21 21:52:04 Is it better to have SetupFlowStep implements DOMM
Sergey Ulanov 2010/12/21 22:26:49 This is not possible because we don't have list of
127
128 void HandleSubmitAuth(const ListValue* args);
129
130 void StartCurrentStep();
131 void OnStepDone();
132
133 // Pointer to the DOM UI. This is provided by RemotingSetupMessageHandler
134 // when attached.
135 DOMUI* dom_ui_;
136
137 // The args to pass to the initial page.
138 std::string dialog_start_args_;
139 Profile* profile_;
140
141 scoped_ptr<SetupFlowStep> current_step_;
142
143 DISALLOW_COPY_AND_ASSIGN(SetupFlow);
144 };
145
146 }
Alpha Left Google 2010/12/21 21:52:04 namespace
Sergey Ulanov 2010/12/21 22:26:49 Done.
147
148 #endif // CHROME_BROWSER_REMOTING_SETUP_FLOW_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/remoting/setup_flow.cc » ('j') | chrome/browser/remoting/setup_flow.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698