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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
Dan Beam
2016/10/28 22:26:52
nit: #include "base/macros.h"
for DISALLOW_COPY_A
Devlin
2016/10/29 17:42:24
Done.
| |
11 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" | 11 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" |
12 #include "components/favicon_base/favicon_callback.h" | 12 #include "components/favicon_base/favicon_callback.h" |
13 #include "content/public/browser/web_ui_controller.h" | 13 #include "content/public/browser/web_ui_controller.h" |
14 | 14 |
15 class Profile; | 15 class Profile; |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 class BrowserContext; | 18 class BrowserContext; |
19 class WebContents; | 19 class WebContents; |
20 } | 20 } |
21 | 21 |
22 namespace extensions { | 22 namespace extensions { |
23 class BookmarkManagerPrivateDragEventRouter; | 23 class BookmarkManagerPrivateDragEventRouter; |
24 } | 24 } |
25 | 25 |
26 namespace user_prefs { | 26 namespace user_prefs { |
27 class PrefRegistrySyncable; | 27 class PrefRegistrySyncable; |
28 } | 28 } |
29 | 29 |
30 // 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 |
31 // 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 |
32 // "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 |
33 // hosted by this class. | 33 // hosted by this class. |
34 // TODO(devlin): The above description has nothing to do with this class as far | |
35 // as I can tell. | |
34 class ExtensionWebUI : public content::WebUIController { | 36 class ExtensionWebUI : public content::WebUIController { |
35 public: | 37 public: |
36 static const char kExtensionURLOverrides[]; | 38 static const char kExtensionURLOverrides[]; |
37 | 39 |
40 // Returns true if the given url requires WebUI bindings. | |
41 static bool NeedsExtensionWebUI(content::BrowserContext* browser_context, | |
42 const GURL& url); | |
43 | |
38 ExtensionWebUI(content::WebUI* web_ui, const GURL& url); | 44 ExtensionWebUI(content::WebUI* web_ui, const GURL& url); |
39 | 45 |
40 ~ExtensionWebUI() override; | 46 ~ExtensionWebUI() override; |
41 | 47 |
42 virtual extensions::BookmarkManagerPrivateDragEventRouter* | 48 extensions::BookmarkManagerPrivateDragEventRouter* |
43 bookmark_manager_private_drag_event_router(); | 49 bookmark_manager_private_drag_event_router(); |
44 | 50 |
51 // TODO(devlin): The rest of this class is static methods dealing with | |
52 // chrome url overrides (e.g. changing chrome://newtab to go to an extension- | |
53 // provided new tab page). This should be in a separate class from the WebUI | |
54 // controller for the bookmark manager, and the WebUI controller should be | |
55 // renamed. | |
45 // BrowserURLHandler | 56 // BrowserURLHandler |
46 static bool HandleChromeURLOverride(GURL* url, | 57 static bool HandleChromeURLOverride(GURL* url, |
47 content::BrowserContext* browser_context); | 58 content::BrowserContext* browser_context); |
48 static bool HandleChromeURLOverrideReverse( | 59 static bool HandleChromeURLOverrideReverse( |
49 GURL* url, content::BrowserContext* browser_context); | 60 GURL* url, content::BrowserContext* browser_context); |
50 | 61 |
51 // Initialize the Chrome URL overrides. This must happen *before* any further | 62 // Initialize the Chrome URL overrides. This must happen *before* any further |
52 // calls for URL overrides! | 63 // calls for URL overrides! |
53 static void InitializeChromeURLOverrides(Profile* profile); | 64 static void InitializeChromeURLOverrides(Profile* profile); |
54 | 65 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 static void UnregisterAndReplaceOverride(const std::string& page, | 101 static void UnregisterAndReplaceOverride(const std::string& page, |
91 Profile* profile, | 102 Profile* profile, |
92 base::ListValue* list, | 103 base::ListValue* list, |
93 const base::Value* override); | 104 const base::Value* override); |
94 | 105 |
95 // TODO(aa): This seems out of place. Why is it not with the event routers for | 106 // TODO(aa): This seems out of place. Why is it not with the event routers for |
96 // the other extension APIs? | 107 // the other extension APIs? |
97 std::unique_ptr<extensions::BookmarkManagerPrivateDragEventRouter> | 108 std::unique_ptr<extensions::BookmarkManagerPrivateDragEventRouter> |
98 bookmark_manager_private_drag_event_router_; | 109 bookmark_manager_private_drag_event_router_; |
99 | 110 |
100 // The URL this WebUI was created for. | 111 DISALLOW_COPY_AND_ASSIGN(ExtensionWebUI); |
101 GURL url_; | |
102 }; | 112 }; |
103 | 113 |
104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ | 114 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ |
OLD | NEW |