Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: content/public/browser/web_ui_controller.h

Issue 9224002: Make WebUI objects not derive from WebUI. WebUI objects own the controller. This is the ownership... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync to head to clear linux_chromeos browsertest failures Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_ 6 #define CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
11 #include "content/common/content_export.h" 11 #include "content/common/content_export.h"
12 12
13 class GURL; 13 class GURL;
14 class RenderViewHost; 14 class RenderViewHost;
15 class WebUI;
15 16
16 namespace base { 17 namespace base {
17 class ListValue; 18 class ListValue;
18 } 19 }
19 20
20 namespace content { 21 namespace content {
21 22
22 // A WebUI page is controller by the embedder's WebUIController object. It 23 // A WebUI page is controller by the embedder's WebUIController object. It
23 // manages the data source and message handlers. 24 // manages the data source and message handlers.
24 class CONTENT_EXPORT WebUIController { 25 class CONTENT_EXPORT WebUIController {
25 public: 26 public:
27 explicit WebUIController(WebUI* web_ui) : web_ui_(web_ui) {}
26 virtual ~WebUIController() {} 28 virtual ~WebUIController() {}
27 29
28 // Allows the controller to override handling all messages from the page. 30 // Allows the controller to override handling all messages from the page.
29 // Return true if the message handling was overridden. 31 // Return true if the message handling was overridden.
30 virtual bool OverrideHandleWebUIMessage(const GURL& source_url, 32 virtual bool OverrideHandleWebUIMessage(const GURL& source_url,
31 const std::string& message, 33 const std::string& message,
32 const base::ListValue& args); 34 const base::ListValue& args);
33 35
34 // Called when RenderView is first created. This is *not* called for every 36 // Called when RenderView is first created. This is *not* called for every
35 // page load because in some cases a RenderView will be reused. In those 37 // page load because in some cases a RenderView will be reused. In those
36 // cases, RenderViewReused will be called instead. 38 // cases, RenderViewReused will be called instead.
37 virtual void RenderViewCreated(RenderViewHost* render_view_host) {} 39 virtual void RenderViewCreated(RenderViewHost* render_view_host) {}
38 40
39 // Called when a RenderView is reused to display a page. 41 // Called when a RenderView is reused to display a page.
40 virtual void RenderViewReused(RenderViewHost* render_view_host) {} 42 virtual void RenderViewReused(RenderViewHost* render_view_host) {}
41 43
42 // Called when this becomes the active WebUI instance for a re-used 44 // Called when this becomes the active WebUI instance for a re-used
43 // RenderView; this is the point at which this WebUI instance will receive 45 // RenderView; this is the point at which this WebUI instance will receive
44 // DOM messages instead of the previous WebUI instance. 46 // DOM messages instead of the previous WebUI instance.
45 // 47 //
46 // If a WebUI instance has code that is usually triggered from a JavaScript 48 // If a WebUI instance has code that is usually triggered from a JavaScript
47 // onload handler, this should be overridden to check to see if the web page's 49 // onload handler, this should be overridden to check to see if the web page's
48 // DOM is still intact (e.g., due to a back/forward navigation that remains 50 // DOM is still intact (e.g., due to a back/forward navigation that remains
49 // within the same page), and if so trigger that code manually since onload 51 // within the same page), and if so trigger that code manually since onload
50 // won't be run in that case. 52 // won't be run in that case.
51 virtual void DidBecomeActiveForReusedRenderView() {} 53 virtual void DidBecomeActiveForReusedRenderView() {}
54
55 WebUI* web_ui() const { return web_ui_; }
56
57 private:
58 WebUI* web_ui_;
59
52 }; 60 };
53 61
54 } // namespace content 62 } // namespace content
55 63
56 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_ 64 #endif // CONTENT_PUBLIC_BROWSER_WEB_UI_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698