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

Side by Side Diff: chrome/browser/dom_ui/dom_ui.h

Issue 12418: Implement History as HTML and add/change a bunch of stuff to make it easier t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years 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
« no previous file with comments | « chrome/browser/dom_ui/chrome_url_data_manager.cc ('k') | chrome/browser/dom_ui/dom_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2006-2008 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 CHROME_BROWSER_DOM_UI_H__
6 #define CHROME_BROWSER_DOM_UI_H__
7
8 #include "base/task.h"
9 #include "chrome/browser/dom_ui/dom_ui_contents.h"
10
11 class Value;
12 class DOMMessageHandler;
13
14 // A DOMUI sets up the datasources and message handlers for a given HTML-based
15 // UI. It is contained by a DOMUIContents.
16 class DOMUI {
17 public:
18 DOMUI(DOMUIContents* contents);
19
20 virtual ~DOMUI();
21 virtual void Init() = 0;
22
23 // Called from DOMUIContents.
24 void ProcessDOMUIMessage(const std::string& message,
25 const std::string& content);
26
27 // Used by DOMMessageHandlers.
28 typedef Callback1<const Value*>::Type MessageCallback;
29 void RegisterMessageCallback (const std::string& message,
30 MessageCallback* callback);
31
32 // Call a Javascript function by sending its name and arguments down to
33 // the renderer. This is asynchronous; there's no way to get the result
34 // of the call, and should be thought of more like sending a message to
35 // the page.
36 // There are two function variants for one-arg and two-arg calls.
37 void CallJavascriptFunction(const std::wstring& function_name,
38 const Value& arg);
39 void CallJavascriptFunction(const std::wstring& function_name,
40 const Value& arg1,
41 const Value& arg2);
42
43 Profile* get_profile() { return contents_->profile(); }
44
45 protected:
46 void AddMessageHandler(DOMMessageHandler* handler);
47
48 DOMUIContents* contents_;
49
50 private:
51 // Execute a string of raw Javascript on the page.
52 void ExecuteJavascript(const std::wstring& javascript);
53
54 // The DOMMessageHandlers we own.
55 std::vector<DOMMessageHandler*> handlers_;
56
57 // A map of message name -> message handling callback.
58 typedef std::map<std::string, MessageCallback*> MessageCallbackMap;
59 MessageCallbackMap message_callbacks_;
60
61 DISALLOW_COPY_AND_ASSIGN(DOMUI);
62 };
63
64 // Messages sent from the DOM are forwarded via the DOMUIContents to handler
65 // classes. These objects are owned by DOMUIHost and destroyed when the
66 // host is destroyed.
67 class DOMMessageHandler {
68 public:
69 explicit DOMMessageHandler(DOMUI* dom_ui);
70 virtual ~DOMMessageHandler();
71
72 protected:
73 // Adds "url" and "title" keys on incoming dictionary, setting title
74 // as the url as a fallback on empty title.
75 static void SetURLAndTitle(DictionaryValue* dictionary,
76 std::wstring title,
77 const GURL& gurl);
78
79 DOMUI* const dom_ui_;
80
81 private:
82 DISALLOW_COPY_AND_ASSIGN(DOMMessageHandler);
83 };
84
85
86 #endif // CHROME_BROWSER_DOM_UI_H__
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/chrome_url_data_manager.cc ('k') | chrome/browser/dom_ui/dom_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698