summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordubroy@chromium.org <dubroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-15 17:18:17 +0000
committerdubroy@chromium.org <dubroy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-15 17:18:17 +0000
commita21ea79c953c0cd935161a6946502a54eefe57da (patch)
tree6e1f5d4c10bde261f121553751f2a3790c25acbb
parent12a1bbda1933c59924aa44937e0c9aff84b647f9 (diff)
downloadchromium_src-a21ea79c953c0cd935161a6946502a54eefe57da.zip
chromium_src-a21ea79c953c0cd935161a6946502a54eefe57da.tar.gz
chromium_src-a21ea79c953c0cd935161a6946502a54eefe57da.tar.bz2
Revert 176910 - Possible breakage of PlatformAppBrowserTest.Messaging
http://build.chromium.org/p/chromium.win/builders/XP%20Tests%20%28dbg%29%282%29/builds/25744/steps/browser_tests/logs/Messaging > Add base class cr.ui.BubbleButton for options.ControlledSettingIndicator > > This CL extracts a cr.ui.BubbleButton base class from the > options.ControlledSettingIndicator so that it can be shared with the > upcoming improved about:policy page. > > BUG=134849 > TEST=Manual > > > Review URL: https://chromiumcodereview.appspot.com/11864019 TBR=bartfab@chromium.org Review URL: https://codereview.chromium.org/11882045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176924 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/resources/options/controlled_setting.js62
-rw-r--r--chrome/browser/resources/options/options.html2
-rw-r--r--chrome/browser/resources/options/options_page.css20
-rw-r--r--chrome/browser/resources/shared/css/bubble_button.css20
-rw-r--r--chrome/browser/resources/shared/js/cr/ui/bubble_button.js84
-rw-r--r--chrome/browser/resources/shared_resources.grd4
6 files changed, 77 insertions, 115 deletions
diff --git a/chrome/browser/resources/options/controlled_setting.js b/chrome/browser/resources/options/controlled_setting.js
index eafa7e3..6e2567e 100644
--- a/chrome/browser/resources/options/controlled_setting.js
+++ b/chrome/browser/resources/options/controlled_setting.js
@@ -15,14 +15,13 @@ cr.define('options', function() {
var ControlledSettingIndicator = cr.ui.define('span');
ControlledSettingIndicator.prototype = {
- __proto__: cr.ui.BubbleButton.prototype,
+ __proto__: HTMLSpanElement.prototype,
/**
* Decorates the base element to show the proper icon.
*/
decorate: function() {
- cr.ui.BubbleButton.prototype.decorate.call(this);
- this.classList.add('controlled-setting-indicator');
+ var self = this;
// If there is a pref, track its controlledBy and recommendedValue
// properties in order to be able to bring up the correct bubble.
@@ -31,6 +30,16 @@ cr.define('options', function() {
this.pref, this.handlePrefChange.bind(this));
this.resetHandler = this.clearAssociatedPref_;
}
+
+ this.className = 'controlled-setting-indicator';
+ this.location = cr.ui.ArrowLocation.TOP_END;
+ this.image = document.createElement('div');
+ this.image.tabIndex = 0;
+ this.image.setAttribute('role', 'button');
+ this.image.addEventListener('click', this);
+ this.image.addEventListener('keydown', this);
+ this.image.addEventListener('mousedown', this);
+ this.appendChild(this.image);
},
/**
@@ -44,6 +53,17 @@ cr.define('options', function() {
},
/**
+ * Whether the indicator is currently showing a bubble.
+ * @type {boolean}
+ */
+ get showingBubble() {
+ return this.image.classList.contains('showing-bubble');
+ },
+ set showingBubble(showing) {
+ this.image.classList.toggle('showing-bubble', showing);
+ },
+
+ /**
* Clears the preference associated with this indicator.
* @private
*/
@@ -71,6 +91,42 @@ cr.define('options', function() {
},
/**
+ * Handle mouse and keyboard events, allowing the user to open and close a
+ * bubble with further information.
+ * @param {Event} event Mouse or keyboard event.
+ */
+ handleEvent: function(event) {
+ switch (event.type) {
+ // Toggle the bubble on left click. Let any other clicks propagate.
+ case 'click':
+ if (event.button != 0)
+ return;
+ break;
+ // Toggle the bubble when <Return> or <Space> is pressed. Let any other
+ // key presses propagate.
+ case 'keydown':
+ switch (event.keyCode) {
+ case 13: // Return.
+ case 32: // Space.
+ break;
+ default:
+ return;
+ }
+ break;
+ // Blur focus when a mouse button is pressed, matching the behavior of
+ // other Web UI elements.
+ case 'mousedown':
+ if (document.activeElement)
+ document.activeElement.blur();
+ event.preventDefault();
+ return;
+ }
+ this.toggleBubble_();
+ event.preventDefault();
+ event.stopPropagation();
+ },
+
+ /**
* Open or close a bubble with further information about the pref.
* @private
*/
diff --git a/chrome/browser/resources/options/options.html b/chrome/browser/resources/options/options.html
index d0dc184..ebe6910 100644
--- a/chrome/browser/resources/options/options.html
+++ b/chrome/browser/resources/options/options.html
@@ -4,7 +4,6 @@
<meta charset="utf-8">
<title i18n-content="optionsPageTitle"></title>
<link rel="stylesheet" href="chrome://resources/css/bubble.css">
-<link rel="stylesheet" href="chrome://resources/css/bubble_button.css">
<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
<link rel="stylesheet" href="chrome://resources/css/list.css">
<link rel="stylesheet" href="chrome://resources/css/overlay.css">
@@ -64,7 +63,6 @@
<script src="chrome://resources/js/cr/ui/touch_handler.js"></script>
<script src="chrome://resources/js/cr/ui/array_data_model.js"></script>
<script src="chrome://resources/js/cr/ui/bubble.js"></script>
-<script src="chrome://resources/js/cr/ui/bubble_button.js"></script>
<script src="chrome://resources/js/cr/ui/focus_manager.js"></script>
<script src="chrome://resources/js/cr/ui/list_selection_model.js"></script>
<script src="chrome://resources/js/cr/ui/list_selection_controller.js"></script>
diff --git a/chrome/browser/resources/options/options_page.css b/chrome/browser/resources/options/options_page.css
index b20e393..0733c8c 100644
--- a/chrome/browser/resources/options/options_page.css
+++ b/chrome/browser/resources/options/options_page.css
@@ -477,13 +477,29 @@ html:not([enablePepperFlashSettings]) .pepper-flash-settings {
padding: 0;
}
+.controlled-setting-indicator {
+ display: none;
+}
+
input:-webkit-any([type='text'],[type='url'],:not([type])) +
.controlled-setting-indicator {
-webkit-margin-start: 5px;
}
-.controlled-setting-indicator:not([controlled-by]) {
- display: none;
+.controlled-setting-indicator[controlled-by] {
+ display: inline-block;
+ height: 0;
+ line-height: 1;
+ vertical-align: middle;
+ width: 16px;
+}
+
+.controlled-setting-indicator[controlled-by] > div {
+ background-size: 16px;
+ height: 16px;
+ position: relative;
+ top: -8px;
+ width: 16px;
}
.controlled-setting-indicator[controlled-by='policy'] > div {
diff --git a/chrome/browser/resources/shared/css/bubble_button.css b/chrome/browser/resources/shared/css/bubble_button.css
deleted file mode 100644
index 5f37ed2..0000000
--- a/chrome/browser/resources/shared/css/bubble_button.css
+++ /dev/null
@@ -1,20 +0,0 @@
-/* Copyright (c) 2013 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.
- */
-
-.bubble-button {
- display: inline-block;
- height: 0;
- line-height: 1;
- vertical-align: middle;
- width: 16px;
-}
-
-.bubble-button > div {
- background-size: 16px;
- height: 16px;
- position: relative;
- top: -8px;
- width: 16px;
-}
diff --git a/chrome/browser/resources/shared/js/cr/ui/bubble_button.js b/chrome/browser/resources/shared/js/cr/ui/bubble_button.js
deleted file mode 100644
index 7216a2d..0000000
--- a/chrome/browser/resources/shared/js/cr/ui/bubble_button.js
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright (c) 2013 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.
-
-cr.define('cr.ui', function() {
- /**
- * An image button that brings up an informative bubble when activated by
- * keyboard or mouse.
- * @constructor
- * @extends {HTMLSpanElement}
- */
- var BubbleButton = cr.ui.define('span');
-
- BubbleButton.prototype = {
- __proto__: HTMLSpanElement.prototype,
-
- /**
- * Decorates the base element to show the proper icon.
- */
- decorate: function() {
- this.className = 'bubble-button';
- this.location = cr.ui.ArrowLocation.TOP_END;
- this.image = document.createElement('div');
- this.image.tabIndex = 0;
- this.image.setAttribute('role', 'button');
- this.image.addEventListener('click', this);
- this.image.addEventListener('keydown', this);
- this.image.addEventListener('mousedown', this);
- this.appendChild(this.image);
- },
-
- /**
- * Whether the button is currently showing a bubble.
- * @type {boolean}
- */
- get showingBubble() {
- return this.image.classList.contains('showing-bubble');
- },
- set showingBubble(showing) {
- this.image.classList.toggle('showing-bubble', showing);
- },
-
- /**
- * Handle mouse and keyboard events, allowing the user to open and close an
- * informative bubble.
- * @param {Event} event Mouse or keyboard event.
- */
- handleEvent: function(event) {
- switch (event.type) {
- // Toggle the bubble on left click. Let any other clicks propagate.
- case 'click':
- if (event.button != 0)
- return;
- break;
- // Toggle the bubble when <Return> or <Space> is pressed. Let any other
- // key presses propagate.
- case 'keydown':
- switch (event.keyCode) {
- case 13: // Return.
- case 32: // Space.
- break;
- default:
- return;
- }
- break;
- // Blur focus when a mouse button is pressed, matching the behavior of
- // other Web UI elements.
- case 'mousedown':
- if (document.activeElement)
- document.activeElement.blur();
- event.preventDefault();
- return;
- }
- this.toggleBubble_();
- event.preventDefault();
- event.stopPropagation();
- },
- };
-
- // Export.
- return {
- BubbleButton: BubbleButton
- };
-});
diff --git a/chrome/browser/resources/shared_resources.grd b/chrome/browser/resources/shared_resources.grd
index 6561d08..41777c9 100644
--- a/chrome/browser/resources/shared_resources.grd
+++ b/chrome/browser/resources/shared_resources.grd
@@ -41,8 +41,6 @@ without changes to the corresponding grd file. -->
file="shared/css/alert_overlay.css" type="chrome_html" />
<structure name="IDR_SHARED_CSS_BUBBLE"
file="shared/css/bubble.css" type="chrome_html" />
- <structure name="IDR_SHARED_CSS_BUBBLE_BUTTON"
- file="shared/css/bubble_button.css" type="chrome_html" />
<structure name="IDR_SHARED_CSS_DIALOGS"
file="shared/css/dialogs.css" type="chrome_html" />
<structure name="IDR_SHARED_CSS_LIST"
@@ -97,8 +95,6 @@ without changes to the corresponding grd file. -->
type="chrome_html" />
<structure name="IDR_SHARED_JS_CR_UI_BUBBLE"
file="shared/js/cr/ui/bubble.js" type="chrome_html" />
- <structure name="IDR_SHARED_JS_CR_UI_BUBBLE_BUTTON"
- file="shared/js/cr/ui/bubble_button.js" type="chrome_html" />
<structure name="IDR_SHARED_JS_CR_UI_CARD_SLIDER"
file="shared/js/cr/ui/card_slider.js" type="chrome_html" />
<structure name="IDR_SHARED_JS_CR_UI_COMMAND"