diff options
author | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-23 18:05:38 +0000 |
---|---|---|
committer | xiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-23 18:05:38 +0000 |
commit | ea1eba54bea492a5fb15087f83f6eaa2baedf79c (patch) | |
tree | dcf193fa10d41bbad1ebd320697a79a97637794d /chrome/browser | |
parent | c9bfe40d84ec61ebf3a4d205e6aad85175871ce2 (diff) | |
download | chromium_src-ea1eba54bea492a5fb15087f83f6eaa2baedf79c.zip chromium_src-ea1eba54bea492a5fb15087f83f6eaa2baedf79c.tar.gz chromium_src-ea1eba54bea492a5fb15087f83f6eaa2baedf79c.tar.bz2 |
Add a boolean prefs for mobile plan notification checkbox.
- Add a boolean prefs "settings.internet.mobile.show_plan_notifications";
- Hook it with the mobile plan notification checkbox on settings page;
- Update NetworkMessageObserver::OnCellularDataPlanChanged to respect
the prefs;
BUG=chromium-os:9327
TEST=Verify fix for chromium-os:9327 and mobile plan notifications could be turn on/off via the checkbox;
Review URL: http://codereview.chromium.org/5197006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67118 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
4 files changed, 34 insertions, 1 deletions
diff --git a/chrome/browser/chromeos/network_message_observer.cc b/chrome/browser/chromeos/network_message_observer.cc index b7336f6..6980eb7 100644 --- a/chrome/browser/chromeos/network_message_observer.cc +++ b/chrome/browser/chromeos/network_message_observer.cc @@ -15,13 +15,31 @@ #include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/notifications/balloon_view_host.h" #include "chrome/browser/chromeos/options/network_config_view.h" +#include "chrome/browser/prefs/pref_service.h" +#include "chrome/browser/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/views/window.h" +#include "chrome/common/pref_names.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" #include "views/window/dialog_delegate.h" #include "views/window/window.h" +namespace { + +// Returns prefs::kShowPlanNotifications in the profile of the last active +// browser. If there is no active browser, returns true. +bool ShouldShowMobilePlanNotifications() { + Browser* browser = BrowserList::GetLastActive(); + if (!browser || !browser->profile()) + return true; + + PrefService* prefs = browser->profile()->GetPrefs(); + return prefs->GetBoolean(prefs::kShowPlanNotifications); +} + +} // namespace + namespace chromeos { NetworkMessageObserver::NetworkMessageObserver(Profile* profile) @@ -193,6 +211,13 @@ void NetworkMessageObserver::OnCellularDataPlanChanged(NetworkLibrary* obj) { cellular_data_plan_name_ = new_plan_name; cellular_data_plan_type_ = new_plan_type; + bool should_show_notifications = ShouldShowMobilePlanNotifications(); + if (!should_show_notifications) { + notification_low_data_.Hide(); + notification_no_data_.Hide(); + return; + } + if (new_plan) { notification_low_data_.Hide(); notification_no_data_.Hide(); diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc index c890a9c..ce0cbf4 100644 --- a/chrome/browser/chromeos/preferences.cc +++ b/chrome/browser/chromeos/preferences.cc @@ -116,6 +116,9 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) { // Screen lock default to off. prefs->RegisterBooleanPref(prefs::kEnableScreenLock, false); + + // Mobile plan notifications default to on. + prefs->RegisterBooleanPref(prefs::kShowPlanNotifications, true); } void Preferences::Init(PrefService* prefs) { diff --git a/chrome/browser/resources/options/chromeos_internet_detail.html b/chrome/browser/resources/options/chromeos_internet_detail.html index 8f1683f..97cdf81 100644 --- a/chrome/browser/resources/options/chromeos_internet_detail.html +++ b/chrome/browser/resources/options/chromeos_internet_detail.html @@ -103,7 +103,8 @@ <section class="plan-details-info"> <div> <label class="checkbox"> - <input id="showPlanNotifications"type="checkbox"> + <input id="showPlanNotifications" type="checkbox" + pref="settings.internet.mobile.show_plan_notifications"> <span i18n-content="showPlanNotifications"></span> </label> </div> diff --git a/chrome/browser/sync/glue/synchronized_preferences.h b/chrome/browser/sync/glue/synchronized_preferences.h index 380cf81..25135fa 100644 --- a/chrome/browser/sync/glue/synchronized_preferences.h +++ b/chrome/browser/sync/glue/synchronized_preferences.h @@ -182,6 +182,10 @@ static const char* kSynchronizedPreferences[] = { // prefs::kLanguageXkbAutoRepeatDelay, // prefs::kLanguageXkbAutoRepeatEnabled, // prefs::kLanguageXkbAutoRepeatInterval, + + // Whether to show mobile plan notifications. + // Settings -> Internet -> Mobile plan details + prefs::kShowPlanNotifications, #endif }; |