summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-21 23:17:17 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-21 23:17:17 +0000
commit4793c9449382bbc28dc9b865b1e77177c9a2feaf (patch)
treef159eabc0862f8cfa6a6352c482674336ed3def5 /chrome/browser/chromeos
parentba463e96863261ba783e374fa7148fa263c9da4a (diff)
downloadchromium_src-4793c9449382bbc28dc9b865b1e77177c9a2feaf.zip
chromium_src-4793c9449382bbc28dc9b865b1e77177c9a2feaf.tar.gz
chromium_src-4793c9449382bbc28dc9b865b1e77177c9a2feaf.tar.bz2
Enable and disable Chat Manager component extension based on labs preference setting.
BUG=56429 TEST=unit_tests --gtest_filter=ExtensionsServiceTest.* Review URL: http://codereview.chromium.org/3120029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60123 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
-rw-r--r--chrome/browser/chromeos/dom_ui/labs_handler.cc5
-rw-r--r--chrome/browser/chromeos/preferences.cc28
-rw-r--r--chrome/browser/chromeos/preferences.h16
3 files changed, 45 insertions, 4 deletions
diff --git a/chrome/browser/chromeos/dom_ui/labs_handler.cc b/chrome/browser/chromeos/dom_ui/labs_handler.cc
index 9504d6d..19b5561 100644
--- a/chrome/browser/chromeos/dom_ui/labs_handler.cc
+++ b/chrome/browser/chromeos/dom_ui/labs_handler.cc
@@ -39,4 +39,9 @@ void LabsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_ADVANCEDFS));
localized_strings->SetString("advanced_filesystem",
l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_ADVANCEDFS_DESCRIPTION));
+
+ localized_strings->SetString("talk_title",
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_TALK));
+ localized_strings->SetString("talk",
+ l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_TALK_DESCRIPTION));
}
diff --git a/chrome/browser/chromeos/preferences.cc b/chrome/browser/chromeos/preferences.cc
index 094c94a..07d9305 100644
--- a/chrome/browser/chromeos/preferences.cc
+++ b/chrome/browser/chromeos/preferences.cc
@@ -12,8 +12,10 @@
#include "chrome/browser/chromeos/cros/keyboard_library.h"
#include "chrome/browser/chromeos/cros/touchpad_library.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
+#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/prefs/pref_member.h"
#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profile.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "unicode/timezone.h"
@@ -21,6 +23,11 @@
namespace chromeos {
static const char kFallbackInputMethodLocale[] = "en-US";
+static const char kTalkAppExtensionId[] = "ggnioahjipcehijkhpdjekioddnjoben";
+
+Preferences::Preferences(Profile* profile)
+ : profile_(profile) {
+}
// static
void Preferences::RegisterUserPrefs(PrefService* prefs) {
@@ -33,6 +40,7 @@ void Preferences::RegisterUserPrefs(PrefService* prefs) {
if (prefs->FindPreference(prefs::kAccessibilityEnabled) == NULL) {
prefs->RegisterBooleanPref(prefs::kAccessibilityEnabled, false);
}
+ prefs->RegisterIntegerPref(prefs::kLabsTalkEnabled, 0);
prefs->RegisterIntegerPref(prefs::kTouchpadSensitivity, 3);
prefs->RegisterStringPref(prefs::kLanguageCurrentInputMethod, "");
prefs->RegisterStringPref(prefs::kLanguagePreviousInputMethod, "");
@@ -171,6 +179,8 @@ void Preferences::Init(PrefService* prefs) {
language_xkb_auto_repeat_interval_pref_.Init(
prefs::kLanguageXkbAutoRepeatInterval, prefs, this);
+ labs_talk_enabled_.Init(prefs::kLabsTalkEnabled, prefs, this);
+
// Initialize touchpad settings to what's saved in user preferences.
NotifyPrefChanged(NULL);
}
@@ -327,6 +337,11 @@ void Preferences::NotifyPrefChanged(const std::string* pref_name) {
(*pref_name == prefs::kLanguageXkbAutoRepeatInterval))) {
UpdateAutoRepeatRate();
}
+
+ // Listen for explicit changes as ExtensionsService handles startup case.
+ if (pref_name && *pref_name == prefs::kLabsTalkEnabled) {
+ UpdateTalkApp();
+ }
}
void Preferences::SetLanguageConfigBoolean(const char* section,
@@ -417,4 +432,17 @@ void Preferences::UpdateAutoRepeatRate() {
CrosLibrary::Get()->GetKeyboardLibrary()->SetAutoRepeatRate(rate);
}
+void Preferences::UpdateTalkApp() {
+ if (!profile_->GetExtensionsService()->is_ready()) {
+ NOTREACHED() << "Extensions service should be ready";
+ return;
+ }
+
+ if (labs_talk_enabled_.GetValue() == 0) {
+ profile_->GetExtensionsService()->DisableExtension(kTalkAppExtensionId);
+ } else {
+ profile_->GetExtensionsService()->EnableExtension(kTalkAppExtensionId);
+ }
+}
+
} // namespace chromeos
diff --git a/chrome/browser/chromeos/preferences.h b/chrome/browser/chromeos/preferences.h
index ad0885e..2226a3a 100644
--- a/chrome/browser/chromeos/preferences.h
+++ b/chrome/browser/chromeos/preferences.h
@@ -14,6 +14,7 @@
#include "chrome/common/notification_observer.h"
class PrefService;
+class Profile;
namespace chromeos {
@@ -23,7 +24,7 @@ namespace chromeos {
// When the preferences change, we change the settings to reflect the new value.
class Preferences : public NotificationObserver {
public:
- Preferences() {}
+ explicit Preferences(Profile* profile);
virtual ~Preferences() {}
// This method will register the prefs associated with Chrome OS settings.
@@ -37,13 +38,12 @@ class Preferences : public NotificationObserver {
const NotificationSource& source,
const NotificationDetails& details);
- protected:
+ private:
// This will set the OS settings when the preference changes.
// If this method is called with NULL, it will set all OS settings to what's
// stored in the preferences.
- virtual void NotifyPrefChanged(const std::string* pref_name);
+ void NotifyPrefChanged(const std::string* pref_name);
- private:
// Writes boolean |value| to the input method (IBus) configuration daemon.
// |section| (e.g. "general") and |name| (e.g. "use_global_engine") should
// not be NULL.
@@ -83,6 +83,11 @@ class Preferences : public NotificationObserver {
// underlying XKB API requires it.
void UpdateAutoRepeatRate();
+ // Updates whether the Talk app is enabled.
+ void UpdateTalkApp();
+
+ Profile* profile_;
+
BooleanPrefMember tap_to_click_enabled_;
BooleanPrefMember vert_edge_scroll_enabled_;
BooleanPrefMember accessibility_enabled_;
@@ -121,6 +126,9 @@ class Preferences : public NotificationObserver {
IntegerPrefMember language_xkb_auto_repeat_delay_pref_;
IntegerPrefMember language_xkb_auto_repeat_interval_pref_;
+ // Labs preferences.
+ IntegerPrefMember labs_talk_enabled_;
+
DISALLOW_COPY_AND_ASSIGN(Preferences);
};