OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_ |
7 | 7 |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "chrome/browser/dom_ui/dom_ui.h" | 9 #include "chrome/browser/dom_ui/dom_ui.h" |
10 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 10 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
11 | 11 |
| 12 class ListValue; |
| 13 class PrefService; |
| 14 class TabContents; |
| 15 |
12 // This class implements DOMUI for extensions and allows extensions to put UI in | 16 // This class implements DOMUI for extensions and allows extensions to put UI in |
13 // the main tab contents area. | 17 // the main tab contents area. |
14 class ExtensionDOMUI | 18 class ExtensionDOMUI |
15 : public DOMUI, | 19 : public DOMUI, |
16 public ExtensionFunctionDispatcher::Delegate { | 20 public ExtensionFunctionDispatcher::Delegate { |
17 public: | 21 public: |
18 explicit ExtensionDOMUI(TabContents* tab_contents); | 22 explicit ExtensionDOMUI(TabContents* tab_contents); |
| 23 |
19 ExtensionFunctionDispatcher* extension_function_dispatcher() const { | 24 ExtensionFunctionDispatcher* extension_function_dispatcher() const { |
20 return extension_function_dispatcher_.get(); | 25 return extension_function_dispatcher_.get(); |
21 } | 26 } |
22 | 27 |
23 // DOMUI | 28 // DOMUI |
24 virtual void RenderViewCreated(RenderViewHost* render_view_host); | 29 virtual void RenderViewCreated(RenderViewHost* render_view_host); |
25 virtual void RenderViewReused(RenderViewHost* render_view_host); | 30 virtual void RenderViewReused(RenderViewHost* render_view_host); |
26 virtual void ProcessDOMUIMessage(const std::string& message, | 31 virtual void ProcessDOMUIMessage(const std::string& message, |
27 const std::string& content, | 32 const std::string& content, |
28 int request_id, | 33 int request_id, |
29 bool has_callback); | 34 bool has_callback); |
30 | 35 |
31 // ExtensionFunctionDispatcher::Delegate | 36 // ExtensionFunctionDispatcher::Delegate |
32 virtual Browser* GetBrowser(); | 37 virtual Browser* GetBrowser(); |
33 | 38 |
| 39 // BrowserURLHandler |
| 40 static bool HandleChromeURLOverride(GURL* url, Profile* profile); |
| 41 |
| 42 // Register and unregister a dictionary of one or more overrides. |
| 43 // Page names are the keys, and chrome-extension: URLs are the values. |
| 44 // (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" } |
| 45 static void RegisterChromeURLOverrides(Profile* profile, |
| 46 const DictionaryValue* overrides); |
| 47 static void UnregisterChromeURLOverrides(Profile* profile, |
| 48 const DictionaryValue* overrides); |
| 49 static void UnregisterChromeURLOverride(const std::string& page, |
| 50 Profile* profile, |
| 51 Value* override); |
| 52 |
| 53 // Called from BrowserPrefs |
| 54 static void RegisterUserPrefs(PrefService* prefs); |
| 55 |
34 private: | 56 private: |
| 57 // Unregister the specified override, and if it's the currently active one, |
| 58 // ensure that something takes its place. |
| 59 static void UnregisterAndReplaceOverride(const std::string& page, |
| 60 Profile* profile, |
| 61 ListValue* list, |
| 62 Value* override); |
| 63 |
| 64 // When the RenderViewHost changes (RenderViewCreated and RenderViewReused), |
| 65 // we need to reset the ExtensionFunctionDispatcher so it's talking to the |
| 66 // right one, as well as being linked to the correct URL. |
| 67 void ResetExtensionFunctionDispatcher(RenderViewHost* render_view_host); |
| 68 |
35 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; | 69 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; |
36 }; | 70 }; |
37 | 71 |
38 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_ | 72 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_ |
OLD | NEW |