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