blob: 4996c6399c213ebc203b02a01119058bdab67535 [file] [log] [blame]
[email protected]f4f50ef2011-01-21 19:01:191// Copyright (c) 2011 The Chromium Authors. All rights reserved.
[email protected]ea0f18b2009-07-27 22:16:112// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
[email protected]8f9d4eb2011-02-05 01:39:105#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
[email protected]32b76ef2010-07-26 23:08:247#pragma once
[email protected]811bfe372009-07-01 08:46:258
[email protected]b27257562009-11-16 23:28:269#include <string>
10
[email protected]3b63f8f42011-03-28 01:54:1511#include "base/memory/scoped_ptr.h"
[email protected]23d5f172011-10-25 05:49:5312#include "chrome/browser/bookmarks/bookmark_manager_extension_api.h"
[email protected]ee2ed42c2011-04-28 22:19:1413#include "chrome/browser/favicon/favicon_service.h"
[email protected]d3cfa482009-10-17 13:54:5714#include "chrome/common/extensions/extension.h"
[email protected]21e6caf82012-01-06 23:44:2015#include "content/browser/webui/web_ui.h"
[email protected]e14c959122012-01-13 16:58:2516#include "content/public/browser/web_ui_controller.h"
[email protected]811bfe372009-07-01 08:46:2517
[email protected]86c008e82009-08-28 20:26:0518class PrefService;
[email protected]591948962010-03-12 19:37:5219class Profile;
[email protected]86c008e82009-08-28 20:26:0520
[email protected]d21cdb12011-02-10 01:22:3221// This class implements WebUI for extensions and allows extensions to put UI in
[email protected]bad77bf2010-08-21 21:21:2222// the main tab contents area. For example, each extension can specify an
23// "options_page", and that page is displayed in the tab contents area and is
24// hosted by this class.
[email protected]e14c959122012-01-13 16:58:2525class ExtensionWebUI : public WebUI, public content::WebUIController {
[email protected]811bfe372009-07-01 08:46:2526 public:
[email protected]e2194742010-08-12 05:54:3427 static const char kExtensionURLOverrides[];
[email protected]c5b8ab42010-04-14 22:06:5028
[email protected]f3f3b722012-01-07 01:29:4329 ExtensionWebUI(content::WebContents* web_contents, const GURL& url);
[email protected]86c008e82009-08-28 20:26:0530
[email protected]8f9d4eb2011-02-05 01:39:1031 virtual ~ExtensionWebUI();
[email protected]8e383412010-10-19 16:57:0332
[email protected]fd8b39f2011-10-31 13:16:4433 virtual BookmarkManagerExtensionEventRouter*
34 bookmark_manager_extension_event_router();
[email protected]ced90ae12010-02-20 02:06:1635
[email protected]86c008e82009-08-28 20:26:0536 // BrowserURLHandler
[email protected]3d7474ff2011-07-27 17:47:3737 static bool HandleChromeURLOverride(GURL* url,
38 content::BrowserContext* browser_context);
39 static bool HandleChromeURLOverrideReverse(
40 GURL* url, content::BrowserContext* browser_context);
[email protected]86c008e82009-08-28 20:26:0541
42 // Register and unregister a dictionary of one or more overrides.
43 // Page names are the keys, and chrome-extension: URLs are the values.
44 // (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" }
45 static void RegisterChromeURLOverrides(Profile* profile,
[email protected]ced90ae12010-02-20 02:06:1646 const Extension::URLOverrideMap& overrides);
[email protected]86c008e82009-08-28 20:26:0547 static void UnregisterChromeURLOverrides(Profile* profile,
[email protected]ced90ae12010-02-20 02:06:1648 const Extension::URLOverrideMap& overrides);
[email protected]86c008e82009-08-28 20:26:0549 static void UnregisterChromeURLOverride(const std::string& page,
50 Profile* profile,
[email protected]f3a1c642011-07-12 19:15:0351 base::Value* override);
[email protected]86c008e82009-08-28 20:26:0552
53 // Called from BrowserPrefs
54 static void RegisterUserPrefs(PrefService* prefs);
55
[email protected]4b91f1f2010-07-14 20:01:0456 // Get the favicon for the extension by getting an icon from the manifest.
57 static void GetFaviconForURL(Profile* profile,
58 FaviconService::GetFaviconRequest* request,
59 const GURL& page_url);
[email protected]591948962010-03-12 19:37:5260
[email protected]811bfe372009-07-01 08:46:2561 private:
[email protected]86c008e82009-08-28 20:26:0562 // Unregister the specified override, and if it's the currently active one,
63 // ensure that something takes its place.
64 static void UnregisterAndReplaceOverride(const std::string& page,
65 Profile* profile,
[email protected]f3a1c642011-07-12 19:15:0366 base::ListValue* list,
67 base::Value* override);
[email protected]86c008e82009-08-28 20:26:0568
[email protected]bad77bf2010-08-21 21:21:2269 // TODO(aa): This seems out of place. Why is it not with the event routers for
70 // the other extension APIs?
[email protected]fd8b39f2011-10-31 13:16:4471 scoped_ptr<BookmarkManagerExtensionEventRouter>
72 bookmark_manager_extension_event_router_;
[email protected]3efe14a62010-10-25 22:18:3873
[email protected]d21cdb12011-02-10 01:22:3274 // The URL this WebUI was created for.
[email protected]3efe14a62010-10-25 22:18:3875 GURL url_;
[email protected]811bfe372009-07-01 08:46:2576};
77
[email protected]8f9d4eb2011-02-05 01:39:1078#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_