summaryrefslogtreecommitdiffstats
path: root/chrome/browser
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/browser
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/browser')
-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
7 files changed, 249 insertions, 0 deletions
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