summaryrefslogtreecommitdiffstats
path: root/chrome/browser/remoting/setup_flow.h
blob: dd33c551fb2cb539b3edf4b0432783ab603826a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_REMOTING_SETUP_FLOW_H_
#define CHROME_BROWSER_REMOTING_SETUP_FLOW_H_

#include <string>
#include <vector>

#include "app/l10n_util.h"
#include "base/time.h"
#include "chrome/browser/dom_ui/html_dialog_ui.h"
#include "gfx/native_widget_types.h"
#include "grit/generated_resources.h"

namespace remoting_setup {

// The state machine used by Remoting for setup wizard.
class SetupFlow : public HtmlDialogUIDelegate {
 public:
  virtual ~SetupFlow();

  // Runs a flow from |start| to |end|, and does the work of actually showing
  // the HTML dialog.  |container| is kept up-to-date with the lifetime of the
  // flow (e.g it is emptied on dialog close).
  static SetupFlow* Run(Profile* service);

  // Fills |args| with "user" and "error" arguments by querying |service|.
  static void GetArgsForGaiaLogin(DictionaryValue* args);

  // Triggers a state machine transition to advance_state.
  void Advance();

  // Focuses the dialog.  This is useful in cases where the dialog has been
  // obscured by a browser window.
  void Focus();

  // HtmlDialogUIDelegate implementation.
  // Get the HTML file path for the content to load in the dialog.
  virtual GURL GetDialogContentURL() const {
    return GURL("chrome://remotingresources/setup");
  }

  // HtmlDialogUIDelegate implementation.
  virtual void GetDOMMessageHandlers(
      std::vector<DOMMessageHandler*>* handlers) const;

  // HtmlDialogUIDelegate implementation.
  // Get the size of the dialog.
  virtual void GetDialogSize(gfx::Size* size) const;

  // HtmlDialogUIDelegate implementation.
  // Gets the JSON string input to use when opening the dialog.
  virtual std::string GetDialogArgs() const {
    return dialog_start_args_;
  }

  // HtmlDialogUIDelegate implementation.
  // A callback to notify the delegate that the dialog closed.
  virtual void OnDialogClosed(const std::string& json_retval);

  // HtmlDialogUIDelegate implementation.
  virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) { }

  // HtmlDialogUIDelegate implementation.
  virtual std::wstring GetDialogTitle() const {
    return l10n_util::GetString(IDS_REMOTING_SETUP_DIALOG_TITLE);
  }

  // HtmlDialogUIDelegate implementation.
  virtual bool IsDialogModal() const {
    return false;
  }

  void OnUserClickedCustomize() {
    // TODO(pranavk): Implement this method.
  }

  bool ClickCustomizeOk() {
    // TODO(pranavk): Implement this method.
    return true;
  }

  void ClickCustomizeCancel() {
    // TODO(pranavk): Implement this method.
  }

 private:

  // Use static Run method to get an instance.
  SetupFlow(const std::string& args, Profile* profile);

  DISALLOW_COPY_AND_ASSIGN(SetupFlow);

  std::string dialog_start_args_;  // The args to pass to the initial page.

  Profile* profile_;
};

}  // namespace remoting_setup

#endif  // CHROME_BROWSER_REMOTING_SETUP_FLOW_H_