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 | |
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
-rw-r--r-- | chrome/app/chromium_strings.grd | 3 | ||||
-rw-r--r-- | chrome/app/generated_resources.grd | 3 | ||||
-rw-r--r-- | chrome/app/google_chrome_strings.grd | 3 | ||||
-rw-r--r-- | chrome/app/resources/locale_settings.grd | 5 | ||||
-rw-r--r-- | chrome/browser/options_util.cc | 1 | ||||
-rw-r--r-- | chrome/browser/views/options/advanced_contents_view.cc | 88 |
6 files changed, 103 insertions, 0 deletions
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index 9e4e793..c65b53c 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -386,6 +386,9 @@ be available for now. --> Chromium installation directory seems to be in use. Please reboot your computer and try again. </message> <!-- Options Dialog --> + <message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_CHROME_APPS" desc="The title text in the options panel that provides options for installed web apps."> + Chromium Web Apps + </message> <message name="IDS_OPTIONS_DISABLE_SERVICES" desc="The text in the options panel that describes how we use web services to improve browsing experience."> Chromium may use web services to improve your browsing experience. You may optionally disable these services. </message> diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index d4f5e05f..55bc4d2 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -5588,6 +5588,9 @@ Keep your key file in a safe place. You will need it to create new versions of y </message> <!-- Options Window --> + <message name="IDS_OPTIONS_CHROME_APPS_ENABLE_BACKGROUND_MODE" desc="The label in the checkbox that enables background mode for installed web apps."> + Allow installed web apps to run in the background and launch on system start + </message> <message name="IDS_OPTIONS_DIALOG_TITLE" desc="The title of the Options dialog box"> <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> Options </message> diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index b9299f7..0867c73 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd @@ -436,6 +436,9 @@ Chrome supports. --> Google Chrome installation directory seems to be in use. Please reboot your computer and try again. </message> <!-- Options Dialog --> + <message name="IDS_OPTIONS_ADVANCED_SECTION_TITLE_CHROME_APPS" desc="The title text in the options panel that provides options for installed web apps."> + Google Chrome Web Apps + </message> <message name="IDS_OPTIONS_DISABLE_SERVICES" desc="The text in the options panel that describes how we use web services to improve browsing experience."> Google Chrome may use web services to improve your browsing experience. You may optionally disable these services. </message> diff --git a/chrome/app/resources/locale_settings.grd b/chrome/app/resources/locale_settings.grd index a6cc77e..237462a 100644 --- a/chrome/app/resources/locale_settings.grd +++ b/chrome/app/resources/locale_settings.grd @@ -517,6 +517,11 @@ http://www.google.com/support/chrome/bin/answer.py?answer=114836&hl=[GRITLANGCODE] </message> + <!-- The URL for the "Learn more" page for the Chrome Web Apps section under Options.--> + <message name="IDS_LEARN_MORE_BACKGROUND_MODE_URL" translateable="false"> + http://www.google.com/support/chrome/bin/answer.py?answer=188022&hl=[GRITLANGCODE] + </message> + <!-- The URL for the "Learn more" page for the usage/crash reporting option in the first run dialog. --> <message name="IDS_LEARN_MORE_REPORTING_URL" translateable="false"> http://www.google.com/support/chrome/bin/answer.py?answer=96817&hl=[GRITLANGCODE] diff --git a/chrome/browser/options_util.cc b/chrome/browser/options_util.cc index fa9a229..88f142c 100644 --- a/chrome/browser/options_util.cc +++ b/chrome/browser/options_util.cc @@ -24,6 +24,7 @@ void OptionsUtil::ResetToDefaults(Profile* profile) { const char* kUserPrefs[] = { prefs::kAcceptLanguages, prefs::kAlternateErrorPagesEnabled, + prefs::kBackgroundModeEnabled, prefs::kClearSiteDataOnExit, prefs::kCookieBehavior, prefs::kDefaultCharset, 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())); } //////////////////////////////////////////////////////////////////////////////// |