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