1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
#define CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
#pragma once
#include <string>
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/extension_bookmark_manager_api.h"
#include "chrome/browser/favicon/favicon_service.h"
#include "chrome/browser/ui/webui/chrome_web_ui.h"
#include "chrome/common/extensions/extension.h"
class GURL;
class PrefService;
class Profile;
class RenderViewHost;
class TabContents;
namespace base {
class ListValue;
class Value;
}
// This class implements WebUI for extensions and allows extensions to put UI in
// the main tab contents area. For example, each extension can specify an
// "options_page", and that page is displayed in the tab contents area and is
// hosted by this class.
class ExtensionWebUI : public ChromeWebUI {
public:
static const char kExtensionURLOverrides[];
explicit ExtensionWebUI(TabContents* tab_contents, const GURL& url);
virtual ~ExtensionWebUI();
virtual ExtensionBookmarkManagerEventRouter*
extension_bookmark_manager_event_router();
// BrowserURLHandler
static bool HandleChromeURLOverride(GURL* url, Profile* profile);
static bool HandleChromeURLOverrideReverse(GURL* url, Profile* profile);
// Register and unregister a dictionary of one or more overrides.
// Page names are the keys, and chrome-extension: URLs are the values.
// (e.g. { "newtab": "chrome-extension://<id>/my_new_tab.html" }
static void RegisterChromeURLOverrides(Profile* profile,
const Extension::URLOverrideMap& overrides);
static void UnregisterChromeURLOverrides(Profile* profile,
const Extension::URLOverrideMap& overrides);
static void UnregisterChromeURLOverride(const std::string& page,
Profile* profile,
base::Value* override);
// Called from BrowserPrefs
static void RegisterUserPrefs(PrefService* prefs);
// Get the favicon for the extension by getting an icon from the manifest.
static void GetFaviconForURL(Profile* profile,
FaviconService::GetFaviconRequest* request,
const GURL& page_url);
private:
// Unregister the specified override, and if it's the currently active one,
// ensure that something takes its place.
static void UnregisterAndReplaceOverride(const std::string& page,
Profile* profile,
base::ListValue* list,
base::Value* override);
// TODO(aa): This seems out of place. Why is it not with the event routers for
// the other extension APIs?
scoped_ptr<ExtensionBookmarkManagerEventRouter>
extension_bookmark_manager_event_router_;
// The URL this WebUI was created for.
GURL url_;
};
#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_WEB_UI_H_
|