1// Copyright (c) 2012 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 CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
6#define CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
7
8#include "base/basictypes.h"
9#include "base/strings/string16.h"
10#include "content/common/content_export.h"
11
12class GURL;
13
14namespace base {
15class ListValue;
16}
17
18namespace content {
19
20class RenderViewHost;
21class WebUI;
22
23// A WebUI page is controller by the embedder's WebUIController object. It
24// manages the data source and message handlers.
25class CONTENT_EXPORT WebUIController {
26 public:
27  explicit WebUIController(WebUI* web_ui) : web_ui_(web_ui) {}
28  virtual ~WebUIController() {}
29
30  // Allows the controller to override handling all messages from the page.
31  // Return true if the message handling was overridden.
32  virtual bool OverrideHandleWebUIMessage(const GURL& source_url,
33                                          const std::string& message,
34                                          const base::ListValue& args);
35
36  // Called when RenderView is first created. This is *not* called for every
37  // page load because in some cases a RenderView will be reused. In those
38  // cases, RenderViewReused will be called instead.
39  virtual void RenderViewCreated(RenderViewHost* render_view_host) {}
40
41  // Called when a RenderView is reused to display a page.
42  virtual void RenderViewReused(RenderViewHost* render_view_host) {}
43
44  WebUI* web_ui() const { return web_ui_; }
45
46 private:
47  WebUI* web_ui_;
48};
49
50}  // namespace content
51
52#endif  // CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
53