15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/basictypes.h"
97d4cd473f85ac64c3747c96c277f9e506a0d2246Torne (Richard Coles)#include "base/strings/string16.h"
105821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "content/common/content_export.h"
115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class GURL;
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace base {
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class ListValue;
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace content {
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class RenderViewHost;
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class WebUI;
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// A WebUI page is controller by the embedder's WebUIController object. It
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// manages the data source and message handlers.
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CONTENT_EXPORT WebUIController {
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public:
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  explicit WebUIController(WebUI* web_ui) : web_ui_(web_ui) {}
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual ~WebUIController() {}
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Allows the controller to override handling all messages from the page.
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Return true if the message handling was overridden.
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual bool OverrideHandleWebUIMessage(const GURL& source_url,
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                          const std::string& message,
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)                                          const base::ListValue& args);
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when RenderView is first created. This is *not* called for every
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // page load because in some cases a RenderView will be reused. In those
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // cases, RenderViewReused will be called instead.
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RenderViewCreated(RenderViewHost* render_view_host) {}
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  // Called when a RenderView is reused to display a page.
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  virtual void RenderViewReused(RenderViewHost* render_view_host) {}
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebUI* web_ui() const { return web_ui_; }
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private:
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)  WebUI* web_ui_;
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)};
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}  // namespace content
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#endif  // CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
53