summaryrefslogtreecommitdiffstats
path: root/chromium/chrome/browser/ui/webui/webapks_handler.h
blob: bcb67234f20d44936c43190a4be17414610ecf36 (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
// Copyright 2017 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_WEBAPKS_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_WEBAPKS_HANDLER_H_

#include <memory>

#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/android/webapk/webapk_handler_delegate.h"
#include "chrome/browser/android/webapk/webapk_info.h"
#include "content/public/browser/web_ui_message_handler.h"

namespace base {
class ListValue;
}  // namespace base

// Handles JavaScript messages from the chrome://webapks page.
class WebApksHandler : public content::WebUIMessageHandler {
 public:
  WebApksHandler();
  ~WebApksHandler() override;

  // content::WebUIMessageHandler:
  void RegisterMessages() override;

  // Handler for the "requestWebApksInfo" message. This requests
  // information for the installed WebAPKs and returns it to JS using
  // OnWebApkInfoReceived().
  void HandleRequestWebApksInfo(const base::ListValue* args);

  // Handler for the "requestWebApkUpdate" message. This sets the
  // update flag for a set of WebAPKs. |args| should contain the
  // webapp IDs of the WebAPKs to update.
  void HandleRequestWebApkUpdate(const base::ListValue* args);

 private:
  // Called once for each installed WebAPK when the WebAPK Info is retrieved.
  void OnWebApkInfoRetrieved(const WebApkInfo& webapk_info);

  WebApkHandlerDelegate delegate_;

  DISALLOW_COPY_AND_ASSIGN(WebApksHandler);
};

#endif  // CHROME_BROWSER_UI_WEBUI_WEBAPKS_HANDLER_H_