summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-28 02:26:30 +0000
committerrafaelw@chromium.org <rafaelw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-28 02:26:30 +0000
commitbbeae1b4351499ca2ab3082040a289f1dd493584 (patch)
tree88cb130fa46ffe70e0d437f953b92dc9011e41a2 /chrome
parentcd1b8530bbb6bb7351e2a54f0b23aedc16a4498a (diff)
downloadchromium_src-bbeae1b4351499ca2ab3082040a289f1dd493584.zip
chromium_src-bbeae1b4351499ca2ab3082040a289f1dd493584.tar.gz
chromium_src-bbeae1b4351499ca2ab3082040a289f1dd493584.tar.bz2
Initial work on chrome-ui://extensions/ page. URL now displays a static template page
Review URL: http://codereview.chromium.org/28172 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/browser.scons2
-rw-r--r--chrome/browser/browser.vcproj8
-rw-r--r--chrome/browser/browser_resources.grd1
-rw-r--r--chrome/browser/dom_ui/dom_ui_contents.cc3
-rw-r--r--chrome/browser/extensions/extensions_ui.cc90
-rw-r--r--chrome/browser/extensions/extensions_ui.h58
-rw-r--r--chrome/browser/resources/extensions.html87
-rw-r--r--chrome/chrome.xcodeproj/project.pbxproj6
9 files changed, 258 insertions, 0 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 416ad08..96cae76 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -173,6 +173,9 @@ each locale. -->
<message name="IDS_DOWNLOAD_TITLE" desc="Title for the downloads tab.">
Downloads
</message>
+ <message name="IDS_EXTENSIONS_TITLE" desc="Title for the extensions tab.">
+ Extensions
+ </message>
<message name="IDS_SESSIONS_TITLE" desc="Title for the sessions tab.">
Sessions
</message>
diff --git a/chrome/browser/browser.scons b/chrome/browser/browser.scons
index ea53d85..2a62c54 100644
--- a/chrome/browser/browser.scons
+++ b/chrome/browser/browser.scons
@@ -513,6 +513,8 @@ input_files = ChromeFileList([
'extensions/extension_protocols.h',
'extensions/extensions_service.cc',
'extensions/extensions_service.h',
+ 'extensions/extensions_ui.cc',
+ 'extensions/extensions_ui.h',
'extensions/user_script_master.cc',
'extensions/user_script_master.h',
]),
diff --git a/chrome/browser/browser.vcproj b/chrome/browser/browser.vcproj
index 0015e0a..49c6eff 100644
--- a/chrome/browser/browser.vcproj
+++ b/chrome/browser/browser.vcproj
@@ -1946,6 +1946,14 @@
>
</File>
<File
+ RelativePath=".\extensions\extensions_ui.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\extensions\extensions_ui.h"
+ >
+ </File>
+ <File
RelativePath=".\extensions\user_script_master.cc"
>
</File>
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 10d84fa..c856181 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -23,6 +23,7 @@
<include name="IDR_CREDITS_HTML" file="resources\about_credits.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_HISTORY_HTML" file="resources\history.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_DOWNLOADS_HTML" file="resources\downloads.html" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_EXTENSIONS_HTML" file="resources\extensions.html" flattenhtml="true" type="BINDATA" />
<if expr="os == 'linux2'">
<include name="IDR_LINUX_SPLASH_HTML" file="resources\linux-splash.html" flattenhtml="true" type="BINDATA" />
</if>
diff --git a/chrome/browser/dom_ui/dom_ui_contents.cc b/chrome/browser/dom_ui/dom_ui_contents.cc
index 6fd749f..fd6a5c3 100644
--- a/chrome/browser/dom_ui/dom_ui_contents.cc
+++ b/chrome/browser/dom_ui/dom_ui_contents.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/dom_ui/downloads_ui.h"
#include "chrome/browser/dom_ui/history_ui.h"
#include "chrome/browser/dom_ui/new_tab_ui.h"
+#include "chrome/browser/extensions/extensions_ui.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/navigation_entry.h"
#include "chrome/common/resource_bundle.h"
@@ -243,6 +244,8 @@ DOMUI* DOMUIContents::GetDOMUIForURL(const GURL &url) {
return new HistoryUI(this);
} else if (url.host() == DownloadsUI::GetBaseURL().host()) {
return new DownloadsUI(this);
+ } else if (url.host() == ExtensionsUI::GetBaseURL().host()) {
+ return new ExtensionsUI(this);
} else if (url.host() == DebuggerContents::GetBaseURL().host()) {
return new DebuggerContents(this);
} else if (url.host() == DevToolsUI::GetBaseURL().host()) {
diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc
new file mode 100644
index 0000000..c4d2344
--- /dev/null
+++ b/chrome/browser/extensions/extensions_ui.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2006-2009 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.
+
+#include "chrome/browser/extensions/extensions_ui.h"
+
+#include "base/thread.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/common/jstemplate_builder.h"
+#include "chrome/common/l10n_util.h"
+#include "chrome/common/resource_bundle.h"
+#include "chrome/common/url_constants.h"
+
+#include "grit/browser_resources.h"
+#include "grit/generated_resources.h"
+
+// ExtensionsUI is accessible from chrome-ui://extensions.
+static const char kExtensionsHost[] = "extensions";
+
+////////////////////////////////////////////////////////////////////////////////
+//
+// ExtensionsHTMLSource
+//
+////////////////////////////////////////////////////////////////////////////////
+
+ExtensionsUIHTMLSource::ExtensionsUIHTMLSource()
+ : DataSource(kExtensionsHost, MessageLoop::current()) {
+}
+
+void ExtensionsUIHTMLSource::StartDataRequest(const std::string& path,
+ int request_id) {
+ DictionaryValue localized_strings;
+ localized_strings.SetString(L"title",
+ l10n_util::GetString(IDS_EXTENSIONS_TITLE));
+
+ static const StringPiece extensions_html(
+ ResourceBundle::GetSharedInstance().GetRawDataResource(
+ IDR_EXTENSIONS_HTML));
+ const std::string full_html = jstemplate_builder::GetTemplateHtml(
+ extensions_html, &localized_strings, "root");
+
+ scoped_refptr<RefCountedBytes> html_bytes(new RefCountedBytes);
+ html_bytes->data.resize(full_html.size());
+ std::copy(full_html.begin(), full_html.end(), html_bytes->data.begin());
+
+ SendResponse(request_id, html_bytes);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+//
+// ExtensionsDOMHandler
+//
+///////////////////////////////////////////////////////////////////////////////
+
+ExtensionsDOMHandler::ExtensionsDOMHandler(DOMUI* dom_ui)
+ : DOMMessageHandler(dom_ui) {
+}
+
+ExtensionsDOMHandler::~ExtensionsDOMHandler() {
+}
+
+// ExtensionsDOMHandler, public: -----------------------------------------------
+
+void ExtensionsDOMHandler::Init() {
+}
+
+ExtensionsUI::ExtensionsUI(DOMUIContents* contents) : DOMUI(contents) {
+}
+
+void ExtensionsUI::Init() {
+ ExtensionsDOMHandler* handler = new ExtensionsDOMHandler(this);
+ AddMessageHandler(handler);
+ handler->Init();
+
+ ExtensionsUIHTMLSource* html_source = new ExtensionsUIHTMLSource();
+
+ // Set up the chrome-ui://extensions/ source.
+ g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(&chrome_url_data_manager,
+ &ChromeURLDataManager::AddDataSource, html_source));
+}
+
+// static
+GURL ExtensionsUI::GetBaseURL() {
+ std::string url = DOMUIContents::GetScheme();
+ url += chrome::kStandardSchemeSeparator;
+ url += kExtensionsHost;
+ return GURL(url);
+}
+
diff --git a/chrome/browser/extensions/extensions_ui.h b/chrome/browser/extensions/extensions_ui.h
new file mode 100644
index 0000000..1298289
--- /dev/null
+++ b/chrome/browser/extensions/extensions_ui.h
@@ -0,0 +1,58 @@
+// Copyright (c) 2006-2009 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_EXTENSIONS_UI_H_
+#define CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_
+
+#include <string>
+
+#include "chrome/browser/dom_ui/dom_ui.h"
+#include "chrome/browser/dom_ui/dom_ui_contents.h"
+
+class GURL;
+
+class ExtensionsUIHTMLSource : public ChromeURLDataManager::DataSource {
+ public:
+ ExtensionsUIHTMLSource();
+
+ // Called when the network layer has requested a resource underneath
+ // the path we registered.
+ virtual void StartDataRequest(const std::string& path, int request_id);
+ virtual std::string GetMimeType(const std::string&) const {
+ return "text/html";
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ExtensionsUIHTMLSource);
+};
+
+// The handler for Javascript messages related to the "extensions" view.
+class ExtensionsDOMHandler : public DOMMessageHandler {
+ public:
+ explicit ExtensionsDOMHandler(DOMUI* dom_ui);
+ virtual ~ExtensionsDOMHandler();
+ void Init();
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ExtensionsDOMHandler);
+};
+
+class ExtensionsUI : public DOMUI {
+ public:
+ explicit ExtensionsUI(DOMUIContents* contents);
+
+ // Return the URL for the front page of this UI.
+ static GURL GetBaseURL();
+
+ // DOMUI Implementation
+ virtual void Init();
+
+ private:
+ DOMUIContents* contents_;
+
+ DISALLOW_COPY_AND_ASSIGN(ExtensionsUI);
+};
+
+#endif // CHROME_BROWSER_EXTENSIONS_EXTENSIONS_UI_H_
+
diff --git a/chrome/browser/resources/extensions.html b/chrome/browser/resources/extensions.html
new file mode 100644
index 0000000..9147b03
--- /dev/null
+++ b/chrome/browser/resources/extensions.html
@@ -0,0 +1,87 @@
+<!DOCTYPE HTML>
+<html id="root">
+<head>
+<meta charset="utf-8">
+<title jscontent="title"></title>
+<script type="text/javascript">
+
+// TODO(rafaelw): Remove. This is stub data. The idea is that the C++ will
+// populate a similar json structure and hand it to this page with real data
+// from the extensions system
+var testExtensionData = [
+ {
+ "name": "Dummy Extension",
+ "description": "Does some extremely cool stuff that I won't ever bother " +
+ "explaining, because it's just that cool.",
+ "version": "1.0.231",
+ "content_scripts": [
+ {
+ "js": ["file1.js", "file2.js"],
+ "matches": ["http://*/*", "http://other.com/*"]
+ },
+ {
+ "js": ["file1.js", "file2.js"],
+ "matches": ["http://*/*", "http://other.com/*"]
+ },
+ {
+ "js": ["file1.js", "file2.js"],
+ "matches": ["http://*/*", "http://other.com/*"]
+ },
+ ],
+ },
+ {
+ "name": "PlaceHolder Extension",
+ "description": "",
+ "version": "1.0.231",
+ "content_scripts": [],
+ }
+];
+
+/**
+ * Takes the |extensionsData| input argument which represents data about the
+ * currently installed/running extensions and populates the html jstemplate with
+ * that data
+ * @param {Object} extensionsData Detailed info about installed extensions
+ */
+function showExtensionsData(extensionsData) {
+ // This is the javascript code that processes the template:
+ var input = new JsExprContext(extensionsData);
+ var output = document.getElementById('extensionTemplate');
+ jstProcess(input, output);
+}
+</script>
+<style type="text/css">
+h1 {
+ text-align: center;
+}
+.extension{
+ padding: 8px;
+}
+.scriptMatches {
+ padding: 4px;
+ font-size: 12px;
+}
+</style>
+</head>
+<body onload="showExtensionsData(testExtensionData);">
+ <h1>Installed Extensions</h1>
+ <div id="extensionTemplate">
+ <div class="extension" jsselect="$this">
+ <div jscontent="name">Extension Name</div>
+ <div jscontent="description">Extension Description</div>
+ <div>Version: <span jscontent="version">x.x.x.x</span></div>
+ <div class="scriptMatches" jsselect="content_scripts">
+ <div>
+ <span jsselect="js"
+ jscontent="(($index > 0) ? ' ' : '') + $this">
+ </span>
+ </div>
+ <div>
+ <span jsselect="matches"
+ jscontent="(($index > 0) ? ' ' : '') + $this">
+ </span>
+ </div>
+ </div>
+ </div>
+ </body>
+</html> \ No newline at end of file
diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj
index dca3388..8366b27 100644
--- a/chrome/chrome.xcodeproj/project.pbxproj
+++ b/chrome/chrome.xcodeproj/project.pbxproj
@@ -95,6 +95,7 @@
0EE123B79B750A2FCEFB4569 /* history_backend_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF9F00E9D48F7009A6919 /* history_backend_unittest.cc */; };
0FF05474D5345CABC5C85B5F /* save_package_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BF9DC0E9D48CE009A6919 /* save_package_unittest.cc */; };
12E687ED55D418FEE894F824 /* history_url_provider.cc in Sources */ = {isa = PBXBuildFile; fileRef = D3C3DAA911D390A33D06B0B0 /* history_url_provider.cc */; };
+ 130C64BCFE3C5C626CC589A1 /* extensions_ui.cc in Sources */ = {isa = PBXBuildFile; fileRef = 9B8087A4D6C6DFC7FCF9908C /* extensions_ui.cc */; };
1647A33CB5B4B14087BFF5C8 /* dns_global.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFA680E9D4981009A6919 /* dns_global.cc */; };
198C49FE557624088F83497A /* bookmark_context_menu.cc in Sources */ = {isa = PBXBuildFile; fileRef = 90BF0D1189BB7158BD7F1600 /* bookmark_context_menu.cc */; };
1C284EB767D0E3D302AC675C /* tab_restore_service.cc in Sources */ = {isa = PBXBuildFile; fileRef = B020A11D500D7519E54F2957 /* tab_restore_service.cc */; };
@@ -2547,6 +2548,7 @@
534E66C30F311BEC0006B2B2 /* temp_scaffolding_stubs.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = temp_scaffolding_stubs.cc; sourceTree = "<group>"; };
56E1D7DF17D327BFCB0B895D /* test_web_contents.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = test_web_contents.cc; path = tab_contents/test_web_contents.cc; sourceTree = "<group>"; };
5EE47CAC5E11F4B35E564CCE /* child_process_host.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = child_process_host.cc; sourceTree = "<group>"; };
+ 5F62FA507336F4E1806D5E5A /* extensions_ui.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = extensions_ui.h; sourceTree = "<group>"; };
622534301BD3F4A908D426D0 /* user_data_manager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = user_data_manager.cc; sourceTree = "<group>"; };
629BF493DEA096E2DD844F2B /* autofill_manager.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = autofill_manager.cc; sourceTree = "<group>"; };
6447F24FADC63E58A44DB762 /* url_pattern.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = url_pattern.cc; path = extensions/url_pattern.cc; sourceTree = "<group>"; };
@@ -2598,6 +2600,7 @@
90BF0D1189BB7158BD7F1600 /* bookmark_context_menu.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bookmark_context_menu.cc; path = browser/bookmarks/bookmark_context_menu.cc; sourceTree = SOURCE_ROOT; };
938D10350F57401C009F1128 /* renderer_webkitclient_impl.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = renderer_webkitclient_impl.cc; sourceTree = "<group>"; };
938D10360F57401C009F1128 /* renderer_webkitclient_impl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = renderer_webkitclient_impl.h; sourceTree = "<group>"; };
+ 9B8087A4D6C6DFC7FCF9908C /* extensions_ui.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extensions_ui.cc; sourceTree = "<group>"; };
A2FC5EE73E0DE8BF6C1C4C0F /* bookmark_utils.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = bookmark_utils.cc; path = browser/bookmarks/bookmark_utils.cc; sourceTree = SOURCE_ROOT; };
A4457D7F38B3E87FD6F0812A /* extension_bindings.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = extension_bindings.cc; path = renderer/extensions/extension_bindings.cc; sourceTree = SOURCE_ROOT; };
A54612D90EE9957000A8EE5D /* extensions_service.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = extensions_service.cc; sourceTree = "<group>"; };
@@ -4744,6 +4747,8 @@
A54612D90EE9957000A8EE5D /* extensions_service.cc */,
A54612DA0EE9957000A8EE5D /* extensions_service.h */,
A54612DB0EE9958600A8EE5D /* extensions_service_unittest.cc */,
+ 9B8087A4D6C6DFC7FCF9908C /* extensions_ui.cc */,
+ 5F62FA507336F4E1806D5E5A /* extensions_ui.h */,
0082A7510F16987A000AA0EF /* user_script_master.cc */,
0082A7520F16987A000AA0EF /* user_script_master.h */,
);
@@ -5791,6 +5796,7 @@
E48B6C280F2783E9002E47EC /* extension_protocols.cc in Sources */,
F7DA1699176A4C039D5D10D0 /* extension_view.cc in Sources */,
A54612E20EE995F600A8EE5D /* extensions_service.cc in Sources */,
+ 130C64BCFE3C5C626CC589A1 /* extensions_ui.cc in Sources */,
9E85B39CA40439D93CE52E60 /* fav_icon_helper.cc in Sources */,
E45075C10F1506F2003BE099 /* firefox2_importer.cc in Sources */,
E45075C40F150701003BE099 /* firefox3_importer.cc in Sources */,