| 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" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 | 41 |
| 42 virtual extensions::BookmarkManagerPrivateDragEventRouter* | 42 virtual extensions::BookmarkManagerPrivateDragEventRouter* |
| 43 bookmark_manager_private_drag_event_router(); | 43 bookmark_manager_private_drag_event_router(); |
| 44 | 44 |
| 45 // BrowserURLHandler | 45 // BrowserURLHandler |
| 46 static bool HandleChromeURLOverride(GURL* url, | 46 static bool HandleChromeURLOverride(GURL* url, |
| 47 content::BrowserContext* browser_context); | 47 content::BrowserContext* browser_context); |
| 48 static bool HandleChromeURLOverrideReverse( | 48 static bool HandleChromeURLOverrideReverse( |
| 49 GURL* url, content::BrowserContext* browser_context); | 49 GURL* url, content::BrowserContext* browser_context); |
| 50 | 50 |
| 51 // Register and unregister a dictionary of one or more overrides. | 51 // Initialize the Chrome URL overrides. This must happen *before* any further |
| 52 // Page names are the keys, and chrome-extension: URLs are the values. | 52 // calls for URL overrides! |
| 53 // (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" } | 53 static void InitializeChromeURLOverrides(Profile* profile); |
| 54 static void RegisterChromeURLOverrides(Profile* profile, | 54 |
| 55 // Validate the Chrome URL overrides, ensuring that each is valid and points |
| 56 // to an existing extension. To be called once all extensions are loaded. |
| 57 static void ValidateChromeURLOverrides(Profile* profile); |
| 58 |
| 59 // Add new Chrome URL overrides. If an entry exists, it is marked as active. |
| 60 // If one doesn't exist, it is added at the beginning of the list of |
| 61 // overrides (meaning it has priority). |
| 62 static void RegisterOrActivateChromeURLOverrides( |
| 63 Profile* profile, |
| 55 const extensions::URLOverrides::URLOverrideMap& overrides); | 64 const extensions::URLOverrides::URLOverrideMap& overrides); |
| 56 static void UnregisterChromeURLOverrides(Profile* profile, | 65 |
| 66 // Deactivate overrides without removing them from the list or modifying their |
| 67 // positions in the list. |
| 68 static void DeactivateChromeURLOverrides( |
| 69 Profile* profile, |
| 57 const extensions::URLOverrides::URLOverrideMap& overrides); | 70 const extensions::URLOverrides::URLOverrideMap& overrides); |
| 58 static void UnregisterChromeURLOverride(const std::string& page, | 71 |
| 59 Profile* profile, | 72 // Completely unregister overrides, removing them from the list. |
| 60 const base::Value* override); | 73 static void UnregisterChromeURLOverrides( |
| 74 Profile* profile, |
| 75 const extensions::URLOverrides::URLOverrideMap& overrides); |
| 61 | 76 |
| 62 // Called from BrowserPrefs | 77 // Called from BrowserPrefs |
| 63 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 78 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 64 | 79 |
| 65 // Get the favicon for the extension by getting an icon from the manifest. | 80 // Get the favicon for the extension by getting an icon from the manifest. |
| 66 // Note. |callback| is always run asynchronously. | 81 // Note. |callback| is always run asynchronously. |
| 67 static void GetFaviconForURL( | 82 static void GetFaviconForURL( |
| 68 Profile* profile, | 83 Profile* profile, |
| 69 const GURL& page_url, | 84 const GURL& page_url, |
| 70 const favicon_base::FaviconResultsCallback& callback); | 85 const favicon_base::FaviconResultsCallback& callback); |
| 71 | 86 |
| 72 private: | 87 private: |
| 73 // Unregister the specified override, and if it's the currently active one, | 88 // Unregister the specified override, and if it's the currently active one, |
| 74 // ensure that something takes its place. | 89 // ensure that something takes its place. |
| 75 static void UnregisterAndReplaceOverride(const std::string& page, | 90 static void UnregisterAndReplaceOverride(const std::string& page, |
| 76 Profile* profile, | 91 Profile* profile, |
| 77 base::ListValue* list, | 92 base::ListValue* list, |
| 78 const base::Value* override); | 93 const base::Value* override); |
| 79 | 94 |
| 80 // TODO(aa): This seems out of place. Why is it not with the event routers for | 95 // TODO(aa): This seems out of place. Why is it not with the event routers for |
| 81 // the other extension APIs? | 96 // the other extension APIs? |
| 82 scoped_ptr<extensions::BookmarkManagerPrivateDragEventRouter> | 97 scoped_ptr<extensions::BookmarkManagerPrivateDragEventRouter> |
| 83 bookmark_manager_private_drag_event_router_; | 98 bookmark_manager_private_drag_event_router_; |
| 84 | 99 |
| 85 // The URL this WebUI was created for. | 100 // The URL this WebUI was created for. |
| 86 GURL url_; | 101 GURL url_; |
| 87 }; | 102 }; |
| 88 | 103 |
| 89 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ | 104 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_ |
| OLD | NEW |