summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorbryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 20:59:42 +0000
committerbryeung@chromium.org <bryeung@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 20:59:42 +0000
commit9c88d47551467000b9bd3484c940320141231f9f (patch)
tree94029e2c4aa97875c4f55112ad6640d3f63eb278 /chrome
parent65188eb51c19157f9b360c84acbfa66543f0d781 (diff)
downloadchromium_src-9c88d47551467000b9bd3484c940320141231f9f.zip
chromium_src-9c88d47551467000b9bd3484c940320141231f9f.tar.gz
chromium_src-9c88d47551467000b9bd3484c940320141231f9f.tar.bz2
Add a placeholder, overridable DOMUI keyboard.
This change does not add support for displaying the keyboard. That will be provided (along with a more useful keyboard) in follow-up changes. BUG=none TEST=added new override test Review URL: http://codereview.chromium.org/3362019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59712 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/browser_resources.grd1
-rw-r--r--chrome/browser/dom_ui/dom_ui_factory.cc7
-rw-r--r--chrome/browser/dom_ui/keyboard_ui.cc54
-rw-r--r--chrome/browser/dom_ui/keyboard_ui.h42
-rw-r--r--chrome/browser/extensions/extension_override_apitest.cc42
-rw-r--r--chrome/browser/profile_impl.cc5
-rw-r--r--chrome/browser/resources/keyboard/index.html1
-rw-r--r--chrome/browser/resources/keyboard/manifest.json12
-rw-r--r--chrome/chrome_browser.gypi5
-rw-r--r--chrome/common/extensions/extension.cc3
-rw-r--r--chrome/common/url_constants.cc2
-rw-r--r--chrome/common/url_constants.h2
-rw-r--r--chrome/test/data/extensions/api_test/override/keyboard/background.html3
-rw-r--r--chrome/test/data/extensions/api_test/override/keyboard/keyboard.html4
-rw-r--r--chrome/test/data/extensions/api_test/override/keyboard/manifest.json9
-rw-r--r--chrome/test/data/extensions/api_test/override/keyboard_fails/background.html3
-rw-r--r--chrome/test/data/extensions/api_test/override/keyboard_fails/keyboard.html4
-rw-r--r--chrome/test/data/extensions/api_test/override/keyboard_fails/manifest.json9
18 files changed, 207 insertions, 1 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index d6f6f1b..e3ecfd3 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -40,6 +40,7 @@ without changes to the corresponding grd file. eadeae-->
<include name="IDR_HISTORY_HTML" file="resources\history.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_HISTORY2_HTML" file="resources\history2.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_INCOGNITO_TAB_HTML" file="resources\incognito_tab.html" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_KEYBOARD_MANIFEST" file="resources\keyboard\manifest.json" type="BINDATA" />
<include name="IDR_LABS_HTML" file="resources\labs.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_NEW_INCOGNITO_TAB_THEME_CSS" file="resources\new_incognito_tab_theme.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_NEW_NEW_TAB_HTML" file="resources\new_new_tab.html" flattenhtml="true" type="BINDATA" />
diff --git a/chrome/browser/dom_ui/dom_ui_factory.cc b/chrome/browser/dom_ui/dom_ui_factory.cc
index 524059b..2e86f77 100644
--- a/chrome/browser/dom_ui/dom_ui_factory.cc
+++ b/chrome/browser/dom_ui/dom_ui_factory.cc
@@ -13,6 +13,9 @@
#include "chrome/browser/dom_ui/history_ui.h"
#include "chrome/browser/dom_ui/history2_ui.h"
#include "chrome/browser/dom_ui/html_dialog_ui.h"
+#if defined(TOUCH_UI)
+#include "chrome/browser/dom_ui/keyboard_ui.h"
+#endif
#include "chrome/browser/dom_ui/labs_ui.h"
#include "chrome/browser/dom_ui/net_internals_ui.h"
#include "chrome/browser/dom_ui/new_tab_ui.h"
@@ -121,6 +124,10 @@ static DOMUIFactoryFunction GetDOMUIFactoryFunction(Profile* profile,
return &NewDOMUI<HistoryUI2>;
if (about_labs::IsEnabled() && url.host() == chrome::kChromeUILabsHost)
return &NewDOMUI<LabsUI>;
+#if defined(TOUCH_UI)
+ if (url.host() == chrome::kChromeUIKeyboardHost)
+ return &NewDOMUI<KeyboardUI>;
+#endif
if (url.host() == chrome::kChromeUINetInternalsHost)
return &NewDOMUI<NetInternalsUI>;
if (url.host() == chrome::kChromeUIPluginsHost)
diff --git a/chrome/browser/dom_ui/keyboard_ui.cc b/chrome/browser/dom_ui/keyboard_ui.cc
new file mode 100644
index 0000000..7c091ef
--- /dev/null
+++ b/chrome/browser/dom_ui/keyboard_ui.cc
@@ -0,0 +1,54 @@
+// Copyright (c) 2010 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/dom_ui/keyboard_ui.h"
+
+#include "app/resource_bundle.h"
+#include "base/ref_counted_memory.h"
+#include "base/singleton.h"
+#include "base/string_piece.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+#include "chrome/browser/profile.h"
+#include "chrome/common/url_constants.h"
+#include "grit/browser_resources.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// KeyboardUI
+
+KeyboardUI::KeyboardUI(TabContents* contents)
+ : DOMUI(contents) {
+ KeyboardHTMLSource* html_source = new KeyboardHTMLSource();
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(
+ Singleton<ChromeURLDataManager>::get(),
+ &ChromeURLDataManager::AddDataSource,
+ make_scoped_refptr(html_source)));
+}
+
+KeyboardUI::~KeyboardUI() {
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// KeyboardHTMLSource
+
+KeyboardUI::KeyboardHTMLSource::KeyboardHTMLSource()
+ : DataSource(chrome::kChromeUIKeyboardHost, MessageLoop::current()) {
+}
+
+void KeyboardUI::KeyboardHTMLSource::StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id) {
+ NOTREACHED() << "We should never get here since the extension should have"
+ << "been triggered";
+ SendResponse(request_id, NULL);
+}
+
+std::string KeyboardUI::KeyboardHTMLSource::GetMimeType(
+ const std::string&) const {
+ NOTREACHED() << "We should never get here since the extension should have"
+ << "been triggered";
+ return "text/html";
+}
diff --git a/chrome/browser/dom_ui/keyboard_ui.h b/chrome/browser/dom_ui/keyboard_ui.h
new file mode 100644
index 0000000..abb23d3
--- /dev/null
+++ b/chrome/browser/dom_ui/keyboard_ui.h
@@ -0,0 +1,42 @@
+// Copyright (c) 2010 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_DOM_UI_KEYBOARD_UI_H_
+#define CHROME_BROWSER_DOM_UI_KEYBOARD_UI_H_
+#pragma once
+
+#include <string>
+
+#include "chrome/browser/dom_ui/dom_ui.h"
+#include "chrome/browser/dom_ui/chrome_url_data_manager.h"
+
+class Profile;
+
+// The TabContents used for the keyboard page.
+class KeyboardUI : public DOMUI {
+ public:
+ explicit KeyboardUI(TabContents* manager);
+ ~KeyboardUI();
+
+ class KeyboardHTMLSource : public ChromeURLDataManager::DataSource {
+ public:
+ KeyboardHTMLSource();
+
+ // Overrides from DataSource
+ virtual void StartDataRequest(const std::string& path,
+ bool is_off_the_record,
+ int request_id);
+ virtual std::string GetMimeType(const std::string&) const;
+
+ private:
+ virtual ~KeyboardHTMLSource() {}
+
+ DISALLOW_COPY_AND_ASSIGN(KeyboardHTMLSource);
+ };
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(KeyboardUI);
+};
+
+#endif // CHROME_BROWSER_DOM_UI_KEYBOARD_UI_H_
diff --git a/chrome/browser/extensions/extension_override_apitest.cc b/chrome/browser/extensions/extension_override_apitest.cc
index adfe2fe..1efa5e7 100644
--- a/chrome/browser/extensions/extension_override_apitest.cc
+++ b/chrome/browser/extensions/extension_override_apitest.cc
@@ -39,6 +39,18 @@ class ExtensionOverrideTest : public ExtensionApiTest {
return true;
}
+
+#if defined(TOUCH_UI)
+ // Navigate to the keyboard page, and ensure we have arrived at an
+ // extension URL.
+ void NavigateToKeyboard() {
+ ui_test_utils::NavigateToURL(browser(), GURL("chrome://keyboard/"));
+ TabContents* tab = browser()->GetSelectedTabContents();
+ ASSERT_TRUE(tab->controller().GetActiveEntry());
+ EXPECT_TRUE(tab->controller().GetActiveEntry()->url().
+ SchemeIs(chrome::kExtensionScheme));
+ }
+#endif
};
IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideNewtab) {
@@ -128,3 +140,33 @@ IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, ShouldCleanUpDuplicateEntries) {
ASSERT_TRUE(CheckHistoryOverridesContainsNoDupes());
}
+
+#if defined(TOUCH_UI)
+IN_PROC_BROWSER_TEST_F(ExtensionOverrideTest, OverrideKeyboard) {
+ ASSERT_TRUE(RunExtensionTest("override/keyboard")) << message_;
+ {
+ ResultCatcher catcher;
+ NavigateToKeyboard();
+ ASSERT_TRUE(catcher.GetNextResult());
+ }
+
+ // Load the failing version. This should take precedence.
+ ASSERT_TRUE(LoadExtension(
+ test_data_dir_.AppendASCII("override").AppendASCII("keyboard_fails")));
+ {
+ ResultCatcher catcher;
+ NavigateToKeyboard();
+ ASSERT_FALSE(catcher.GetNextResult());
+ }
+
+ // Unload the failing version. We should be back to passing now.
+ const ExtensionList *extensions =
+ browser()->profile()->GetExtensionsService()->extensions();
+ UnloadExtension((*extensions->rbegin())->id());
+ {
+ ResultCatcher catcher;
+ NavigateToKeyboard();
+ ASSERT_TRUE(catcher.GetNextResult());
+ }
+}
+#endif
diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc
index 2a3bb3f..723eabc 100644
--- a/chrome/browser/profile_impl.cc
+++ b/chrome/browser/profile_impl.cc
@@ -395,6 +395,11 @@ void ProfileImpl::InitExtensions() {
component_extensions.push_back(
std::make_pair("bookmark_manager", IDR_BOOKMARKS_MANIFEST));
+#if defined(TOUCH_UI)
+ component_extensions.push_back(
+ std::make_pair("keyboard", IDR_KEYBOARD_MANIFEST));
+#endif
+
// Web Store.
component_extensions.push_back(
std::make_pair("web_store", IDR_WEBSTORE_MANIFEST));
diff --git a/chrome/browser/resources/keyboard/index.html b/chrome/browser/resources/keyboard/index.html
new file mode 100644
index 0000000..aae357e
--- /dev/null
+++ b/chrome/browser/resources/keyboard/index.html
@@ -0,0 +1 @@
+<html><body>This is a placeholder keyboard.</body></html>
diff --git a/chrome/browser/resources/keyboard/manifest.json b/chrome/browser/resources/keyboard/manifest.json
new file mode 100644
index 0000000..31f31e3
--- /dev/null
+++ b/chrome/browser/resources/keyboard/manifest.json
@@ -0,0 +1,12 @@
+{
+ "key": "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMzY3+qeu4pXSEeSegJLHHhFFiiAq82w8noLxkJqNh+d7Np/scxDr4WkYezIhJTUOIAMxeyP2e//lxU8LTLJFySVWf/dQ5p9xBwzyk4qqJsIsqbrNUrzziN6qk/1Vj8+3qWnG5mSo7Ge4n0OGAVugd29xa/2o79VCFnohgoCHtDdAgMBAAECgYEAnyspGdoK6RyW6h4TtbJ9RaqQ5BnO5P3H+zMo8zQqJ/kDMGgmVAyH1vT6rgzEkAwydrT2GbFQ614THAntKNf9pScL3KmjTeuKCh4t7PJyABOH6Zby/mHN3JJCrX4fLorv7h8CILUrdrmnrAbDvYsF3LTyHkWFeptpgUhZTSysd5UCQQD7O4/yv8a4uvvtdfGNLRb0xfl9JAdq5l+LzN6uSgA74fQoEdcFycjFjxeT2yW7vSzbSXswaSntkdrXin7oqB3/AkEA0Lv7IHEeQ3MkL04ETjgLFJ+UalG51K8gh0X4H4Fqrq24hkqG2xLT+bQ2NvCayqz2xMzqriZagELwXrw+R2tJIwJAYKIwZDbPwQ5rCJNtLdhCFDRyGmhZUgz6g1Nx86gTHvVybFcwVdGfoB3B++U3RlclgdNpxt0se2y2uGFVHzhLEQJAQM4MAp98EN7fnhwvtAUsU4PT9UpYUpLom3b6uPVaJM9kmbTrt3pZ+42aw2Xh+QjIOIOSXO0lberaa98vysahVwJAUmbvLS8ao4FGYkgi0GdskvbudxbVSv1waZuaMttmqenev7xz/94tMyd4Xhsg6AIFf8xpAfPkKF5XlnFje/akUQ==",
+ "name": "Virtual Keyboard",
+ "version": "0.1",
+ "description": "Virtual Keyboard",
+ "permissions": [
+ "experimental"
+ ],
+ "chrome_url_overrides": {
+ "keyboard": "index.html"
+ }
+}
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 81196b1..4a6a251 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1264,6 +1264,8 @@
'browser/dom_ui/html_dialog_ui.h',
'browser/dom_ui/import_data_handler.cc',
'browser/dom_ui/import_data_handler.h',
+ 'browser/dom_ui/keyboard_ui.cc',
+ 'browser/dom_ui/keyboard_ui.h',
'browser/dom_ui/labs_ui.cc',
'browser/dom_ui/labs_ui.h',
'browser/dom_ui/mediaplayer_ui.cc',
@@ -3194,7 +3196,8 @@
}],
['touchui==0', {
'sources!': [
- # Nothing yet.
+ 'browser/dom_ui/keyboard_ui.cc',
+ 'browser/dom_ui/keyboard_ui.h',
],
}],
['OS=="linux"', {
diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc
index a9cfde1..4a3f851 100644
--- a/chrome/common/extensions/extension.cc
+++ b/chrome/common/extensions/extension.cc
@@ -1556,6 +1556,9 @@ bool Extension::InitFromValue(const DictionaryValue& source, bool require_key,
std::string val;
// Restrict override pages to a list of supported URLs.
if ((page != chrome::kChromeUINewTabHost &&
+#if defined(TOUCH_UI)
+ page != chrome::kChromeUIKeyboardHost &&
+#endif
page != chrome::kChromeUIBookmarksHost &&
page != chrome::kChromeUIHistoryHost) ||
!overrides->GetStringWithoutPathExpansion(*iter, &val)) {
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 8157bce..46c4cb0 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -79,6 +79,7 @@ const char kChromeUIHistory2URL[] = "chrome://history2/";
const char kChromeUIHistoryURL[] = "chrome://history/";
const char kChromeUIImageBurnerURL[] = "chrome://imageburner/";
const char kChromeUIIPCURL[] = "chrome://about/ipc";
+const char kChromeUIKeyboardURL[] = "chrome://keyboard/";
const char kChromeUILabsURL[] = "chrome://labs/";
const char kChromeUIMediaplayerURL[] = "chrome://mediaplayer/";
const char kChromeUINewTabURL[] = "chrome://newtab";
@@ -100,6 +101,7 @@ const char kChromeUIHistoryHost[] = "history";
const char kChromeUIHistory2Host[] = "history2";
const char kChromeUIImageBurnerHost[] = "imageburner";
const char kChromeUIInspectorHost[] = "inspector";
+const char kChromeUIKeyboardHost[] = "keyboard";
const char kChromeUILabsHost[] = "labs";
const char kChromeUIMediaplayerHost[] = "mediaplayer";
const char kChromeUINetInternalsHost[] = "net-internals";
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index eb9f7b7..986d23c 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -72,6 +72,7 @@ extern const char kChromeUIHistory2URL[];
extern const char kChromeUIHistoryURL[];
extern const char kChromeUIImageBurnerURL[];
extern const char kChromeUIIPCURL[];
+extern const char kChromeUIKeyboardURL[];
extern const char kChromeUILabsURL[];
extern const char kChromeUIMediaplayerURL[];
extern const char kChromeUINewTabURL[];
@@ -95,6 +96,7 @@ extern const char kChromeUIHistory2Host[];
extern const char kChromeUIHistoryHost[];
extern const char kChromeUIImageBurnerHost[];
extern const char kChromeUIInspectorHost[];
+extern const char kChromeUIKeyboardHost[];
extern const char kChromeUILabsHost[];
extern const char kChromeUIMediaplayerHost[];
extern const char kChromeUINetInternalsHost[];
diff --git a/chrome/test/data/extensions/api_test/override/keyboard/background.html b/chrome/test/data/extensions/api_test/override/keyboard/background.html
new file mode 100644
index 0000000..3605780
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/override/keyboard/background.html
@@ -0,0 +1,3 @@
+<script>
+chrome.test.notifyPass();
+</script>
diff --git a/chrome/test/data/extensions/api_test/override/keyboard/keyboard.html b/chrome/test/data/extensions/api_test/override/keyboard/keyboard.html
new file mode 100644
index 0000000..af428b1
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/override/keyboard/keyboard.html
@@ -0,0 +1,4 @@
+<script>
+chrome.test.notifyPass();
+</script>
+Keyboard Override!
diff --git a/chrome/test/data/extensions/api_test/override/keyboard/manifest.json b/chrome/test/data/extensions/api_test/override/keyboard/manifest.json
new file mode 100644
index 0000000..25151a7
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/override/keyboard/manifest.json
@@ -0,0 +1,9 @@
+{
+ "name": "Keyboard override test",
+ "version": "0.1",
+ "description": "Test chrome://keyboard override",
+ "background_page": "background.html",
+ "chrome_url_overrides": {
+ "keyboard": "keyboard.html"
+ }
+}
diff --git a/chrome/test/data/extensions/api_test/override/keyboard_fails/background.html b/chrome/test/data/extensions/api_test/override/keyboard_fails/background.html
new file mode 100644
index 0000000..3605780
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/override/keyboard_fails/background.html
@@ -0,0 +1,3 @@
+<script>
+chrome.test.notifyPass();
+</script>
diff --git a/chrome/test/data/extensions/api_test/override/keyboard_fails/keyboard.html b/chrome/test/data/extensions/api_test/override/keyboard_fails/keyboard.html
new file mode 100644
index 0000000..16d845d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/override/keyboard_fails/keyboard.html
@@ -0,0 +1,4 @@
+<script>
+chrome.test.notifyFail('this failure is expected');
+</script>
+Failing Keyboard Override!
diff --git a/chrome/test/data/extensions/api_test/override/keyboard_fails/manifest.json b/chrome/test/data/extensions/api_test/override/keyboard_fails/manifest.json
new file mode 100644
index 0000000..25151a7
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/override/keyboard_fails/manifest.json
@@ -0,0 +1,9 @@
+{
+ "name": "Keyboard override test",
+ "version": "0.1",
+ "description": "Test chrome://keyboard override",
+ "background_page": "background.html",
+ "chrome_url_overrides": {
+ "keyboard": "keyboard.html"
+ }
+}