summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-04 19:53:38 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-04 19:53:38 +0000
commit6d87f0e61c2b6f1a1ce9bea468b910a0ddb9ebc2 (patch)
tree8a26111e25c0ee393af62ad8fc1252921d28a03e
parent4d4bb12bad913e95bac1b285fdc4f3e405caef71 (diff)
downloadchromium_src-6d87f0e61c2b6f1a1ce9bea468b910a0ddb9ebc2.zip
chromium_src-6d87f0e61c2b6f1a1ce9bea468b910a0ddb9ebc2.tar.gz
chromium_src-6d87f0e61c2b6f1a1ce9bea468b910a0ddb9ebc2.tar.bz2
WebUI: Use the TOOLKIT_VIEWS define to determine the value of isViews.
This sets isViews correctly for non-Windows, non-CrOS Views builds. Fixes test failures from the previous commit which was reverted. BUG=none TEST=none Review URL: http://codereview.chromium.org/8114027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103966 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/shared/js/cr.js12
-rw-r--r--content/browser/webui/web_ui.cc13
-rw-r--r--content/browser/webui/web_ui.h2
-rw-r--r--content/common/bindings_policy.h4
4 files changed, 25 insertions, 6 deletions
diff --git a/chrome/browser/resources/shared/js/cr.js b/chrome/browser/resources/shared/js/cr.js
index 366f038..2a370a1 100644
--- a/chrome/browser/resources/shared/js/cr.js
+++ b/chrome/browser/resources/shared/js/cr.js
@@ -35,10 +35,16 @@ const cr = (function() {
const isLinux = /Linux/.test(navigator.userAgent);
/**
+ * Whether this uses GTK or not.
+ * @type {boolean}
+ */
+ const isGTK = /GTK/.test(chrome.toolkit);
+
+ /**
* Whether this uses the views toolkit or not.
* @type {boolean}
*/
- const isViews = isWindows || isChromeOS;
+ const isViews = /views/.test(chrome.toolkit);
/**
* Sets the os and toolkit attributes in the <html> element so that platform
@@ -51,10 +57,10 @@ const cr = (function() {
doc.documentElement.setAttribute('os', 'windows');
if (isChromeOS)
doc.documentElement.setAttribute('os', 'chromeos');
- if (isLinux) {
+ if (isLinux)
doc.documentElement.setAttribute('os', 'linux');
+ if (isGTK)
doc.documentElement.setAttribute('toolkit', 'gtk');
- }
if (isViews)
doc.documentElement.setAttribute('toolkit', 'views');
}
diff --git a/content/browser/webui/web_ui.cc b/content/browser/webui/web_ui.cc
index 9ac142c..59e2a07 100644
--- a/content/browser/webui/web_ui.cc
+++ b/content/browser/webui/web_ui.cc
@@ -99,6 +99,19 @@ void WebUI::OnWebUISend(const GURL& source_url,
}
}
+void WebUI::RenderViewCreated(RenderViewHost* render_view_host) {
+ // Do not attempt to set the toolkit property if WebUI is not enabled, e.g.,
+ // the bookmarks manager page.
+ if (!(bindings_ & BindingsPolicy::WEB_UI))
+ return;
+
+#if defined(TOOLKIT_VIEWS)
+ render_view_host->SetWebUIProperty("toolkit", "views");
+#elif defined(TOOLKIT_GTK)
+ render_view_host->SetWebUIProperty("toolkit", "GTK");
+#endif // defined(TOOLKIT_VIEWS)
+}
+
void WebUI::CallJavascriptFunction(const std::string& function_name) {
DCHECK(IsStringASCII(function_name));
string16 javascript = ASCIIToUTF16(function_name + "();");
diff --git a/content/browser/webui/web_ui.h b/content/browser/webui/web_ui.h
index 4464847..6d0e16c 100644
--- a/content/browser/webui/web_ui.h
+++ b/content/browser/webui/web_ui.h
@@ -49,7 +49,7 @@ class CONTENT_EXPORT WebUI : public IPC::Channel::Listener {
// *not* called for every page load because in some cases
// RenderViewHostManager will reuse RenderView instances. In those cases,
// RenderViewReused will be called instead.
- virtual void RenderViewCreated(RenderViewHost* render_view_host) {}
+ virtual void RenderViewCreated(RenderViewHost* render_view_host);
// Called by RenderViewHostManager when a RenderView is reused to display a
// page.
diff --git a/content/common/bindings_policy.h b/content/common/bindings_policy.h
index 489ebef..ecdc1a6 100644
--- a/content/common/bindings_policy.h
+++ b/content/common/bindings_policy.h
@@ -11,10 +11,10 @@
class BindingsPolicy {
public:
enum {
- // HTML-based UI bindings that allows he js content to send JSON-encoded
+ // HTML-based UI bindings that allows the JS content to send JSON-encoded
// data back to the browser process.
WEB_UI = 1 << 0,
- // DOM automation bindings that allows the js content to send JSON-encoded
+ // DOM automation bindings that allows the JS content to send JSON-encoded
// data back to automation in the parent process. (By default this isn't
// allowed unless the app has been started up with the --dom-automation
// switch.)