summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/popular_sites_internals_message_handler.h
blob: 1801a92792ca391a8262c4b11e28b16e4f265f6f (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
// Copyright 2015 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_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_

#include <string>

#include "base/macros.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
#include "content/public/browser/web_ui_message_handler.h"

namespace base {
class ListValue;
}  // namespace base

class PopularSites;

// The implementation for the chrome://popular-sites-internals page.
class PopularSitesInternalsMessageHandler
    : public content::WebUIMessageHandler {
 public:
  PopularSitesInternalsMessageHandler();
  ~PopularSitesInternalsMessageHandler() override;

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

  void HandleRegisterForEvents(const base::ListValue* args);
  void HandleDownload(const base::ListValue* args);
  void HandleViewJson(const base::ListValue* args);

  void SendDownloadResult(bool success);
  void SendSites();
  void SendJson(const std::string& json);

  void OnPopularSitesAvailable(bool explicit_request, bool success);

  scoped_ptr<PopularSites> popular_sites_;

  base::WeakPtrFactory<PopularSitesInternalsMessageHandler> weak_ptr_factory_;

  DISALLOW_COPY_AND_ASSIGN(PopularSitesInternalsMessageHandler);
};

#endif  // CHROME_BROWSER_UI_WEBUI_POPULAR_SITES_INTERNALS_MESSAGE_HANDLER_H_