| 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 <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/scoped_ptr.h" | 10 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/dom_ui/dom_ui.h" | 11 #include "chrome/browser/dom_ui/dom_ui.h" |
| 12 #include "chrome/browser/extensions/extension_bookmark_manager_api.h" |
| 12 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 13 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
| 13 #include "chrome/browser/extensions/extension_popup_host.h" | 14 #include "chrome/browser/extensions/extension_popup_host.h" |
| 14 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 15 | 16 |
| 16 class ListValue; | 17 class ListValue; |
| 17 class PrefService; | 18 class PrefService; |
| 18 class RenderViewHost; | 19 class RenderViewHost; |
| 19 class TabContents; | 20 class TabContents; |
| 20 | 21 |
| 21 // This class implements DOMUI for extensions and allows extensions to put UI in | 22 // This class implements DOMUI for extensions and allows extensions to put UI in |
| (...skipping 20 matching lines...) Expand all Loading... |
| 42 // ExtensionFunctionDispatcher::Delegate | 43 // ExtensionFunctionDispatcher::Delegate |
| 43 virtual Browser* GetBrowser() const; | 44 virtual Browser* GetBrowser() const; |
| 44 virtual ExtensionDOMUI* GetExtensionDOMUI() { return this; } | 45 virtual ExtensionDOMUI* GetExtensionDOMUI() { return this; } |
| 45 virtual gfx::NativeWindow GetFrameNativeWindow(); | 46 virtual gfx::NativeWindow GetFrameNativeWindow(); |
| 46 | 47 |
| 47 // ExtensionPopupHost::Delegate | 48 // ExtensionPopupHost::Delegate |
| 48 virtual RenderViewHost* GetRenderViewHost(); | 49 virtual RenderViewHost* GetRenderViewHost(); |
| 49 virtual Profile* GetProfile(); | 50 virtual Profile* GetProfile(); |
| 50 virtual gfx::NativeView GetNativeViewOfHost(); | 51 virtual gfx::NativeView GetNativeViewOfHost(); |
| 51 | 52 |
| 53 virtual ExtensionBookmarkManagerEventRouter* |
| 54 extension_bookmark_manager_event_router() { |
| 55 return extension_bookmark_manager_event_router_.get(); |
| 56 } |
| 57 |
| 52 // BrowserURLHandler | 58 // BrowserURLHandler |
| 53 static bool HandleChromeURLOverride(GURL* url, Profile* profile); | 59 static bool HandleChromeURLOverride(GURL* url, Profile* profile); |
| 54 | 60 |
| 55 // Register and unregister a dictionary of one or more overrides. | 61 // Register and unregister a dictionary of one or more overrides. |
| 56 // Page names are the keys, and chrome-extension: URLs are the values. | 62 // Page names are the keys, and chrome-extension: URLs are the values. |
| 57 // (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" } | 63 // (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" } |
| 58 static void RegisterChromeURLOverrides(Profile* profile, | 64 static void RegisterChromeURLOverrides(Profile* profile, |
| 59 const Extension::URLOverrideMap& overrides); | 65 const Extension::URLOverrideMap& overrides); |
| 60 static void UnregisterChromeURLOverrides(Profile* profile, | 66 static void UnregisterChromeURLOverrides(Profile* profile, |
| 61 const Extension::URLOverrideMap& overrides); | 67 const Extension::URLOverrideMap& overrides); |
| 62 static void UnregisterChromeURLOverride(const std::string& page, | 68 static void UnregisterChromeURLOverride(const std::string& page, |
| 63 Profile* profile, | 69 Profile* profile, |
| 64 Value* override); | 70 Value* override); |
| 65 | 71 |
| 66 // Called from BrowserPrefs | 72 // Called from BrowserPrefs |
| 67 static void RegisterUserPrefs(PrefService* prefs); | 73 static void RegisterUserPrefs(PrefService* prefs); |
| 68 | 74 |
| 69 private: | 75 private: |
| 70 // Unregister the specified override, and if it's the currently active one, | 76 // Unregister the specified override, and if it's the currently active one, |
| 71 // ensure that something takes its place. | 77 // ensure that something takes its place. |
| 72 static void UnregisterAndReplaceOverride(const std::string& page, | 78 static void UnregisterAndReplaceOverride(const std::string& page, |
| 73 Profile* profile, | 79 Profile* profile, |
| 74 ListValue* list, | 80 ListValue* list, |
| 75 Value* override); | 81 Value* override); |
| 76 | 82 |
| 77 // When the RenderViewHost changes (RenderViewCreated and RenderViewReused), | 83 // When the RenderViewHost changes (RenderViewCreated and RenderViewReused), |
| 78 // we need to reset the ExtensionFunctionDispatcher so it's talking to the | 84 // we need to reset the ExtensionFunctionDispatcher so it's talking to the |
| 79 // right one, as well as being linked to the correct URL. | 85 // right one, as well as being linked to the correct URL. |
| 80 void ResetExtensionFunctionDispatcher(RenderViewHost* render_view_host); | 86 void ResetExtensionFunctionDispatcher(RenderViewHost* render_view_host); |
| 81 | 87 |
| 88 void ResetExtensionBookmarkManagerEventRouter(); |
| 89 |
| 82 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; | 90 scoped_ptr<ExtensionFunctionDispatcher> extension_function_dispatcher_; |
| 91 |
| 92 scoped_ptr<ExtensionBookmarkManagerEventRouter> |
| 93 extension_bookmark_manager_event_router_; |
| 83 }; | 94 }; |
| 84 | 95 |
| 85 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_ | 96 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_DOM_UI_H_ |
| OLD | NEW |