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

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

Issue 2452773002: [Extensions] Limit Extension WebUI (Closed)
Patch Set: sky's 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
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_web_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
38 ExtensionWebUI(content::WebUI* web_ui, const GURL& url); 41 ExtensionWebUI(content::WebUI* web_ui, const GURL& url);
39 42
40 ~ExtensionWebUI() override; 43 ~ExtensionWebUI() override;
41 44
42 virtual extensions::BookmarkManagerPrivateDragEventRouter* 45 // Returns true if the given url requires WebUI bindings.
43 bookmark_manager_private_drag_event_router(); 46 static bool NeedsExtensionWebUI(content::BrowserContext* browser_context,
47 const GURL& url);
44 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.
45 // BrowserURLHandler 54 // BrowserURLHandler
46 static bool HandleChromeURLOverride(GURL* url, 55 static bool HandleChromeURLOverride(GURL* url,
47 content::BrowserContext* browser_context); 56 content::BrowserContext* browser_context);
48 static bool HandleChromeURLOverrideReverse( 57 static bool HandleChromeURLOverrideReverse(
49 GURL* url, content::BrowserContext* browser_context); 58 GURL* url, content::BrowserContext* browser_context);
50 59
51 // Initialize the Chrome URL overrides. This must happen *before* any further 60 // Initialize the Chrome URL overrides. This must happen *before* any further
52 // calls for URL overrides! 61 // calls for URL overrides!
53 static void InitializeChromeURLOverrides(Profile* profile); 62 static void InitializeChromeURLOverrides(Profile* profile);
54 63
(...skipping 22 matching lines...) Expand all
77 // Called from BrowserPrefs 86 // Called from BrowserPrefs
78 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 87 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
79 88
80 // Get the favicon for the extension by getting an icon from the manifest. 89 // Get the favicon for the extension by getting an icon from the manifest.
81 // Note. |callback| is always run asynchronously. 90 // Note. |callback| is always run asynchronously.
82 static void GetFaviconForURL( 91 static void GetFaviconForURL(
83 Profile* profile, 92 Profile* profile,
84 const GURL& page_url, 93 const GURL& page_url,
85 const favicon_base::FaviconResultsCallback& callback); 94 const favicon_base::FaviconResultsCallback& callback);
86 95
96 extensions::BookmarkManagerPrivateDragEventRouter*
97 bookmark_manager_private_drag_event_router() {
98 return bookmark_manager_private_drag_event_router_.get();
99 }
100
87 private: 101 private:
88 // Unregister the specified override, and if it's the currently active one, 102 // Unregister the specified override, and if it's the currently active one,
89 // ensure that something takes its place. 103 // ensure that something takes its place.
90 static void UnregisterAndReplaceOverride(const std::string& page, 104 static void UnregisterAndReplaceOverride(const std::string& page,
91 Profile* profile, 105 Profile* profile,
92 base::ListValue* list, 106 base::ListValue* list,
93 const base::Value* override); 107 const base::Value* override);
94 108
95 // TODO(aa): This seems out of place. Why is it not with the event routers for 109 // TODO(aa): This seems out of place. Why is it not with the event routers for
96 // the other extension APIs? 110 // the other extension APIs?
97 std::unique_ptr<extensions::BookmarkManagerPrivateDragEventRouter> 111 std::unique_ptr<extensions::BookmarkManagerPrivateDragEventRouter>
98 bookmark_manager_private_drag_event_router_; 112 bookmark_manager_private_drag_event_router_;
99 113
100 // The URL this WebUI was created for. 114 DISALLOW_COPY_AND_ASSIGN(ExtensionWebUI);
101 GURL url_;
102 }; 115 };
103 116
104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ 117 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_web_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698