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