Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(634)

Side by Side Diff: chrome/browser/extensions/extension_web_ui.h

Issue 2468673003: [Extensions] Remove ExtensionWebUI (Closed)
Patch Set: nit Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/macros.h"
12 #include "chrome/common/extensions/chrome_manifest_url_handlers.h" 12 #include "chrome/common/extensions/chrome_manifest_url_handlers.h"
13 #include "components/favicon_base/favicon_callback.h" 13 #include "components/favicon_base/favicon_callback.h"
14 #include "content/public/browser/web_ui_controller.h" 14 #include "content/public/browser/web_ui_controller.h"
15 15
16 class Profile; 16 class Profile;
17 17
18 namespace content { 18 namespace content {
19 class BrowserContext; 19 class BrowserContext;
20 class WebContents; 20 class WebContents;
21 } 21 }
22 22
23 namespace extensions {
24 class BookmarkManagerPrivateDragEventRouter;
25 }
26
27 namespace user_prefs { 23 namespace user_prefs {
28 class PrefRegistrySyncable; 24 class PrefRegistrySyncable;
29 } 25 }
30 26
31 // This class implements WebUI for extensions and allows extensions to put UI in 27 // A collection of methods to handle Chrome URL overrides that are managed by
32 // the main tab contents area. For example, each extension can specify an 28 // extensions (such as overriding the new tab page).
33 // "options_page", and that page is displayed in the tab contents area and is 29 // TODO(devlin): Rename this class to ExtensionURLOverrides.
34 // hosted by this class. 30 class ExtensionWebUI {
35 // TODO(devlin): The above description has nothing to do with this class as far
36 // as I can tell.
37 class ExtensionWebUI : public content::WebUIController {
38 public: 31 public:
39 static const char kExtensionURLOverrides[]; 32 static const char kExtensionURLOverrides[];
40 33
41 ExtensionWebUI(content::WebUI* web_ui, const GURL& url);
42
43 ~ExtensionWebUI() override;
44
45 // Returns true if the given url requires WebUI bindings.
46 static bool NeedsExtensionWebUI(content::BrowserContext* browser_context,
47 const GURL& url);
48
49 // TODO(devlin): The rest of this class is static methods dealing with
50 // chrome url overrides (e.g. changing chrome://newtab to go to an extension-
51 // provided new tab page). This should be in a separate class from the WebUI
52 // controller for the bookmark manager, and the WebUI controller should be
53 // renamed.
54 // BrowserURLHandler
55 static bool HandleChromeURLOverride(GURL* url, 34 static bool HandleChromeURLOverride(GURL* url,
56 content::BrowserContext* browser_context); 35 content::BrowserContext* browser_context);
57 static bool HandleChromeURLOverrideReverse( 36 static bool HandleChromeURLOverrideReverse(
58 GURL* url, content::BrowserContext* browser_context); 37 GURL* url, content::BrowserContext* browser_context);
59 38
60 // Initialize the Chrome URL overrides. This must happen *before* any further 39 // Initialize the Chrome URL overrides. This must happen *before* any further
61 // calls for URL overrides! 40 // calls for URL overrides!
62 static void InitializeChromeURLOverrides(Profile* profile); 41 static void InitializeChromeURLOverrides(Profile* profile);
63 42
64 // Validate the Chrome URL overrides, ensuring that each is valid and points 43 // Validate the Chrome URL overrides, ensuring that each is valid and points
(...skipping 21 matching lines...) Expand all
86 // Called from BrowserPrefs 65 // Called from BrowserPrefs
87 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 66 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
88 67
89 // Get the favicon for the extension by getting an icon from the manifest. 68 // Get the favicon for the extension by getting an icon from the manifest.
90 // Note. |callback| is always run asynchronously. 69 // Note. |callback| is always run asynchronously.
91 static void GetFaviconForURL( 70 static void GetFaviconForURL(
92 Profile* profile, 71 Profile* profile,
93 const GURL& page_url, 72 const GURL& page_url,
94 const favicon_base::FaviconResultsCallback& callback); 73 const favicon_base::FaviconResultsCallback& callback);
95 74
96 extensions::BookmarkManagerPrivateDragEventRouter*
97 bookmark_manager_private_drag_event_router() {
98 return bookmark_manager_private_drag_event_router_.get();
99 }
100
101 private: 75 private:
102 // Unregister the specified override, and if it's the currently active one, 76 // Unregister the specified override, and if it's the currently active one,
103 // ensure that something takes its place. 77 // ensure that something takes its place.
104 static void UnregisterAndReplaceOverride(const std::string& page, 78 static void UnregisterAndReplaceOverride(const std::string& page,
105 Profile* profile, 79 Profile* profile,
106 base::ListValue* list, 80 base::ListValue* list,
107 const base::Value* override); 81 const base::Value* override);
108
109 // TODO(aa): This seems out of place. Why is it not with the event routers for
110 // the other extension APIs?
111 std::unique_ptr<extensions::BookmarkManagerPrivateDragEventRouter>
112 bookmark_manager_private_drag_event_router_;
113
114 DISALLOW_COPY_AND_ASSIGN(ExtensionWebUI);
115 }; 82 };
116 83
117 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ 84 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698