summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/copresence_ui_handler.h
blob: f4d32ce4df44718932b460559f85955df4fe7f58 (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
// Copyright 2014 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_UI_WEBUI_COPRESENCE_UI_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_COPRESENCE_UI_HANDLER_H_

#include "base/macros.h"
#include "components/copresence/public/copresence_observer.h"
#include "content/public/browser/web_ui_message_handler.h"

namespace base {
class ListValue;
}

namespace content {
class WebUI;
}

namespace copresence {
class CopresenceState;
}

// UI Handler for the copresence page.
// TODO(crbug.com/444263): Write tests.
class CopresenceUIHandler final : public content::WebUIMessageHandler,
                                  public copresence::CopresenceObserver {
 public:
  explicit CopresenceUIHandler(content::WebUI* web_ui);
  ~CopresenceUIHandler() override;

 private:
  // WebUIMessageHandler override.
  void RegisterMessages() override;

  // CopresenceObserver overrides.
  void DirectivesUpdated() override;
  void TokenTransmitted(const copresence::TransmittedToken& token) override;
  void TokenReceived(const copresence::ReceivedToken& token) override;

  // Handler to populate the page with its initial state.
  void HandlePopulateState(const base::ListValue* args);

  // Handler for the clear state button.
  void HandleClearState(const base::ListValue* args);

  copresence::CopresenceState* state_;

  DISALLOW_COPY_AND_ASSIGN(CopresenceUIHandler);
};

#endif  // CHROME_BROWSER_UI_WEBUI_COPRESENCE_UI_HANDLER_H_