summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/browser_resources.grd1
-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
-rw-r--r--chrome/browser/extensions/extensions_service.cc1
-rw-r--r--chrome/browser/extensions/extensions_service.h4
-rw-r--r--chrome/browser/extensions/extensions_service_unittest.cc6
-rw-r--r--chrome/browser/profile_impl.cc14
-rw-r--r--chrome/browser/profile_impl.h6
-rw-r--r--chrome/browser/resources/options/chromeos_labs.html13
-rw-r--r--chrome/browser/resources/options/pref_ui.js28
-rw-r--r--chrome/chrome_browser.gypi27
-rw-r--r--chrome/common/pref_names.cc4
-rw-r--r--chrome/common/pref_names.h1
15 files changed, 148 insertions, 12 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 3ec1a01..465e51e 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -8373,6 +8373,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_OPTIONS_SETTINGS_SECTION_TITLE_ADVANCEDFS">
Advanced Filesystem
</message>
+ <message name="IDS_OPTIONS_SETTINGS_SECTION_TITLE_TALK">
+ Talk
+ </message>
<message name="IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION" desc="In the settings tab, the text next to the timezone combobox.">
Timezone:
</message>
@@ -8388,6 +8391,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_OPTIONS_SETTINGS_ADVANCEDFS_DESCRIPTION" desc="In the settings tab, the text next to the checkbox for the filesystem.">
Advanced Filesystem including USB/SD card support.
</message>
+ <message name="IDS_OPTIONS_SETTINGS_TALK_DESCRIPTION" desc="In the settings tab, the text next to the checkbox to turn on Talk.">
+ Use Google Talk to chat across browser tabs.
+ </message>
<message name="IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION" desc="In the settings tab, the text next to the checkbox for accessbility.">
Enable Accessibility
</message>
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index e3ecfd3..52c3714 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -74,6 +74,7 @@ without changes to the corresponding grd file. eadeae-->
<include name="IDR_OFFLINE_LOAD_HTML" file="resources\offline_load.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_OS_CREDITS_HTML" file="resources\about_os_credits.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_SLIDESHOW_HTML" file="resources\slideshow.html" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_TALK_APP_MANIFEST" file="resources\chat_manager\manifest.json" type="BINDATA" />
</if>
</includes>
</release>
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);
};
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 37685e8..79810c0 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -805,7 +805,6 @@ void ExtensionsService::ClearExtensionData(const GURL& extension_url) {
void ExtensionsService::EnableExtension(const std::string& extension_id) {
Extension* extension = GetExtensionByIdInternal(extension_id, false, true);
if (!extension) {
- NOTREACHED() << "Trying to enable an extension that isn't disabled.";
return;
}
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index 4efa84a..211bc8de 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -242,8 +242,8 @@ class ExtensionsService
void UninstallExtension(const std::string& extension_id,
bool external_uninstall);
- // Enable or disable an extension. The extension must be in the opposite state
- // before calling.
+ // Enable or disable an extension. No action if the extension is already
+ // enabled/disabled.
void EnableExtension(const std::string& extension_id);
void DisableExtension(const std::string& extension_id);
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index ee4d7a9..281e9cb 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -302,6 +302,12 @@ void ExtensionsServiceTestBase::InitializeExtensionsService(
browser::RegisterUserPrefs(prefs_.get());
profile_.reset(profile);
+ // TODO(scherkus): Remove this when we no longer need to have Talk
+ // component extension state as a preference http://crbug.com/56429
+ DictionaryValue* dict =
+ prefs_->GetMutableDictionary("extensions.settings");
+ dict->Remove("ggnioahjipcehijkhpdjekioddnjoben", NULL);
+
service_ = new ExtensionsService(profile_.get(),
CommandLine::ForCurrentProcess(),
prefs_.get(),
diff --git a/chrome/browser/profile_impl.cc b/chrome/browser/profile_impl.cc
index c8498d2..fb5f501 100644
--- a/chrome/browser/profile_impl.cc
+++ b/chrome/browser/profile_impl.cc
@@ -100,6 +100,10 @@
#include "chrome/browser/password_manager/password_store_x.h"
#endif
+#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/preferences.h"
+#endif
+
using base::Time;
using base::TimeDelta;
@@ -337,7 +341,8 @@ ProfileImpl::ProfileImpl(const FilePath& path)
SSLConfigServiceManager::CreateDefaultManager(this));
#if defined(OS_CHROMEOS)
- chromeos_preferences_.Init(prefs);
+ chromeos_preferences_.reset(new chromeos::Preferences(this));
+ chromeos_preferences_->Init(prefs);
#endif
pinned_tab_service_.reset(new PinnedTabService(this));
@@ -415,6 +420,13 @@ void ProfileImpl::InitExtensions() {
std::make_pair("docs_app", IDR_DOCS_APP_MANIFEST));
}
+#if defined(OS_CHROMEOS) && defined(GOOGLE_CHROME_BUILD)
+ if (Extension::AppsAreEnabled()) {
+ component_extensions.push_back(
+ std::make_pair("chat_manager", IDR_TALK_APP_MANIFEST));
+ }
+#endif
+
for (ComponentExtensionList::iterator iter = component_extensions.begin();
iter != component_extensions.end(); ++iter) {
FilePath path;
diff --git a/chrome/browser/profile_impl.h b/chrome/browser/profile_impl.h
index e378290..9331d34 100644
--- a/chrome/browser/profile_impl.h
+++ b/chrome/browser/profile_impl.h
@@ -18,7 +18,9 @@
#include "chrome/common/notification_registrar.h"
#if defined(OS_CHROMEOS)
-#include "chrome/browser/chromeos/preferences.h"
+namespace chromeos {
+class Preferences;
+}
#endif
// The default profile implementation.
@@ -242,7 +244,7 @@ class ProfileImpl : public Profile,
scoped_refptr<ChromeBlobStorageContext> blob_storage_context_;
#if defined(OS_CHROMEOS)
- chromeos::Preferences chromeos_preferences_;
+ scoped_ptr<chromeos::Preferences> chromeos_preferences_;
scoped_refptr<chromeos::ProxyConfigServiceImpl>
chromeos_proxy_config_service_impl_;
diff --git a/chrome/browser/resources/options/chromeos_labs.html b/chrome/browser/resources/options/chromeos_labs.html
index cce03b4..9288a92 100644
--- a/chrome/browser/resources/options/chromeos_labs.html
+++ b/chrome/browser/resources/options/chromeos_labs.html
@@ -24,4 +24,17 @@
</table>
</div>
</section>
+ <section>
+ <h3 i18n-content="talk_title"></h3>
+ <div class="option">
+ <table class="option-control-table">
+ <tr>
+ <td class="option-name"><label><input id="talk-check"
+ pref="extensions.settings.ggnioahjipcehijkhpdjekioddnjoben.state"
+ type="checkbox" value-type="number"><span
+ i18n-content="talk"></span></label></td>
+ </tr>
+ </table>
+ </div>
+ </section>
</div>
diff --git a/chrome/browser/resources/options/pref_ui.js b/chrome/browser/resources/options/pref_ui.js
index cdc223c..a0a656a8 100644
--- a/chrome/browser/resources/options/pref_ui.js
+++ b/chrome/browser/resources/options/pref_ui.js
@@ -25,8 +25,9 @@ cr.define('options', function() {
// Listen to pref changes.
Preferences.getInstance().addEventListener(this.pref,
function(event) {
- self.checked = (event.value && event.value['value'] != undefined) ?
+ var value = (event.value && event.value['value'] != undefined) ?
event.value['value'] : event.value;
+ self.checked = Boolean(value);
self.managed = (event.value && event.value['managed'] != undefined) ?
event.value['managed'] : false;
self.disabled = self.managed;
@@ -35,8 +36,31 @@ cr.define('options', function() {
// Listen to user events.
this.addEventListener('click',
function(e) {
- Preferences.setBooleanPref(self.pref, self.checked, self.metric);
+ switch(self.valueType) {
+ case 'number':
+ Preferences.setIntegerPref(self.pref,
+ Number(self.checked), self.metric);
+ break;
+ case 'boolean':
+ Preferences.setBooleanPref(self.pref, self.checked,
+ self.checked, self.metric);
+ break;
+ }
+ });
+
+ // Initialize options.
+ this.ownerDocument.addEventListener('DOMContentLoaded',
+ function() {
+ self.initializeValueType(self.getAttribute('value-type'));
});
+ },
+
+ /**
+ * Sets up options in checkbox element.
+ * @param {String} valueType The preference type for this checkbox.
+ */
+ initializeValueType: function(valueType) {
+ this.valueType = valueType || 'boolean';
}
};
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 636eb3b..839dc87 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -3950,6 +3950,33 @@
]
},
],
+ 'conditions': [
+ ['OS=="linux" and chromeos==1 and branding=="Chrome"',{
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)/resources/chat_manager',
+ 'files': [
+ 'browser/resources/chat_manager/background.html',
+ 'browser/resources/chat_manager/central_roster.html',
+ 'browser/resources/chat_manager/central_roster_viewer.html',
+ 'browser/resources/chat_manager/manifest.json',
+ 'browser/resources/chat_manager/128.png',
+ 'browser/resources/chat_manager/48.png',
+ 'browser/resources/chat_manager/32.png',
+ 'browser/resources/chat_manager/24.png',
+ ]
+ },
+ {
+ 'destination': '<(PRODUCT_DIR)/resources/chat_manager/js',
+ 'files': [
+ 'browser/resources/chat_manager/js/chatbridgeeventtypes.js',
+ 'browser/resources/chat_manager/js/chatbridgehook.js',
+ 'browser/resources/chat_manager/js/gmailbridgehook.js',
+ ]
+ },
+ ]
+ }]
+ ],
},
{
# Protobuf compiler / generate rule for feedback
diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc
index 78ca687..2cd9111 100644
--- a/chrome/common/pref_names.cc
+++ b/chrome/common/pref_names.cc
@@ -372,6 +372,10 @@ const char kLabsAdvancedFilesystemEnabled[] =
// A boolean pref which turns on the mediaplayer.
const char kLabsMediaplayerEnabled[] = "settings.labs.mediaplayer";
+// An integer pref which maps to the extension state for Talk.
+const char kLabsTalkEnabled[] =
+ "extensions.settings.ggnioahjipcehijkhpdjekioddnjoben.state";
+
#endif // defined(OS_CHROMEOS)
// The disabled messages in IPC logging.
diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h
index c9ea3b6..295b804 100644
--- a/chrome/common/pref_names.h
+++ b/chrome/common/pref_names.h
@@ -139,6 +139,7 @@ extern const char kLanguageXkbAutoRepeatInterval[];
extern const char kAccessibilityEnabled[];
extern const char kLabsAdvancedFilesystemEnabled[];
extern const char kLabsMediaplayerEnabled[];
+extern const char kLabsTalkEnabled[];
#endif
extern const char kIpcDisabledMessages[];
extern const char kShowHomeButton[];