diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-12 05:05:37 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-12 05:05:37 +0000 |
commit | 2031cf9d2ebb778b9a2f76aa089a3c96ae91db72 (patch) | |
tree | b1f7a90f01c76af8e8502f189925957d89734fe8 /chrome/browser/views/options/general_page_view.cc | |
parent | c976938f96f5f9296d25cbc41d8fcea5bce74627 (diff) | |
download | chromium_src-2031cf9d2ebb778b9a2f76aa089a3c96ae91db72.zip chromium_src-2031cf9d2ebb778b9a2f76aa089a3c96ae91db72.tar.gz chromium_src-2031cf9d2ebb778b9a2f76aa089a3c96ae91db72.tar.bz2 |
Moves instant out of labs and into prefs.
BUG=58772
TEST=make sure that there is an entry in prefs for instant. See that
it works.
Review URL: http://codereview.chromium.org/3726002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views/options/general_page_view.cc')
-rw-r--r-- | chrome/browser/views/options/general_page_view.cc | 65 |
1 files changed, 64 insertions, 1 deletions
diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc index 9df25d0..b194f0f 100644 --- a/chrome/browser/views/options/general_page_view.cc +++ b/chrome/browser/views/options/general_page_view.cc @@ -11,8 +11,11 @@ #include "base/string16.h" #include "base/string_util.h" #include "base/utf_string_conversions.h" +#include "chrome/browser/browser.h" +#include "chrome/browser/browser_window.h" #include "chrome/browser/custom_home_pages_table_model.h" #include "chrome/browser/dom_ui/new_tab_ui.h" +#include "chrome/browser/instant/instant_confirm_dialog.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profile.h" @@ -208,6 +211,8 @@ GeneralPageView::GeneralPageView(Profile* profile) homepage_show_home_button_checkbox_(NULL), default_search_group_(NULL), default_search_manage_engines_button_(NULL), + instant_checkbox_(NULL), + instant_link_(NULL), default_browser_group_(NULL), default_browser_status_label_(NULL), default_browser_use_as_default_button_(NULL), @@ -281,6 +286,16 @@ void GeneralPageView::ButtonPressed( UserMetricsRecordAction(UserMetricsAction("Options_ManageSearchEngines"), NULL); KeywordEditorView::Show(profile()); + } else if (sender == instant_checkbox_) { + if (instant_checkbox_->checked()) { + // Don't toggle immediately, instead let + // ShowInstantConfirmDialogIfNecessary do it. + instant_checkbox_->SetChecked(false); + browser::ShowInstantConfirmDialogIfNecessary( + GetWindow()->GetNativeWindow(), profile()); + } else { + profile()->GetPrefs()->SetBoolean(prefs::kInstantEnabled, false); + } } } @@ -357,6 +372,7 @@ void GeneralPageView::InitControlLayout() { registrar_.Init(profile()->GetPrefs()); registrar_.Add(prefs::kRestoreOnStartup, this); registrar_.Add(prefs::kURLsToRestoreOnStartup, this); + registrar_.Add(prefs::kInstantEnabled, this); new_tab_page_is_home_page_.Init(prefs::kHomePageIsNewTabPage, profile()->GetPrefs(), this); @@ -365,10 +381,10 @@ void GeneralPageView::InitControlLayout() { } void GeneralPageView::NotifyPrefChanged(const std::string* pref_name) { + PrefService* prefs = profile()->GetPrefs(); if (!pref_name || *pref_name == prefs::kRestoreOnStartup || *pref_name == prefs::kURLsToRestoreOnStartup) { - PrefService* prefs = profile()->GetPrefs(); const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref(prefs); bool radio_buttons_enabled = !SessionStartupPref::TypeIsManaged(prefs); @@ -423,6 +439,9 @@ void GeneralPageView::NotifyPrefChanged(const std::string* pref_name) { homepage_show_home_button_checkbox_->SetEnabled( !show_home_button_.IsManaged()); } + + if (!pref_name || *pref_name == prefs::kInstantEnabled) + instant_checkbox_->SetChecked(prefs->GetBoolean(prefs::kInstantEnabled)); } void GeneralPageView::HighlightGroup(OptionsGroup highlight_group) { @@ -430,6 +449,16 @@ void GeneralPageView::HighlightGroup(OptionsGroup highlight_group) { default_search_group_->SetHighlighted(true); } +void GeneralPageView::LinkActivated(views::Link* source, int event_flags) { + DCHECK(source == instant_link_); + // We open a new browser window so the Options dialog doesn't get lost behind + // other windows. + Browser* browser = Browser::Create(profile()); + browser->OpenURL(GURL(browser::kInstantLearnMoreURL), + GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK); + browser->window()->Show(); +} + /////////////////////////////////////////////////////////////////////////////// // GeneralPageView, private: @@ -627,6 +656,15 @@ void GeneralPageView::InitDefaultSearchGroup() { this, l10n_util::GetString(IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES_LINK)); + instant_checkbox_ = new views::Checkbox( + l10n_util::GetString(IDS_INSTANT_PREF)); + instant_checkbox_->SetMultiLine(true); + instant_checkbox_->set_listener(this); + + instant_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE)); + instant_link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); + instant_link_->SetController(this); + using views::GridLayout; using views::ColumnSet; @@ -642,9 +680,34 @@ void GeneralPageView::InitDefaultSearchGroup() { column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, GridLayout::USE_PREF, 0, 0); + const int single_column_view_set_id = 1; + column_set = layout->AddColumnSet(single_column_view_set_id); + column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, + GridLayout::USE_PREF, 0, 0); + + const int link_column_set_id = 2; + column_set = layout->AddColumnSet(link_column_set_id); + // TODO(sky): this isn't right, we need a method to determine real indent. + column_set->AddPaddingColumn(0, views::Checkbox::GetTextIndent() + 3); + column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, + GridLayout::USE_PREF, 0, 0); + column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); + column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, + GridLayout::USE_PREF, 0, 0); + layout->StartRow(0, double_column_view_set_id); layout->AddView(default_search_engine_combobox_); layout->AddView(default_search_manage_engines_button_); + layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); + + layout->StartRow(0, single_column_view_set_id); + layout->AddView(instant_checkbox_); + layout->AddPaddingRow(0, 0); + + layout->StartRow(0, link_column_set_id); + layout->AddView( + new views::Label(l10n_util::GetString(IDS_INSTANT_PREF_WARNING))); + layout->AddView(instant_link_); default_search_group_ = new OptionsGroupView( contents, l10n_util::GetString(IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME), |