diff options
author | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-19 00:09:10 +0000 |
---|---|---|
committer | kuan@chromium.org <kuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-19 00:09:10 +0000 |
commit | d9ffdfb9cc92e80e574deb6cdd7b1b05cb7d8cde (patch) | |
tree | 42090bcf8d89580e5fc2178554433ef0b1d609db | |
parent | 1c5119cafe5ace871fbf38faaab36eacf44f5044 (diff) | |
download | chromium_src-d9ffdfb9cc92e80e574deb6cdd7b1b05cb7d8cde.zip chromium_src-d9ffdfb9cc92e80e574deb6cdd7b1b05cb7d8cde.tar.gz chromium_src-d9ffdfb9cc92e80e574deb6cdd7b1b05cb7d8cde.tar.bz2 |
alternate ntp: show search provider logo
- add option to show search provider logo at chrome://instant, enhance js to include and handle checkbox input beside number input
- NTP shows google logo if default search provider is google and option is checked, else a red box is shown.
- enhance animation scale factor: increase max to 20, set max for spin
BUG=148765
TEST=verfiy per bug rpt
Review URL: https://chromiumcodereview.appspot.com/10910286
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157457 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/theme/theme_resources.grd | 4 | ||||
-rw-r--r-- | chrome/browser/resources/instant/instant.js | 66 | ||||
-rw-r--r-- | chrome/browser/ui/views/search_view_controller.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/webui/instant_ui.cc | 32 | ||||
-rw-r--r-- | chrome/browser/ui/webui/instant_ui.h | 3 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 4 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
7 files changed, 80 insertions, 34 deletions
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd index 7c6bcf2..6c69c6c 100644 --- a/chrome/app/theme/theme_resources.grd +++ b/chrome/app/theme/theme_resources.grd @@ -322,9 +322,7 @@ <structure type="chrome_scaled_image" name="IDR_GEOLOCATION_ALLOWED_LOCATIONBAR_ICON" file="allowed_location.png" /> <structure type="chrome_scaled_image" name="IDR_GEOLOCATION_DENIED_LOCATIONBAR_ICON" file="blocked_location.png" /> <structure type="chrome_scaled_image" name="IDR_GEOLOCATION_INFOBAR_ICON" file="infobar_geolocation.png" /> - <if expr="pp_ifdef('_google_chrome')"> - <structure type="chrome_scaled_image" name="IDR_GOOGLE_LOGO_LG" file="google_chrome/google_logo_lg.png" /> - </if> + <structure type="chrome_scaled_image" name="IDR_GOOGLE_LOGO_LG" file="google_logo_lg.png" /> <if expr="pp_ifdef('chromeos')"> <structure type="chrome_scaled_image" name="IDR_HELP_MENU" file="help_16.png" /> </if> diff --git a/chrome/browser/resources/instant/instant.js b/chrome/browser/resources/instant/instant.js index 3abe066..d729407 100644 --- a/chrome/browser/resources/instant/instant.js +++ b/chrome/browser/resources/instant/instant.js @@ -18,17 +18,27 @@ var instantConfig = (function() { var FIELDS = [ { key: 'instant.animation_scale_factor', - label: 'Slow down animations by a factor of', - type: 'float', - units: 'no units, range 1 to 10', - default: 1 + label: 'Slow down animations by a factor of ', + type: 'number', + units: 'no units, range 1 to 20', + size: 3, + default: 1, + min: 1, + max: 20 }, { key: 'instant.experimental_zero_suggest_url_prefix', label: 'Prefix URL for the (experimental) ZeroSuggest provider', type: 'string', + size: 40, units: '', default: '' + }, + { + key: 'instant.show_search_provider_logo', + label: 'Show search provider logo', + type: 'checkbox', + default: false } ]; @@ -60,17 +70,13 @@ var instantConfig = (function() { row.appendChild(label); var input = createElementWithClass('input', 'row-input'); + input.type = field.type; input.id = field.key; input.title = "Default Value: " + field.default; - if (field.type == 'float') { - input.size = 3; - input.type = 'number'; - input.min = field.min || 0; - if (field.max) input.max = field.max; - if (field.step) input.step = field.step; - } else { - input.size = 40; - } + if (field.size) input.size = field.size; + input.min = field.min || 0; + if (field.max) input.max = field.max; + if (field.step) input.step = field.step; row.appendChild(input); var units = createElementWithClass('div', 'row-units'); @@ -89,7 +95,7 @@ var instantConfig = (function() { for (var i = 0; i < FIELDS.length; i++) { var field = FIELDS[i]; $(field.key).onchange = (function(key) { - setPreferenceValue(key, $(key).value); + setPreferenceValue(key); }).bind(null, field.key); } } @@ -110,16 +116,27 @@ var instantConfig = (function() { * @param {value} value The current value associated with prefName. */ function getPreferenceValueResult(prefName, value) { - $(prefName).value = value; + if ($(prefName).type == 'checkbox') + $(prefName).checked = value; + else + $(prefName).value = value; } /** - * Set a preference setting's value. + * Set a preference setting's value stored in the element with prefName. * @param {string} prefName The name of the preference value being set. - * @param {value} value The value to be associated with prefName. */ - function setPreferenceValue(prefName, value) { - chrome.send('setPreferenceValue', [prefName, value]); + function setPreferenceValue(prefName) { + var value; + if ($(prefName).type == 'checkbox') + value = $(prefName).checked; + else if ($(prefName).type == 'number') + value = parseFloat($(prefName).value); + else + value = $(prefName).value; + chrome.send( + 'setPreferenceValue', + [prefName, value]); } /** @@ -129,8 +146,11 @@ var instantConfig = (function() { function onReset() { for (var i = 0; i < FIELDS.length; i++) { var field = FIELDS[i]; - $(field.key).value = field.default; - setPreferenceValue(field.key, field.default); + if ($(field.key).type == 'checkbox') + $(field.key).checked = field.default; + else + $(field.key).value = field.default; + setPreferenceValue(field.key); } return false; } @@ -141,9 +161,7 @@ var instantConfig = (function() { function onSave() { for (var i = 0; i < FIELDS.length; i++) { var field = FIELDS[i]; - var value = $(field.key).value; - setPreferenceValue( - field.key, (field.type == 'float') ? parseFloat(value) : value); + setPreferenceValue(field.key); } return false; } diff --git a/chrome/browser/ui/views/search_view_controller.cc b/chrome/browser/ui/views/search_view_controller.cc index 9271587..3a3111e 100644 --- a/chrome/browser/ui/views/search_view_controller.cc +++ b/chrome/browser/ui/views/search_view_controller.cc @@ -475,8 +475,7 @@ void SearchViewController::CreateViews(State state) { Profile::FromBrowserContext(browser_context_))-> GetDefaultSearchProvider(); -#if defined(GOOGLE_CHROME_BUILD) - if (default_provider && + if (default_provider && InstantUI::ShouldShowSearchProviderLogo() && (TemplateURLPrepopulateData::GetEngineType(default_provider->url()) == SEARCH_ENGINE_GOOGLE)) { default_provider_logo_.reset(new views::ImageView()); @@ -486,7 +485,6 @@ void SearchViewController::CreateViews(State state) { default_provider_logo_->SetPaintToLayer(true); default_provider_logo_->SetFillsBoundsOpaquely(false); } -#endif if (!default_provider_logo_.get()) { default_provider_name_.reset(new views::Label( diff --git a/chrome/browser/ui/webui/instant_ui.cc b/chrome/browser/ui/webui/instant_ui.cc index 427bc3c..57ce618 100644 --- a/chrome/browser/ui/webui/instant_ui.cc +++ b/chrome/browser/ui/webui/instant_ui.cc @@ -44,6 +44,10 @@ class InstantUIMessageHandler return slow_animation_scale_factor_; } + static bool show_search_provider_logo() { + return show_search_provider_logo_; + } + private: void GetPreferenceValue(const base::ListValue* args); void SetPreferenceValue(const base::ListValue* args); @@ -51,11 +55,15 @@ class InstantUIMessageHandler // Slows down Instant animations by a time factor. static int slow_animation_scale_factor_; + // True if search provider logo should be shown. + static bool show_search_provider_logo_; + DISALLOW_COPY_AND_ASSIGN(InstantUIMessageHandler); }; // static int InstantUIMessageHandler::slow_animation_scale_factor_ = 1; +bool InstantUIMessageHandler::show_search_provider_logo_ = false; InstantUIMessageHandler::InstantUIMessageHandler() {} @@ -85,6 +93,10 @@ void InstantUIMessageHandler::GetPreferenceValue(const base::ListValue* args) { base::FundamentalValue arg(value); web_ui()->CallJavascriptFunction( "instantConfig.getPreferenceValueResult", pref_name_value, arg); + } else if (pref_name == prefs::kInstantShowSearchProviderLogo) { + base::FundamentalValue arg(show_search_provider_logo_); + web_ui()->CallJavascriptFunction( + "instantConfig.getPreferenceValueResult", pref_name_value, arg); } else if (pref_name == prefs::kExperimentalZeroSuggestUrlPrefix) { PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); base::StringValue arg(prefs->GetString(pref_name.c_str())); @@ -99,17 +111,24 @@ void InstantUIMessageHandler::SetPreferenceValue(const base::ListValue* args) { if (pref_name == prefs::kInstantAnimationScaleFactor) { double value; - if (!args->GetDouble(1, &value)) return; + if (!args->GetDouble(1, &value)) + return; #if defined(TOOLKIT_VIEWS) // Clamp to something reasonable. - value = std::max(0.1, std::min(value, 10.0)); + value = std::max(0.1, std::min(value, 20.0)); slow_animation_scale_factor_ = static_cast<int>(value); #else NOTIMPLEMENTED(); -#endif +#endif // defined(TOOLKIT_VIEWS) + } else if (pref_name == prefs::kInstantShowSearchProviderLogo) { + bool value; + if (!args->GetBoolean(1, &value)) + return; + show_search_provider_logo_ = value; } else if (pref_name == prefs::kExperimentalZeroSuggestUrlPrefix) { std::string value; - if (!args->GetString(1, &value)) return; + if (!args->GetString(1, &value)) + return; PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); prefs->SetString(pref_name.c_str(), value); } @@ -132,3 +151,8 @@ InstantUI::InstantUI(content::WebUI* web_ui) : WebUIController(web_ui) { int InstantUI::GetSlowAnimationScaleFactor() { return InstantUIMessageHandler::slow_animation_scale_factor(); } + +// static +bool InstantUI::ShouldShowSearchProviderLogo() { + return InstantUIMessageHandler::show_search_provider_logo(); +} diff --git a/chrome/browser/ui/webui/instant_ui.h b/chrome/browser/ui/webui/instant_ui.h index a5a2d8f..32ac064 100644 --- a/chrome/browser/ui/webui/instant_ui.h +++ b/chrome/browser/ui/webui/instant_ui.h @@ -17,6 +17,9 @@ class InstantUI : public content::WebUIController { // Returns a scale factor to slow down Instant animations. static int GetSlowAnimationScaleFactor(); + // Returns true if search provider logo should be shown. + static bool ShouldShowSearchProviderLogo(); + private: DISALLOW_COPY_AND_ASSIGN(InstantUI); }; diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 2c3e154..b4a7a3c1f 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -472,6 +472,10 @@ const char kInstantEnabled[] = "instant.enabled"; const char kExperimentalZeroSuggestUrlPrefix[] = "instant.experimental_zero_suggest_url_prefix"; +// Boolean pref indicating if instant search provider logo should be shown. +const char kInstantShowSearchProviderLogo[] = + "instant.show_search_provider_logo"; + // Used to migrate preferences from local state to user preferences to // enable multiple profiles. // BITMASK with possible values (see browser_prefs.cc for enum): diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 681ae45..f86b222 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -177,6 +177,7 @@ extern const char kInstantAnimationScaleFactor[]; extern const char kInstantConfirmDialogShown[]; extern const char kInstantEnabled[]; extern const char kExperimentalZeroSuggestUrlPrefix[]; +extern const char kInstantShowSearchProviderLogo[]; extern const char kMultipleProfilePrefMigration[]; extern const char kNetworkPredictionEnabled[]; extern const char kDefaultAppsInstallState[]; |