| OLD | NEW |
| 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "chrome/browser/favicon/favicon_service.h" | 11 #include "chrome/browser/favicon/favicon_service.h" |
| 12 #include "chrome/common/extensions/manifest_url_handler.h" | 12 #include "chrome/common/extensions/manifest_url_handler.h" |
| 13 #include "content/public/browser/web_ui_controller.h" | 13 #include "content/public/browser/web_ui_controller.h" |
| 14 | 14 |
| 15 class Profile; |
| 16 |
| 15 namespace content { | 17 namespace content { |
| 16 class BrowserContext; | 18 class BrowserContext; |
| 17 class WebContents; | 19 class WebContents; |
| 18 } | 20 } |
| 19 | 21 |
| 20 namespace extensions { | 22 namespace extensions { |
| 21 class BookmarkManagerPrivateEventRouter; | 23 class BookmarkManagerPrivateEventRouter; |
| 22 } | 24 } |
| 23 | 25 |
| 26 namespace user_prefs { |
| 24 class PrefRegistrySyncable; | 27 class PrefRegistrySyncable; |
| 25 class Profile; | 28 } |
| 26 | 29 |
| 27 // This class implements WebUI for extensions and allows extensions to put UI in | 30 // This class implements WebUI for extensions and allows extensions to put UI in |
| 28 // the main tab contents area. For example, each extension can specify an | 31 // the main tab contents area. For example, each extension can specify an |
| 29 // "options_page", and that page is displayed in the tab contents area and is | 32 // "options_page", and that page is displayed in the tab contents area and is |
| 30 // hosted by this class. | 33 // hosted by this class. |
| 31 class ExtensionWebUI : public content::WebUIController { | 34 class ExtensionWebUI : public content::WebUIController { |
| 32 public: | 35 public: |
| 33 static const char kExtensionURLOverrides[]; | 36 static const char kExtensionURLOverrides[]; |
| 34 | 37 |
| 35 ExtensionWebUI(content::WebUI* web_ui, const GURL& url); | 38 ExtensionWebUI(content::WebUI* web_ui, const GURL& url); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 50 // (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" } | 53 // (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" } |
| 51 static void RegisterChromeURLOverrides(Profile* profile, | 54 static void RegisterChromeURLOverrides(Profile* profile, |
| 52 const extensions::URLOverrides::URLOverrideMap& overrides); | 55 const extensions::URLOverrides::URLOverrideMap& overrides); |
| 53 static void UnregisterChromeURLOverrides(Profile* profile, | 56 static void UnregisterChromeURLOverrides(Profile* profile, |
| 54 const extensions::URLOverrides::URLOverrideMap& overrides); | 57 const extensions::URLOverrides::URLOverrideMap& overrides); |
| 55 static void UnregisterChromeURLOverride(const std::string& page, | 58 static void UnregisterChromeURLOverride(const std::string& page, |
| 56 Profile* profile, | 59 Profile* profile, |
| 57 const base::Value* override); | 60 const base::Value* override); |
| 58 | 61 |
| 59 // Called from BrowserPrefs | 62 // Called from BrowserPrefs |
| 60 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 63 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
| 61 | 64 |
| 62 // Get the favicon for the extension by getting an icon from the manifest. | 65 // Get the favicon for the extension by getting an icon from the manifest. |
| 63 // Note. |callback| is always run asynchronously. | 66 // Note. |callback| is always run asynchronously. |
| 64 static void GetFaviconForURL( | 67 static void GetFaviconForURL( |
| 65 Profile* profile, | 68 Profile* profile, |
| 66 const GURL& page_url, | 69 const GURL& page_url, |
| 67 const FaviconService::FaviconResultsCallback& callback); | 70 const FaviconService::FaviconResultsCallback& callback); |
| 68 | 71 |
| 69 private: | 72 private: |
| 70 // Unregister the specified override, and if it's the currently active one, | 73 // Unregister the specified override, and if it's the currently active one, |
| 71 // ensure that something takes its place. | 74 // ensure that something takes its place. |
| 72 static void UnregisterAndReplaceOverride(const std::string& page, | 75 static void UnregisterAndReplaceOverride(const std::string& page, |
| 73 Profile* profile, | 76 Profile* profile, |
| 74 base::ListValue* list, | 77 base::ListValue* list, |
| 75 const base::Value* override); | 78 const base::Value* override); |
| 76 | 79 |
| 77 // TODO(aa): This seems out of place. Why is it not with the event routers for | 80 // TODO(aa): This seems out of place. Why is it not with the event routers for |
| 78 // the other extension APIs? | 81 // the other extension APIs? |
| 79 scoped_ptr<extensions::BookmarkManagerPrivateEventRouter> | 82 scoped_ptr<extensions::BookmarkManagerPrivateEventRouter> |
| 80 bookmark_manager_private_event_router_; | 83 bookmark_manager_private_event_router_; |
| 81 | 84 |
| 82 // The URL this WebUI was created for. | 85 // The URL this WebUI was created for. |
| 83 GURL url_; | 86 GURL url_; |
| 84 }; | 87 }; |
| 85 | 88 |
| 86 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ | 89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ |
| OLD | NEW |