diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 20:21:51 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-24 20:21:51 +0000 |
commit | 37a74c778efbf7e2c238304803a6df80e4c8a01c (patch) | |
tree | 85223354875991ffd3c124a99f1700356b28c8c8 /chrome/browser/views | |
parent | 7c76a33abeffd7bb1b1b2510ff3872c5a6bf37a7 (diff) | |
download | chromium_src-37a74c778efbf7e2c238304803a6df80e4c8a01c.zip chromium_src-37a74c778efbf7e2c238304803a6df80e4c8a01c.tar.gz chromium_src-37a74c778efbf7e2c238304803a6df80e4c8a01c.tar.bz2 |
Added prefs ui for enabling/disabling background mode on windows.
BUG=53173
TEST=none yet (will add tests when BackgroundModeManager handles prefs notifications)
Review URL: http://codereview.chromium.org/3200007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57225 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/options/advanced_contents_view.cc | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index ee7dfc9..9e84f11 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -1276,6 +1276,92 @@ void TranslateSection::NotifyPrefChanged(const std::string* pref_name) { } //////////////////////////////////////////////////////////////////////////////// +// ChromeAppsSection + +class ChromeAppsSection : public AdvancedSection, + public views::ButtonListener, + public views::LinkController { + public: + explicit ChromeAppsSection(Profile* profile); + virtual ~ChromeAppsSection() {} + + // Overridden from views::ButtonListener: + virtual void ButtonPressed(views::Button* sender, const views::Event& event); + // Overridden from views::LinkController: + virtual void LinkActivated(views::Link* source, int event_flags); + + protected: + // OptionsPageView overrides: + virtual void InitControlLayout(); + virtual void NotifyPrefChanged(const std::string* pref_name); + + private: + // Controls for this section: + views::Checkbox* enable_background_mode_checkbox_; + views::Link* learn_more_link_; + + // Preferences for this section: + BooleanPrefMember enable_background_mode_; + + DISALLOW_COPY_AND_ASSIGN(ChromeAppsSection); +}; + +ChromeAppsSection::ChromeAppsSection(Profile* profile) + : enable_background_mode_checkbox_(NULL), + learn_more_link_(NULL), + AdvancedSection(profile, l10n_util::GetString( + IDS_OPTIONS_ADVANCED_SECTION_TITLE_CHROME_APPS)) { +} + +void ChromeAppsSection::ButtonPressed( + views::Button* sender, const views::Event& event) { + DCHECK(sender == enable_background_mode_checkbox_); + bool enabled = enable_background_mode_checkbox_->checked(); + UserMetricsRecordAction(enabled ? + UserMetricsAction("Options_BackgroundMode_Enable") : + UserMetricsAction("Options_BackgroundMode_Disable"), + profile()->GetPrefs()); + enable_background_mode_.SetValue(enabled); +} + +void ChromeAppsSection::LinkActivated(views::Link* source, int event_flags) { + DCHECK(source == learn_more_link_); + Browser::Create(profile())->OpenURL( + GURL(l10n_util::GetString(IDS_LEARN_MORE_BACKGROUND_MODE_URL)), GURL(), + NEW_WINDOW, PageTransition::LINK); +} + +void ChromeAppsSection::InitControlLayout() { + AdvancedSection::InitControlLayout(); + + GridLayout* layout = new GridLayout(contents_); + contents_->SetLayoutManager(layout); + + AddIndentedColumnSet(layout, 0); + + enable_background_mode_checkbox_ = new views::Checkbox( + l10n_util::GetString(IDS_OPTIONS_CHROME_APPS_ENABLE_BACKGROUND_MODE)); + enable_background_mode_checkbox_->set_listener(this); + AddWrappingCheckboxRow(layout, enable_background_mode_checkbox_, 0, true); + + // Init member pref so we can update the controls if prefs change. + enable_background_mode_.Init(prefs::kBackgroundModeEnabled, + profile()->GetPrefs(), this); + + // Add our link to the help center page for this feature. + learn_more_link_ = new views::Link(l10n_util::GetString(IDS_LEARN_MORE)); + learn_more_link_->SetController(this); + AddLeadingControl(layout, learn_more_link_, 0, false); +} + +void ChromeAppsSection::NotifyPrefChanged(const std::string* pref_name) { + if (!pref_name || *pref_name == prefs::kBackgroundModeEnabled) { + enable_background_mode_checkbox_->SetChecked( + enable_background_mode_.GetValue()); + } +} + +//////////////////////////////////////////////////////////////////////////////// // AdvancedContentsView class AdvancedContentsView : public OptionsPageView { @@ -1372,6 +1458,8 @@ void AdvancedContentsView::InitControlLayout() { layout->AddView(new WebContentSection(profile())); layout->StartRow(0, single_column_view_set_id); layout->AddView(new SecuritySection(profile())); + layout->StartRow(0, single_column_view_set_id); + layout->AddView(new ChromeAppsSection(profile())); } //////////////////////////////////////////////////////////////////////////////// |