diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 19:59:19 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-28 19:59:19 +0000 |
commit | a5345be658a27aed8bdd0a4b79672d4f93313922 (patch) | |
tree | 010891f75fbafb8235f56be75a47c16f6422ffd2 /chrome/browser/chromeos | |
parent | c0101a0eace40d9c29f7673f69ee1e387df7e590 (diff) | |
download | chromium_src-a5345be658a27aed8bdd0a4b79672d4f93313922.zip chromium_src-a5345be658a27aed8bdd0a4b79672d4f93313922.tar.gz chromium_src-a5345be658a27aed8bdd0a4b79672d4f93313922.tar.bz2 |
WebUI: Move chromeos/webui remaining files to ui/webui/options/chromeos directory.
BUG=76120
TEST=None
R=estade@chromium.org
Review URL: http://codereview.chromium.org/6711083
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79604 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/chromeos')
32 files changed, 0 insertions, 3342 deletions
diff --git a/chrome/browser/chromeos/webui/accounts_options_handler.cc b/chrome/browser/chromeos/webui/accounts_options_handler.cc deleted file mode 100644 index 574d028..0000000 --- a/chrome/browser/chromeos/webui/accounts_options_handler.cc +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/accounts_options_handler.h" - -#include "base/json/json_reader.h" -#include "base/memory/scoped_ptr.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/chromeos/cros_settings_names.h" -#include "chrome/browser/chromeos/login/authenticator.h" -#include "chrome/browser/chromeos/login/user_manager.h" -#include "chrome/browser/chromeos/user_cros_settings_provider.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" -#include "chrome/common/url_constants.h" -#include "content/browser/webui/web_ui_util.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -namespace chromeos { - -AccountsOptionsHandler::AccountsOptionsHandler() - : CrosOptionsPageUIHandler(new UserCrosSettingsProvider) { -} - -AccountsOptionsHandler::~AccountsOptionsHandler() { -} - -void AccountsOptionsHandler::RegisterMessages() { - DCHECK(web_ui_); - web_ui_->RegisterMessageCallback("whitelistUser", - NewCallback(this, &AccountsOptionsHandler::WhitelistUser)); - web_ui_->RegisterMessageCallback("unwhitelistUser", - NewCallback(this, &AccountsOptionsHandler::UnwhitelistUser)); - web_ui_->RegisterMessageCallback("fetchUserPictures", - NewCallback(this, &AccountsOptionsHandler::FetchUserPictures)); - web_ui_->RegisterMessageCallback("whitelistExistingUsers", - NewCallback(this, &AccountsOptionsHandler::WhitelistExistingUsers)); -} - -void AccountsOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - RegisterTitle(localized_strings, "accountsPage", - IDS_OPTIONS_ACCOUNTS_TAB_LABEL); - - localized_strings->SetString("allow_BWSI", l10n_util::GetStringUTF16( - IDS_OPTIONS_ACCOUNTS_ALLOW_BWSI_DESCRIPTION)); - localized_strings->SetString("use_whitelist",l10n_util::GetStringUTF16( - IDS_OPTIONS_ACCOUNTS_USE_WHITELIST_DESCRIPTION)); - localized_strings->SetString("show_user_on_signin",l10n_util::GetStringUTF16( - IDS_OPTIONS_ACCOUNTS_SHOW_USER_NAMES_ON_SINGIN_DESCRIPTION)); - localized_strings->SetString("username_edit_hint",l10n_util::GetStringUTF16( - IDS_OPTIONS_ACCOUNTS_USERNAME_EDIT_HINT)); - localized_strings->SetString("username_format",l10n_util::GetStringUTF16( - IDS_OPTIONS_ACCOUNTS_USERNAME_FORMAT)); - localized_strings->SetString("add_users",l10n_util::GetStringUTF16( - IDS_OPTIONS_ACCOUNTS_ADD_USERS)); - localized_strings->SetString("owner_only", l10n_util::GetStringUTF16( - IDS_OPTIONS_ACCOUNTS_OWNER_ONLY)); - localized_strings->SetString("owner_user_id", UTF8ToUTF16( - UserCrosSettingsProvider::cached_owner())); - - localized_strings->SetString("current_user_is_owner", - UserManager::Get()->current_user_is_owner() ? - ASCIIToUTF16("true") : ASCIIToUTF16("false")); - localized_strings->SetString("whitelist_is_managed", - g_browser_process->local_state()->IsManagedPreference( - kAccountsPrefUsers) ? ASCIIToUTF16("true") : ASCIIToUTF16("false")); -} - -UserCrosSettingsProvider* AccountsOptionsHandler::users_settings() const { - return static_cast<UserCrosSettingsProvider*>(settings_provider_.get()); -} - -void AccountsOptionsHandler::WhitelistUser(const ListValue* args) { - std::string email; - if (!args->GetString(0, &email)) { - return; - } - - users_settings()->WhitelistUser(Authenticator::Canonicalize(email)); -} - -void AccountsOptionsHandler::UnwhitelistUser(const ListValue* args) { - std::string email; - if (!args->GetString(0, &email)) { - return; - } - - users_settings()->UnwhitelistUser(Authenticator::Canonicalize(email)); - UserManager::Get()->RemoveUser(email, NULL); -} - -void AccountsOptionsHandler::FetchUserPictures(const ListValue* args) { - DictionaryValue user_pictures; - - UserVector users = UserManager::Get()->GetUsers(); - for (UserVector::const_iterator it = users.begin(); - it != users.end(); ++it) { - StringValue* image_url = - new StringValue(chrome::kChromeUIUserImageURL + it->email()); - // SetWithoutPathExpansion because email has "." in it. - user_pictures.SetWithoutPathExpansion(it->email(), image_url); - } - - web_ui_->CallJavascriptFunction("AccountsOptions.setUserPictures", - user_pictures); -} - -void AccountsOptionsHandler::WhitelistExistingUsers(const ListValue* args) { - ListValue whitelist_users; - - UserVector users = UserManager::Get()->GetUsers(); - for (UserVector::const_iterator it = users.begin(); - it < users.end(); ++it) { - const std::string& email = it->email(); - if (!UserCrosSettingsProvider::IsEmailInCachedWhitelist(email)) { - DictionaryValue* user_dict = new DictionaryValue; - user_dict->SetString("name", it->GetDisplayName()); - user_dict->SetString("email", email); - user_dict->SetBoolean("owner", false); - - whitelist_users.Append(user_dict); - } - } - - web_ui_->CallJavascriptFunction("AccountsOptions.addUsers", whitelist_users); -} - -void AccountsOptionsHandler::Initialize() { - DCHECK(web_ui_); - banner_handler_.reset( - new OptionsManagedBannerHandler(web_ui_, - ASCIIToUTF16("AccountsOptions"), - OPTIONS_PAGE_ACCOUNTS)); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/accounts_options_handler.h b/chrome/browser/chromeos/webui/accounts_options_handler.h deleted file mode 100644 index 9146a83..0000000 --- a/chrome/browser/chromeos/webui/accounts_options_handler.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_ACCOUNTS_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_ACCOUNTS_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/chromeos/webui/cros_options_page_ui_handler.h" - -class OptionsManagedBannerHandler; - -namespace chromeos { - -class UserCrosSettingsProvider; - -// ChromeOS accounts options page handler. -class AccountsOptionsHandler : public CrosOptionsPageUIHandler { - public: - AccountsOptionsHandler(); - virtual ~AccountsOptionsHandler(); - - // WebUIMessageHandler implementation. - virtual void RegisterMessages(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - virtual void Initialize(); - - private: - UserCrosSettingsProvider* users_settings() const; - - // Javascript callbacks to whitelist/unwhitelist user. - void WhitelistUser(const ListValue* args); - void UnwhitelistUser(const ListValue* args); - - // Javascript callback to fetch known user pictures. - void FetchUserPictures(const ListValue* args); - - // Javascript callback to auto add existing users to white list. - void WhitelistExistingUsers(const ListValue* args); - - scoped_ptr<OptionsManagedBannerHandler> banner_handler_; - - DISALLOW_COPY_AND_ASSIGN(AccountsOptionsHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_ACCOUNTS_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/core_chromeos_options_handler.cc b/chrome/browser/chromeos/webui/core_chromeos_options_handler.cc deleted file mode 100644 index 25d2c27..0000000 --- a/chrome/browser/chromeos/webui/core_chromeos_options_handler.cc +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/core_chromeos_options_handler.h" - -#include <string> - -#include "base/string_number_conversions.h" -#include "base/string_util.h" -#include "chrome/browser/chromeos/cros_settings.h" -#include "chrome/browser/metrics/user_metrics.h" -#include "content/common/notification_details.h" -#include "content/common/notification_source.h" - -namespace chromeos { - -CoreChromeOSOptionsHandler::CoreChromeOSOptionsHandler() - : handling_change_(false) { -} - -Value* CoreChromeOSOptionsHandler::FetchPref(const std::string& pref_name) { - if (!CrosSettings::IsCrosSettings(pref_name)) - return ::CoreOptionsHandler::FetchPref(pref_name); - - Value* pref_value = NULL; - CrosSettings::Get()->Get(pref_name, &pref_value); - return pref_value ? pref_value : Value::CreateNullValue(); -} - -void CoreChromeOSOptionsHandler::ObservePref(const std::string& pref_name) { - if (!CrosSettings::IsCrosSettings(pref_name)) - return ::CoreOptionsHandler::ObservePref(pref_name); - - // TODO(xiyuan): Change this when CrosSettings supports observers. - CrosSettings::Get()->AddSettingsObserver(pref_name.c_str(), this); -} - -void CoreChromeOSOptionsHandler::SetPref(const std::string& pref_name, - const Value* value, - const std::string& metric) { - if (!CrosSettings::IsCrosSettings(pref_name)) - return ::CoreOptionsHandler::SetPref(pref_name, value, metric); - handling_change_ = true; - // CrosSettings takes ownership of its value so we need to copy it. - Value* pref_value = value->DeepCopy(); - CrosSettings::Get()->Set(pref_name, pref_value); - handling_change_ = false; - - ProcessUserMetric(value, metric); -} - -void CoreChromeOSOptionsHandler::StopObservingPref(const std::string& path) { - // Unregister this instance from observing prefs of chrome os settings. - if (CrosSettings::IsCrosSettings(path)) - CrosSettings::Get()->RemoveSettingsObserver(path.c_str(), this); - else // Call base class to handle regular preferences. - ::CoreOptionsHandler::StopObservingPref(path); -} - -void CoreChromeOSOptionsHandler::Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details) { - // Ignore the notification if this instance had caused it. - if (handling_change_) - return; - if (type == NotificationType::SYSTEM_SETTING_CHANGED) { - NotifySettingsChanged(Details<std::string>(details).ptr()); - return; - } - ::CoreOptionsHandler::Observe(type, source, details); -} - -void CoreChromeOSOptionsHandler::NotifySettingsChanged( - const std::string* setting_name) { - DCHECK(web_ui_); - DCHECK(CrosSettings::Get()->IsCrosSettings(*setting_name)); - Value* value = NULL; - if (!CrosSettings::Get()->Get(*setting_name, &value)) { - NOTREACHED(); - if (value) - delete value; - return; - } - for (PreferenceCallbackMap::const_iterator iter = - pref_callback_map_.find(*setting_name); - iter != pref_callback_map_.end(); ++iter) { - const std::wstring& callback_function = iter->second; - ListValue result_value; - result_value.Append(Value::CreateStringValue(setting_name->c_str())); - result_value.Append(value->DeepCopy()); - web_ui_->CallJavascriptFunction(WideToASCII(callback_function), - result_value); - } - if (value) - delete value; -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/core_chromeos_options_handler.h b/chrome/browser/chromeos/webui/core_chromeos_options_handler.h deleted file mode 100644 index a87b219..0000000 --- a/chrome/browser/chromeos/webui/core_chromeos_options_handler.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_CORE_CHROMEOS_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_CORE_CHROMEOS_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/ui/webui/options/core_options_handler.h" - -namespace chromeos { - -// CoreChromeOSOptionsHandler handles ChromeOS settings. -class CoreChromeOSOptionsHandler : public CoreOptionsHandler { - public: - CoreChromeOSOptionsHandler(); - - protected: - // ::CoreOptionsHandler overrides - virtual Value* FetchPref(const std::string& pref_name); - virtual void ObservePref(const std::string& pref_name); - virtual void SetPref(const std::string& pref_name, - const Value* value, - const std::string& metric); - virtual void StopObservingPref(const std::string& path); - - // NotificationObserver implementation. - virtual void Observe(NotificationType type, - const NotificationSource& source, - const NotificationDetails& details); - - private: - // Notifies registered JS callbacks on ChromeOS setting change. - void NotifySettingsChanged(const std::string* setting_name); - - // Keeps the track of change caused by the handler to make sure - // it does not signal itself again. - bool handling_change_; -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_CORE_CHROMEOS_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/cros_language_options_handler.cc b/chrome/browser/chromeos/webui/cros_language_options_handler.cc deleted file mode 100644 index 8ccb0dd..0000000 --- a/chrome/browser/chromeos/webui/cros_language_options_handler.cc +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/cros_language_options_handler.h" - -#include <map> -#include <set> -#include <vector> - -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/metrics/user_metrics.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/chromeos/cros/input_method_library.h" - -namespace chromeos { - -CrosLanguageOptionsHandler::CrosLanguageOptionsHandler() { -} - -CrosLanguageOptionsHandler::~CrosLanguageOptionsHandler() { -} - -void CrosLanguageOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - LanguageOptionsHandlerCommon::GetLocalizedValues(localized_strings); - - localized_strings->SetString("ok_button", l10n_util::GetStringUTF16(IDS_OK)); - localized_strings->SetString("configure", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CONFIGURE)); - localized_strings->SetString("input_method", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD)); - localized_strings->SetString("please_add_another_input_method", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_PLEASE_ADD_ANOTHER_INPUT_METHOD)); - localized_strings->SetString("input_method_instructions", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_INPUT_METHOD_INSTRUCTIONS)); - localized_strings->SetString("switch_input_methods_hint", - l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_SWITCH_INPUT_METHODS_HINT, - ASCIIToUTF16("alt+shift"))); - localized_strings->SetString("select_previous_input_method_hint", - l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_SELECT_PREVIOUS_INPUT_METHOD_HINT, - ASCIIToUTF16("ctrl+space"))); - localized_strings->SetString("restart_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_SIGN_OUT_BUTTON)); - - // GetSupportedInputMethods() never return NULL. - InputMethodLibrary *im_library = - CrosLibrary::Get()->GetInputMethodLibrary(); - scoped_ptr<chromeos::InputMethodDescriptors> descriptors( - im_library->GetSupportedInputMethods()); - localized_strings->Set("languageList", GetLanguageList(*descriptors)); - localized_strings->Set("inputMethodList", GetInputMethodList(*descriptors)); -} - -void CrosLanguageOptionsHandler::RegisterMessages() { - LanguageOptionsHandlerCommon::RegisterMessages(); - - web_ui_->RegisterMessageCallback("inputMethodDisable", - NewCallback(this, - &CrosLanguageOptionsHandler::InputMethodDisableCallback)); - web_ui_->RegisterMessageCallback("inputMethodEnable", - NewCallback(this, - &CrosLanguageOptionsHandler::InputMethodEnableCallback)); - web_ui_->RegisterMessageCallback("inputMethodOptionsOpen", - NewCallback(this, - &CrosLanguageOptionsHandler::InputMethodOptionsOpenCallback)); - web_ui_->RegisterMessageCallback("uiLanguageRestart", - NewCallback(this, &CrosLanguageOptionsHandler::RestartCallback)); -} - -ListValue* CrosLanguageOptionsHandler::GetInputMethodList( - const chromeos::InputMethodDescriptors& descriptors) { - ListValue* input_method_list = new ListValue(); - - for (size_t i = 0; i < descriptors.size(); ++i) { - const chromeos::InputMethodDescriptor& descriptor = descriptors[i]; - const std::string language_code = - chromeos::input_method::GetLanguageCodeFromDescriptor(descriptor); - const std::string display_name = - chromeos::input_method::GetInputMethodDisplayNameFromId(descriptor.id); - - DictionaryValue* dictionary = new DictionaryValue(); - dictionary->SetString("id", descriptor.id); - dictionary->SetString("displayName", display_name); - - // One input method can be associated with multiple languages, hence - // we use a dictionary here. - DictionaryValue* language_codes = new DictionaryValue(); - language_codes->SetBoolean(language_code, true); - // Check kExtraLanguages to see if there are languages associated with - // this input method. If these are present, add these. - for (size_t j = 0; j < arraysize(chromeos::input_method::kExtraLanguages); - ++j) { - const std::string extra_input_method_id = - chromeos::input_method::kExtraLanguages[j].input_method_id; - const std::string extra_language_code = - chromeos::input_method::kExtraLanguages[j].language_code; - if (extra_input_method_id == descriptor.id) { - language_codes->SetBoolean(extra_language_code, true); - } - } - dictionary->Set("languageCodeSet", language_codes); - - input_method_list->Append(dictionary); - } - - return input_method_list; -} - -ListValue* CrosLanguageOptionsHandler::GetLanguageList( - const chromeos::InputMethodDescriptors& descriptors) { - std::set<std::string> language_codes; - // Collect the language codes from the supported input methods. - for (size_t i = 0; i < descriptors.size(); ++i) { - const chromeos::InputMethodDescriptor& descriptor = descriptors[i]; - const std::string language_code = - chromeos::input_method::GetLanguageCodeFromDescriptor(descriptor); - language_codes.insert(language_code); - } - // Collect the language codes from kExtraLanguages. - for (size_t i = 0; i < arraysize(chromeos::input_method::kExtraLanguages); - ++i) { - const char* language_code = - chromeos::input_method::kExtraLanguages[i].language_code; - language_codes.insert(language_code); - } - - // Map of display name -> {language code, native_display_name}. - // In theory, we should be able to create a map that is sorted by - // display names using ICU comparator, but doing it is hard, thus we'll - // use an auxiliary vector to achieve the same result. - typedef std::pair<std::string, string16> LanguagePair; - typedef std::map<string16, LanguagePair> LanguageMap; - LanguageMap language_map; - // The auxiliary vector mentioned above. - std::vector<string16> display_names; - - // Build the list of display names, and build the language map. - for (std::set<std::string>::const_iterator iter = language_codes.begin(); - iter != language_codes.end(); ++iter) { - const string16 display_name = - chromeos::input_method::GetLanguageDisplayNameFromCode(*iter); - const string16 native_display_name = - chromeos::input_method::GetLanguageNativeDisplayNameFromCode(*iter); - display_names.push_back(display_name); - language_map[display_name] = - std::make_pair(*iter, native_display_name); - } - DCHECK_EQ(display_names.size(), language_map.size()); - - // Sort display names using locale specific sorter. - l10n_util::SortStrings16(g_browser_process->GetApplicationLocale(), - &display_names); - - // Build the language list from the language map. - ListValue* language_list = new ListValue(); - for (size_t i = 0; i < display_names.size(); ++i) { - const LanguagePair& pair = language_map[display_names[i]]; - DictionaryValue* dictionary = new DictionaryValue(); - dictionary->SetString("code", pair.first); - dictionary->SetString("displayName", display_names[i]); - dictionary->SetString("nativeDisplayName", pair.second); - language_list->Append(dictionary); - } - - return language_list; -} - -string16 CrosLanguageOptionsHandler::GetProductName() { - return l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); -} - -void CrosLanguageOptionsHandler::SetApplicationLocale( - const std::string& language_code) { - web_ui_->GetProfile()->ChangeAppLocale( - language_code, Profile::APP_LOCALE_CHANGED_VIA_SETTINGS); -} - -void CrosLanguageOptionsHandler::RestartCallback(const ListValue* args) { - UserMetrics::RecordAction(UserMetricsAction("LanguageOptions_SignOut")); - - Browser* browser = Browser::GetBrowserForController( - &web_ui_->tab_contents()->controller(), NULL); - if (browser) - browser->ExecuteCommand(IDC_EXIT); -} - -void CrosLanguageOptionsHandler::InputMethodDisableCallback( - const ListValue* args) { - const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args)); - const std::string action = StringPrintf( - "LanguageOptions_DisableInputMethod_%s", input_method_id.c_str()); - UserMetrics::RecordComputedAction(action); -} - -void CrosLanguageOptionsHandler::InputMethodEnableCallback( - const ListValue* args) { - const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args)); - const std::string action = StringPrintf( - "LanguageOptions_EnableInputMethod_%s", input_method_id.c_str()); - UserMetrics::RecordComputedAction(action); -} - -void CrosLanguageOptionsHandler::InputMethodOptionsOpenCallback( - const ListValue* args) { - const std::string input_method_id = UTF16ToASCII(ExtractStringValue(args)); - const std::string action = StringPrintf( - "InputMethodOptions_Open_%s", input_method_id.c_str()); - UserMetrics::RecordComputedAction(action); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/cros_language_options_handler.h b/chrome/browser/chromeos/webui/cros_language_options_handler.h deleted file mode 100644 index d5cf885..0000000 --- a/chrome/browser/chromeos/webui/cros_language_options_handler.h +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_CROS_LANGUAGE_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_CROS_LANGUAGE_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/chromeos/input_method/input_method_util.h" -#include "chrome/browser/ui/webui/options/language_options_handler.h" - -namespace chromeos { - -// Language options page UI handler for Chrome OS. For non-Chrome OS, -// see LanguageOptionsHnadler. -class CrosLanguageOptionsHandler : public LanguageOptionsHandlerCommon { - public: - CrosLanguageOptionsHandler(); - virtual ~CrosLanguageOptionsHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - - // DOMMessageHandler implementation. - virtual void RegisterMessages(); - - // The following static methods are public for ease of testing. - - // Gets the list of input methods from the given input descriptors. - // The return value will look like: - // [{'id': 'pinyin', 'displayName': 'Pinyin', - // 'languageCodeSet': {'zh-CW': true}}, ...] - // - // Note that true in languageCodeSet does not mean anything. We just use - // the dictionary as a set. - static ListValue* GetInputMethodList( - const chromeos::InputMethodDescriptors& descriptors); - - // Gets the list of languages from the given input descriptors. - // The return value will look like: - // [{'code': 'fi', 'displayName': 'Finnish', 'nativeDisplayName': 'suomi'}, - // ...] - static ListValue* GetLanguageList( - const chromeos::InputMethodDescriptors& descriptors); - - private: - // LanguageOptionsHandlerCommon implementation. - virtual string16 GetProductName(); - virtual void SetApplicationLocale(const std::string& language_code); - - // Called when the sign-out button is clicked. - void RestartCallback(const ListValue* args); - - // Called when the input method is disabled. - // |args| will contain the input method ID as string (ex. "mozc"). - void InputMethodDisableCallback(const ListValue* args); - - // Called when the input method is enabled. - // |args| will contain the input method ID as string (ex. "mozc"). - void InputMethodEnableCallback(const ListValue* args); - - // Called when the input method options page is opened. - // |args| will contain the input method ID as string (ex. "mozc"). - void InputMethodOptionsOpenCallback(const ListValue* args); - - DISALLOW_COPY_AND_ASSIGN(CrosLanguageOptionsHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_CROS_LANGUAGE_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/cros_options_page_ui_handler.cc b/chrome/browser/chromeos/webui/cros_options_page_ui_handler.cc deleted file mode 100644 index 348669be..0000000 --- a/chrome/browser/chromeos/webui/cros_options_page_ui_handler.cc +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/cros_options_page_ui_handler.h" - -#include "base/values.h" -#include "chrome/browser/chromeos/cros_settings.h" - -namespace chromeos { - -CrosOptionsPageUIHandler::CrosOptionsPageUIHandler( - CrosSettingsProvider* provider) : settings_provider_(provider) { - if (settings_provider_.get()) - CrosSettings::Get()->AddSettingsProvider(settings_provider_.get()); -} - -CrosOptionsPageUIHandler::~CrosOptionsPageUIHandler() { - if (settings_provider_.get()) - CrosSettings::Get()->RemoveSettingsProvider(settings_provider_.get()); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/cros_options_page_ui_handler.h b/chrome/browser/chromeos/webui/cros_options_page_ui_handler.h deleted file mode 100644 index 92c0982..0000000 --- a/chrome/browser/chromeos/webui/cros_options_page_ui_handler.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_CROS_OPTIONS_PAGE_UI_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_CROS_OPTIONS_PAGE_UI_HANDLER_H_ -#pragma once - -#include "chrome/browser/chromeos/cros_settings_provider.h" -#include "chrome/browser/ui/webui/options/options_ui.h" - -namespace chromeos { - -// The base class handler of Javascript messages of options pages. -class CrosOptionsPageUIHandler : public OptionsPageUIHandler { - public: - explicit CrosOptionsPageUIHandler(CrosSettingsProvider* provider); - virtual ~CrosOptionsPageUIHandler(); - - protected: - scoped_ptr<CrosSettingsProvider> settings_provider_; - - private: - DISALLOW_COPY_AND_ASSIGN(CrosOptionsPageUIHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_CROS_OPTIONS_PAGE_UI_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/internet_options_handler.cc b/chrome/browser/chromeos/webui/internet_options_handler.cc deleted file mode 100644 index 3318bcf..0000000 --- a/chrome/browser/chromeos/webui/internet_options_handler.cc +++ /dev/null @@ -1,1094 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/internet_options_handler.h" - -#include <ctype.h> - -#include <map> -#include <string> -#include <vector> - -#include "base/base64.h" -#include "base/basictypes.h" -#include "base/callback.h" -#include "base/i18n/time_formatting.h" -#include "base/string16.h" -#include "base/string_number_conversions.h" -#include "base/time.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/browser_list.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/browser_window.h" -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/chromeos/login/user_manager.h" -#include "chrome/browser/chromeos/status/network_menu.h" -#include "chrome/browser/chromeos/user_cros_settings_provider.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/views/window.h" -#include "chrome/common/pref_names.h" -#include "chrome/common/time_format.h" -#include "content/browser/webui/web_ui_util.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#include "grit/locale_settings.h" -#include "grit/theme_resources.h" -#include "third_party/skia/include/core/SkBitmap.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "views/window/window.h" - -static const char kOtherNetworksFakePath[] = "?"; - -namespace { - -// Format the hardware address like "0011AA22BB33" => "00:11:AA:22:BB:33". -std::string FormatHardwareAddress(const std::string& address) { - std::string output; - for (size_t i = 0; i < address.size(); ++i) { - if (i != 0 && i % 2 == 0) { - output.push_back(':'); - } - output.push_back(toupper(address[i])); - } - return output; -} - -} // namespace - -InternetOptionsHandler::InternetOptionsHandler() - : chromeos::CrosOptionsPageUIHandler( - new chromeos::UserCrosSettingsProvider), - use_settings_ui_(false) { - chromeos::NetworkLibrary* netlib = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - netlib->AddNetworkManagerObserver(this); - netlib->AddCellularDataPlanObserver(this); - MonitorNetworks(netlib); -} - -InternetOptionsHandler::~InternetOptionsHandler() { - chromeos::NetworkLibrary *netlib = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - netlib->RemoveNetworkManagerObserver(this); - netlib->RemoveCellularDataPlanObserver(this); - netlib->RemoveObserverForAllNetworks(this); -} - -void InternetOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - RegisterTitle(localized_strings, "internetPage", - IDS_OPTIONS_INTERNET_TAB_LABEL); - - localized_strings->SetString("wired_title", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIRED_NETWORK)); - localized_strings->SetString("wireless_title", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_SECTION_TITLE_WIRELESS_NETWORK)); - localized_strings->SetString("remembered_title", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_SECTION_TITLE_REMEMBERED_NETWORK)); - - localized_strings->SetString("connect_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_CONNECT)); - localized_strings->SetString("disconnect_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_DISCONNECT)); - localized_strings->SetString("options_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_OPTIONS)); - localized_strings->SetString("forget_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_FORGET)); - localized_strings->SetString("activate_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_ACTIVATE)); - localized_strings->SetString("buyplan_button", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_BUY_PLAN)); - - localized_strings->SetString("wifiNetworkTabLabel", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_TAB_WIFI)); - localized_strings->SetString("cellularPlanTabLabel", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_TAB_PLAN)); - localized_strings->SetString("cellularConnTabLabel", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_TAB_CONNECTION)); - localized_strings->SetString("cellularDeviceTabLabel", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_TAB_DEVICE)); - localized_strings->SetString("networkTabLabel", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_TAB_NETWORK)); - - localized_strings->SetString("connectionState", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CONNECTION_STATE)); - localized_strings->SetString("inetAddress", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_ADDRESS)); - localized_strings->SetString("inetSubnetAddress", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SUBNETMASK)); - localized_strings->SetString("inetGateway", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_GATEWAY)); - localized_strings->SetString("inetDns", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_DNSSERVER)); - localized_strings->SetString("hardwareAddress", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_HARDWARE_ADDRESS)); - - localized_strings->SetString("accessLockedMsg", - l10n_util::GetStringUTF16( - IDS_STATUSBAR_NETWORK_LOCKED)); - localized_strings->SetString("inetSsid", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NETWORK_ID)); - localized_strings->SetString("inetIdent", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_IDENTITY)); - localized_strings->SetString("inetCert", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT)); - localized_strings->SetString("inetCertPass", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PRIVATE_KEY_PASSWORD)); - localized_strings->SetString("inetPassProtected", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NET_PROTECTED)); - localized_strings->SetString("inetAutoConnectNetwork", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); - localized_strings->SetString("inetCertPkcs", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CERT_INSTALLED)); - localized_strings->SetString("inetLogin", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOGIN)); - localized_strings->SetString("inetShowPass", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHOWPASSWORD)); - localized_strings->SetString("inetSecurityNone", - l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT, - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_NONE))); - localized_strings->SetString("inetSecurityWEP", - l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT, - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WEP))); - localized_strings->SetString("inetSecurityWPA", - l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT, - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_WPA))); - localized_strings->SetString("inetSecurityRSN", - l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_SELECT, - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SECURITY_RSN))); - localized_strings->SetString("inetPassPrompt", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PASSWORD)); - localized_strings->SetString("inetSsidPrompt", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SSID)); - localized_strings->SetString("inetStatus", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_STATUS_TITLE)); - localized_strings->SetString("inetConnect", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CONNECT_TITLE)); - - localized_strings->SetString("serviceName", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_SERVICE_NAME)); - localized_strings->SetString("networkTechnology", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_NETWORK_TECHNOLOGY)); - localized_strings->SetString("operatorName", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_OPERATOR)); - localized_strings->SetString("operatorCode", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_OPERATOR_CODE)); - localized_strings->SetString("activationState", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ACTIVATION_STATE)); - localized_strings->SetString("roamingState", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ROAMING_STATE)); - localized_strings->SetString("restrictedPool", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_RESTRICTED_POOL)); - localized_strings->SetString("errorState", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_ERROR_STATE)); - localized_strings->SetString("manufacturer", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_MANUFACTURER)); - localized_strings->SetString("modelId", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_MODEL_ID)); - localized_strings->SetString("firmwareRevision", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_FIRMWARE_REVISION)); - localized_strings->SetString("hardwareRevision", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_HARDWARE_REVISION)); - localized_strings->SetString("lastUpdate", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_LAST_UPDATE)); - localized_strings->SetString("prlVersion", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELLULAR_PRL_VERSION)); - - localized_strings->SetString("planName", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CELL_PLAN_NAME)); - localized_strings->SetString("planLoading", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_LOADING_PLAN)); - localized_strings->SetString("noPlansFound", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_NO_PLANS_FOUND)); - localized_strings->SetString("purchaseMore", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_PURCHASE_MORE)); - localized_strings->SetString("dataRemaining", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_DATA_REMAINING)); - localized_strings->SetString("planExpires", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_EXPIRES)); - localized_strings->SetString("showPlanNotifications", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_SHOW_MOBILE_NOTIFICATION)); - localized_strings->SetString("autoconnectCellular", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_AUTO_CONNECT)); - localized_strings->SetString("customerSupport", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_OPTIONS_CUSTOMER_SUPPORT)); - - localized_strings->SetString("enableWifi", - l10n_util::GetStringFUTF16( - IDS_STATUSBAR_NETWORK_DEVICE_ENABLE, - l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_WIFI))); - localized_strings->SetString("disableWifi", - l10n_util::GetStringFUTF16( - IDS_STATUSBAR_NETWORK_DEVICE_DISABLE, - l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_WIFI))); - localized_strings->SetString("enableCellular", - l10n_util::GetStringFUTF16( - IDS_STATUSBAR_NETWORK_DEVICE_ENABLE, - l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR))); - localized_strings->SetString("disableCellular", - l10n_util::GetStringFUTF16( - IDS_STATUSBAR_NETWORK_DEVICE_DISABLE, - l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR))); - localized_strings->SetString("enableDataRoaming", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_ENABLE_DATA_ROAMING)); - localized_strings->SetString("generalNetworkingTitle", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_INTERNET_CONTROL_TITLE)); - localized_strings->SetString("detailsInternetDismiss", - l10n_util::GetStringUTF16(IDS_CLOSE)); - localized_strings->SetString("ownerOnly", l10n_util::GetStringUTF16( - IDS_OPTIONS_ACCOUNTS_OWNER_ONLY)); - localized_strings->SetString("ownerUserId", UTF8ToUTF16( - chromeos::UserCrosSettingsProvider::cached_owner())); - - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - FillNetworkInfo(localized_strings, cros); - - localized_strings->SetBoolean("networkUseSettingsUI", use_settings_ui_); -} - -void InternetOptionsHandler::Initialize() { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - cros->RequestNetworkScan(); -} - -void InternetOptionsHandler::RegisterMessages() { - // Setup handlers specific to this panel. - DCHECK(web_ui_); - web_ui_->RegisterMessageCallback("buttonClickCallback", - NewCallback(this, &InternetOptionsHandler::ButtonClickCallback)); - web_ui_->RegisterMessageCallback("refreshCellularPlan", - NewCallback(this, &InternetOptionsHandler::RefreshCellularPlanCallback)); - web_ui_->RegisterMessageCallback("loginToNetwork", - NewCallback(this, &InternetOptionsHandler::LoginCallback)); - web_ui_->RegisterMessageCallback("loginToCertNetwork", - NewCallback(this, &InternetOptionsHandler::LoginCertCallback)); - web_ui_->RegisterMessageCallback("loginToOtherNetwork", - NewCallback(this, &InternetOptionsHandler::LoginToOtherCallback)); - web_ui_->RegisterMessageCallback("setDetails", - NewCallback(this, &InternetOptionsHandler::SetDetailsCallback)); - web_ui_->RegisterMessageCallback("enableWifi", - NewCallback(this, &InternetOptionsHandler::EnableWifiCallback)); - web_ui_->RegisterMessageCallback("disableWifi", - NewCallback(this, &InternetOptionsHandler::DisableWifiCallback)); - web_ui_->RegisterMessageCallback("enableCellular", - NewCallback(this, &InternetOptionsHandler::EnableCellularCallback)); - web_ui_->RegisterMessageCallback("disableCellular", - NewCallback(this, &InternetOptionsHandler::DisableCellularCallback)); - web_ui_->RegisterMessageCallback("buyDataPlan", - NewCallback(this, &InternetOptionsHandler::BuyDataPlanCallback)); - web_ui_->RegisterMessageCallback("showMorePlanInfo", - NewCallback(this, &InternetOptionsHandler::BuyDataPlanCallback)); -} - -void InternetOptionsHandler::EnableWifiCallback(const ListValue* args) { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - cros->EnableWifiNetworkDevice(true); -} - -void InternetOptionsHandler::DisableWifiCallback(const ListValue* args) { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - cros->EnableWifiNetworkDevice(false); -} - -void InternetOptionsHandler::EnableCellularCallback(const ListValue* args) { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - cros->EnableCellularNetworkDevice(true); -} - -void InternetOptionsHandler::DisableCellularCallback(const ListValue* args) { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - cros->EnableCellularNetworkDevice(false); -} - -void InternetOptionsHandler::BuyDataPlanCallback(const ListValue* args) { - if (!web_ui_) - return; - Browser* browser = BrowserList::FindBrowserWithFeature( - web_ui_->GetProfile(), Browser::FEATURE_TABSTRIP); - if (browser) - browser->OpenMobilePlanTabAndActivate(); -} - -void InternetOptionsHandler::RefreshNetworkData( - chromeos::NetworkLibrary* cros) { - DictionaryValue dictionary; - FillNetworkInfo(&dictionary, cros); - web_ui_->CallJavascriptFunction( - "options.InternetOptions.refreshNetworkData", dictionary); -} - -void InternetOptionsHandler::OnNetworkManagerChanged( - chromeos::NetworkLibrary* cros) { - if (!web_ui_) - return; - MonitorNetworks(cros); - RefreshNetworkData(cros); -} - -void InternetOptionsHandler::OnNetworkChanged( - chromeos::NetworkLibrary* cros, - const chromeos::Network* network) { - if (web_ui_) - RefreshNetworkData(cros); -} - -// Monitor wireless networks for changes. It is only necessary -// to set up individual observers for the cellular networks -// (if any) and for the connected Wi-Fi network (if any). The -// only change we are interested in for Wi-Fi networks is signal -// strength. For non-connected Wi-Fi networks, all information is -// reported via scan results, which trigger network manager -// updates. Only the connected Wi-Fi network has changes reported -// via service property updates. -void InternetOptionsHandler::MonitorNetworks(chromeos::NetworkLibrary* cros) { - cros->RemoveObserverForAllNetworks(this); - const chromeos::WifiNetwork* wifi_network = cros->wifi_network(); - if (wifi_network != NULL) - cros->AddNetworkObserver(wifi_network->service_path(), this); - // Always monitor the cellular networks, if any, so that changes - // in network technology, roaming status, and signal strength - // will be shown. - const chromeos::CellularNetworkVector& cell_networks = - cros->cellular_networks(); - for (size_t i = 0; i < cell_networks.size(); ++i) { - chromeos::CellularNetwork* cell_network = cell_networks[i]; - cros->AddNetworkObserver(cell_network->service_path(), this); - } -} - -void InternetOptionsHandler::OnCellularDataPlanChanged( - chromeos::NetworkLibrary* cros) { - if (!web_ui_) - return; - const chromeos::CellularNetwork* cellular = cros->cellular_network(); - if (!cellular) - return; - const chromeos::CellularDataPlanVector* plans = - cros->GetDataPlans(cellular->service_path()); - DictionaryValue connection_plans; - ListValue* plan_list = new ListValue(); - if (plans) { - for (chromeos::CellularDataPlanVector::const_iterator iter = plans->begin(); - iter != plans->end(); ++iter) { - plan_list->Append(CellularDataPlanToDictionary(*iter)); - } - } - connection_plans.SetString("servicePath", cellular->service_path()); - connection_plans.SetBoolean("needsPlan", cellular->needs_new_plan()); - connection_plans.SetBoolean("activated", - cellular->activation_state() == chromeos::ACTIVATION_STATE_ACTIVATED); - connection_plans.Set("plans", plan_list); - SetActivationButtonVisibility(cellular, &connection_plans); - web_ui_->CallJavascriptFunction( - "options.InternetOptions.updateCellularPlans", connection_plans); -} - -DictionaryValue* InternetOptionsHandler::CellularDataPlanToDictionary( - const chromeos::CellularDataPlan* plan) { - DictionaryValue* plan_dict = new DictionaryValue(); - plan_dict->SetInteger("planType", plan->plan_type); - plan_dict->SetString("name", plan->plan_name); - plan_dict->SetString("planSummary", plan->GetPlanDesciption()); - plan_dict->SetString("dataRemaining", plan->GetDataRemainingDesciption()); - plan_dict->SetString("planExpires", plan->GetPlanExpiration()); - plan_dict->SetString("warning", plan->GetRemainingWarning()); - return plan_dict; -} - -void InternetOptionsHandler::SetDetailsCallback(const ListValue* args) { - std::string service_path; - std::string auto_connect_str; - - if (args->GetSize() < 2 || - !args->GetString(0, &service_path) || - !args->GetString(1, &auto_connect_str)) { - NOTREACHED(); - return; - } - - if (!chromeos::UserManager::Get()->current_user_is_owner()) { - LOG(WARNING) << "Non-owner tried to change a network."; - return; - } - - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path); - if (!network) - return; - - if (network->encrypted()) { - if (network->encrypted() && - network->encryption() == chromeos::SECURITY_8021X) { - std::string ident; - if (!args->GetString(2, &ident)) { - NOTREACHED(); - return; - } - if (ident != network->identity()) - network->SetIdentity(ident); - if (!IsCertificateInPkcs11(network->cert_path())) { - std::string certpath; - if (!args->GetString(3, &certpath)) { - NOTREACHED(); - return; - } - if (certpath != network->cert_path()) - network->SetCertPath(certpath); - } - } - } - - bool auto_connect = auto_connect_str == "true"; - if (auto_connect != network->auto_connect()) - network->SetAutoConnect(auto_connect); -} - -bool InternetOptionsHandler::IsCertificateInPkcs11(const std::string& path) { - static const std::string settings_string("SETTINGS:"); - static const std::string pkcs11_key("key_id"); - if (path.find(settings_string) == 0) { - std::string::size_type idx = path.find(pkcs11_key); - if (idx != std::string::npos) - idx = path.find_first_not_of(kWhitespaceASCII, idx + pkcs11_key.length()); - if (idx != std::string::npos && path[idx] == '=') - return true; - } - return false; -} - -void InternetOptionsHandler::PopulateDictionaryDetails( - const chromeos::Network* net, chromeos::NetworkLibrary* cros) { - DCHECK(net); - DictionaryValue dictionary; - std::string hardware_address; - chromeos::NetworkIPConfigVector ipconfigs = - cros->GetIPConfigs(net->device_path(), &hardware_address); - if (!hardware_address.empty()) { - dictionary.SetString("hardwareAddress", - FormatHardwareAddress(hardware_address)); - } - scoped_ptr<ListValue> ipconfig_list(new ListValue()); - for (chromeos::NetworkIPConfigVector::const_iterator it = ipconfigs.begin(); - it != ipconfigs.end(); ++it) { - scoped_ptr<DictionaryValue> ipconfig_dict(new DictionaryValue()); - const chromeos::NetworkIPConfig& ipconfig = *it; - ipconfig_dict->SetString("address", ipconfig.address); - ipconfig_dict->SetString("subnetAddress", ipconfig.netmask); - ipconfig_dict->SetString("gateway", ipconfig.gateway); - ipconfig_dict->SetString("dns", ipconfig.name_servers); - ipconfig_list->Append(ipconfig_dict.release()); - } - dictionary.Set("ipconfigs", ipconfig_list.release()); - - chromeos::ConnectionType type = net->type(); - dictionary.SetInteger("type", type); - dictionary.SetString("servicePath", net->service_path()); - dictionary.SetBoolean("connecting", net->connecting()); - dictionary.SetBoolean("connected", net->connected()); - dictionary.SetString("connectionState", net->GetStateString()); - - if (type == chromeos::TYPE_WIFI) { - const chromeos::WifiNetwork* wifi = - cros->FindWifiNetworkByPath(net->service_path()); - if (!wifi) { - LOG(WARNING) << "Cannot find network " << net->service_path(); - } else { - PopulateWifiDetails(wifi, &dictionary); - } - } else if (type == chromeos::TYPE_CELLULAR) { - const chromeos::CellularNetwork* cellular = - cros->FindCellularNetworkByPath(net->service_path()); - if (!cellular) { - LOG(WARNING) << "Cannot find network " << net->service_path(); - } else { - PopulateCellularDetails(cros, cellular, &dictionary); - } - } - - web_ui_->CallJavascriptFunction( - "options.InternetOptions.showDetailedInfo", dictionary); -} - -void InternetOptionsHandler::PopulateWifiDetails( - const chromeos::WifiNetwork* wifi, - DictionaryValue* dictionary) { - dictionary->SetString("ssid", wifi->name()); - dictionary->SetBoolean("autoConnect", wifi->auto_connect()); - if (wifi->encrypted()) { - dictionary->SetBoolean("encrypted", true); - if (wifi->encryption() == chromeos::SECURITY_8021X) { - bool certificate_in_pkcs11 = - IsCertificateInPkcs11(wifi->cert_path()); - if (certificate_in_pkcs11) { - dictionary->SetBoolean("certInPkcs", true); - } else { - dictionary->SetBoolean("certInPkcs", false); - } - dictionary->SetString("certPath", wifi->cert_path()); - dictionary->SetString("ident", wifi->identity()); - dictionary->SetBoolean("certNeeded", true); - dictionary->SetString("certPass", wifi->GetPassphrase()); - } else { - dictionary->SetBoolean("certNeeded", false); - } - } else { - dictionary->SetBoolean("encrypted", false); - } -} - -void InternetOptionsHandler::PopulateCellularDetails( - chromeos::NetworkLibrary* cros, - const chromeos::CellularNetwork* cellular, - DictionaryValue* dictionary) { - // Cellular network / connection settings. - dictionary->SetString("serviceName", cellular->name()); - dictionary->SetString("networkTechnology", - cellular->GetNetworkTechnologyString()); - dictionary->SetString("operatorName", cellular->operator_name()); - dictionary->SetString("operatorCode", cellular->operator_code()); - dictionary->SetString("activationState", - cellular->GetActivationStateString()); - dictionary->SetString("roamingState", - cellular->GetRoamingStateString()); - dictionary->SetString("restrictedPool", - cellular->restricted_pool() ? - l10n_util::GetStringUTF8( - IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL) : - l10n_util::GetStringUTF8( - IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)); - dictionary->SetString("errorState", cellular->GetErrorString()); - dictionary->SetString("supportUrl", cellular->payment_url()); - dictionary->SetBoolean("needsPlan", cellular->needs_new_plan()); - dictionary->SetBoolean("gsm", cellular->is_gsm()); - - // Device settings. - const chromeos::NetworkDevice* device = - cros->FindNetworkDeviceByPath(cellular->device_path()); - if (device) { - dictionary->SetString("manufacturer", device->manufacturer()); - dictionary->SetString("modelId", device->model_id()); - dictionary->SetString("firmwareRevision", device->firmware_revision()); - dictionary->SetString("hardwareRevision", device->hardware_revision()); - dictionary->SetString("lastUpdate", device->last_update()); - dictionary->SetString("prlVersion", - StringPrintf("%u", device->prl_version())); - dictionary->SetString("meid", device->meid()); - dictionary->SetString("imei", device->imei()); - dictionary->SetString("mdn", device->mdn()); - dictionary->SetString("imsi", device->imsi()); - dictionary->SetString("esn", device->esn()); - dictionary->SetString("min", device->min()); - } - - SetActivationButtonVisibility(cellular, dictionary); -} - -void InternetOptionsHandler::SetActivationButtonVisibility( - const chromeos::CellularNetwork* cellular, - DictionaryValue* dictionary) { - if (cellular->needs_new_plan()) { - dictionary->SetBoolean("showBuyButton", true); - } else if (cellular->activation_state() != - chromeos::ACTIVATION_STATE_ACTIVATING && - cellular->activation_state() != - chromeos::ACTIVATION_STATE_ACTIVATED) { - dictionary->SetBoolean("showActivateButton", true); - } -} - -void InternetOptionsHandler::LoginCallback(const ListValue* args) { - std::string service_path; - std::string password; - - if (args->GetSize() != 2 || - !args->GetString(0, &service_path) || - !args->GetString(1, &password)) { - NOTREACHED(); - return; - } - - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - cros->ConnectToWifiNetwork(service_path); -} - -void InternetOptionsHandler::LoginCertCallback(const ListValue* args) { - std::string service_path; - std::string identity; - std::string certpath; - if (args->GetSize() < 3 || - !args->GetString(0, &service_path) || - !args->GetString(1, &certpath) || - !args->GetString(2, &identity)) { - return; - } - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - chromeos::WifiNetwork* network = cros->FindWifiNetworkByPath(service_path); - if (network) { - std::string passphrase; - if (args->GetSize() == 4 && args->GetString(3, &passphrase)) - network->SetPassphrase(passphrase); - cros->ConnectToWifiNetwork(network); - } -} - -void InternetOptionsHandler::LoginToOtherCallback(const ListValue* args) { - std::string security; - std::string ssid; - std::string password; - - if (args->GetSize() != 3 || - !args->GetString(0, &security) || - !args->GetString(1, &ssid) || - !args->GetString(2, &password)) { - NOTREACHED(); - return; - } - - chromeos::ConnectionSecurity sec = chromeos::SECURITY_UNKNOWN; - if (security == "none") { - sec = chromeos::SECURITY_NONE; - } else if (security == "wep") { - sec = chromeos::SECURITY_WEP; - } else if (security == "wpa") { - sec = chromeos::SECURITY_WPA; - } else if (security == "rsn") { - sec = chromeos::SECURITY_RSN; - } - - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - - cros->ConnectToWifiNetwork(sec, ssid, password, std::string(), std::string(), - true); -} - -void InternetOptionsHandler::CreateModalPopup(views::WindowDelegate* view) { - DCHECK(!use_settings_ui_); - - // TODO(beng): This is an improper direct dependency on Browser. Route this - // through some sort of delegate. - Browser* browser = BrowserList::FindBrowserWithProfile(web_ui_->GetProfile()); - views::Window* window = browser::CreateViewsWindow( - browser->window()->GetNativeHandle(), gfx::Rect(), view); - window->SetIsAlwaysOnTop(true); - window->Show(); -} - -void InternetOptionsHandler::ButtonClickCallback(const ListValue* args) { - std::string str_type; - std::string service_path; - std::string command; - if (args->GetSize() != 3 || - !args->GetString(0, &str_type) || - !args->GetString(1, &service_path) || - !args->GetString(2, &command)) { - NOTREACHED(); - return; - } - - int type = atoi(str_type.c_str()); - if (type == chromeos::TYPE_ETHERNET) { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - const chromeos::EthernetNetwork* ether = cros->ethernet_network(); - PopulateDictionaryDetails(ether, cros); - } else if (type == chromeos::TYPE_WIFI) { - HandleWifiButtonClick(service_path, command); - } else if (type == chromeos::TYPE_CELLULAR) { - HandleCellularButtonClick(service_path, command); - } else { - NOTREACHED(); - } -} - -void InternetOptionsHandler::HandleWifiButtonClick( - const std::string& service_path, - const std::string& command) { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - chromeos::WifiNetwork* wifi = NULL; - if (command == "forget") { - if (!chromeos::UserManager::Get()->current_user_is_owner()) { - LOG(WARNING) << "Non-owner tried to forget a network."; - return; - } - cros->ForgetWifiNetwork(service_path); - } else if (!use_settings_ui_ && service_path == kOtherNetworksFakePath) { - // Other wifi networks. - CreateModalPopup(new chromeos::NetworkConfigView()); - } else if ((wifi = cros->FindWifiNetworkByPath(service_path))) { - if (command == "connect") { - // Connect to wifi here. Open password page if appropriate. - if (wifi->IsPassphraseRequired()) { - if (use_settings_ui_) { - if (wifi->encryption() == chromeos::SECURITY_8021X) { - PopulateDictionaryDetails(wifi, cros); - } else { - DictionaryValue dictionary; - dictionary.SetString("servicePath", wifi->service_path()); - web_ui_->CallJavascriptFunction( - "options.InternetOptions.showPasswordEntry", dictionary); - } - } else { - CreateModalPopup( - new chromeos::NetworkConfigView(wifi)); - } - } else { - cros->ConnectToWifiNetwork(wifi); - } - } else if (command == "disconnect") { - cros->DisconnectFromWirelessNetwork(wifi); - } else if (command == "options") { - PopulateDictionaryDetails(wifi, cros); - } - } -} - -void InternetOptionsHandler::HandleCellularButtonClick( - const std::string& service_path, - const std::string& command) { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - chromeos::CellularNetwork* cellular = - cros->FindCellularNetworkByPath(service_path); - if (cellular) { - if (command == "connect") { - cros->ConnectToCellularNetwork(cellular); - } else if (command == "disconnect") { - cros->DisconnectFromWirelessNetwork(cellular); - } else if (command == "activate") { - Browser* browser = BrowserList::GetLastActive(); - if (browser) - browser->OpenMobilePlanTabAndActivate(); - } else if (command == "options") { - PopulateDictionaryDetails(cellular, cros); - } - } -} - -void InternetOptionsHandler::RefreshCellularPlanCallback( - const ListValue* args) { - std::string service_path; - if (args->GetSize() != 1 || - !args->GetString(0, &service_path)) { - NOTREACHED(); - return; - } - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - const chromeos::CellularNetwork* cellular = - cros->FindCellularNetworkByPath(service_path); - if (cellular) - cellular->RefreshDataPlansIfNeeded(); -} - -ListValue* InternetOptionsHandler::GetNetwork( - const std::string& service_path, - const SkBitmap& icon, - const std::string& name, - bool connecting, - bool connected, - bool connectable, - chromeos::ConnectionType connection_type, - bool remembered, - chromeos::ActivationState activation_state, - bool needs_new_plan) { - ListValue* network = new ListValue(); - - int connection_state = IDS_STATUSBAR_NETWORK_DEVICE_DISCONNECTED; - if (!connectable) - connection_state = IDS_STATUSBAR_NETWORK_DEVICE_NOT_CONFIGURED; - else if (connecting) - connection_state = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING; - else if (connected) - connection_state = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTED; - std::string status = l10n_util::GetStringUTF8(connection_state); - if (connection_type == chromeos::TYPE_CELLULAR) { - if (needs_new_plan) { - status = l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_NO_PLAN_LABEL); - } else if (activation_state != chromeos::ACTIVATION_STATE_ACTIVATED) { - status.append(" / "); - status.append( - chromeos::CellularNetwork::ActivationStateToString(activation_state)); - } - } - - // To keep the consistency with JS implementation, do not change the order - // locally. - // TODO(kochi): Use dictionaly for future maintainability. - // 0) service path - network->Append(Value::CreateStringValue(service_path)); - // 1) name - network->Append(Value::CreateStringValue(name)); - // 2) status - network->Append(Value::CreateStringValue(status)); - // 3) type - network->Append(Value::CreateIntegerValue(static_cast<int>(connection_type))); - // 4) connected - network->Append(Value::CreateBooleanValue(connected)); - // 5) connecting - network->Append(Value::CreateBooleanValue(connecting)); - // 6) icon data url - network->Append(Value::CreateStringValue(icon.isNull() ? "" : - web_ui_util::GetImageDataUrl(icon))); - // 7) remembered - network->Append(Value::CreateBooleanValue(remembered)); - // 8) activation state - network->Append(Value::CreateIntegerValue( - static_cast<int>(activation_state))); - // 9) needs new plan - network->Append(Value::CreateBooleanValue(needs_new_plan)); - // 10) connectable - network->Append(Value::CreateBooleanValue(connectable)); - return network; -} - -ListValue* InternetOptionsHandler::GetWiredList() { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - ListValue* list = new ListValue(); - - // If ethernet is not enabled, then don't add anything. - if (cros->ethernet_enabled()) { - const chromeos::EthernetNetwork* ethernet_network = - cros->ethernet_network(); - const SkBitmap* icon = rb.GetBitmapNamed(IDR_STATUSBAR_WIRED_BLACK); - const SkBitmap* badge = !ethernet_network || - (!ethernet_network->connecting() && !ethernet_network->connected()) ? - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_DISCONNECTED) : NULL; - if (ethernet_network) { - list->Append(GetNetwork( - ethernet_network->service_path(), - chromeos::NetworkMenu::IconForDisplay(icon, badge), - l10n_util::GetStringUTF8(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET), - ethernet_network->connecting(), - ethernet_network->connected(), - ethernet_network->connectable(), - chromeos::TYPE_ETHERNET, - false, - chromeos::ACTIVATION_STATE_UNKNOWN, - false)); - } - } - return list; -} - -ListValue* InternetOptionsHandler::GetWirelessList() { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - ListValue* list = new ListValue(); - - const chromeos::WifiNetworkVector& wifi_networks = cros->wifi_networks(); - for (chromeos::WifiNetworkVector::const_iterator it = - wifi_networks.begin(); it != wifi_networks.end(); ++it) { - const SkBitmap* icon = - chromeos::NetworkMenu::IconForNetworkStrength(*it, true); - const SkBitmap* badge = (*it)->encrypted() ? - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL; - list->Append(GetNetwork( - (*it)->service_path(), - chromeos::NetworkMenu::IconForDisplay(icon, badge), - (*it)->name(), - (*it)->connecting(), - (*it)->connected(), - (*it)->connectable(), - chromeos::TYPE_WIFI, - false, - chromeos::ACTIVATION_STATE_UNKNOWN, - false)); - } - - const chromeos::CellularNetworkVector cellular_networks = - cros->cellular_networks(); - for (chromeos::CellularNetworkVector::const_iterator it = - cellular_networks.begin(); it != cellular_networks.end(); ++it) { - const SkBitmap* icon = - chromeos::NetworkMenu::IconForNetworkStrength(*it, true); - const SkBitmap* badge = - chromeos::NetworkMenu::BadgeForNetworkTechnology(*it); - const SkBitmap* roaming_badge = - chromeos::NetworkMenu::BadgeForRoamingStatus(*it); - list->Append(GetNetwork( - (*it)->service_path(), - chromeos::NetworkMenu::IconForDisplay(icon, badge, roaming_badge), - (*it)->name(), - (*it)->connecting(), - (*it)->connected(), - (*it)->connectable(), - chromeos::TYPE_CELLULAR, - false, - (*it)->activation_state(), - (*it)->restricted_pool())); - } - - // Add "Other..." if wifi is enabled. - if (cros->wifi_enabled()) { - list->Append(GetNetwork( - kOtherNetworksFakePath, - *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK), - l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_OTHER_NETWORKS), - false, - false, - true, - chromeos::TYPE_WIFI, - false, - chromeos::ACTIVATION_STATE_UNKNOWN, - false)); - } - - return list; -} - -std::string GetWifiUniqueIdentifier(const chromeos::WifiNetwork* wifi) { - return wifi->encryption() + "|" + wifi->name(); -} - -ListValue* InternetOptionsHandler::GetRememberedList() { - chromeos::NetworkLibrary* cros = - chromeos::CrosLibrary::Get()->GetNetworkLibrary(); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - ListValue* list = new ListValue(); - - const chromeos::WifiNetworkVector& remembered_wifi_networks = - cros->remembered_wifi_networks(); - const chromeos::WifiNetworkVector& wifi_networks = - cros->wifi_networks(); - - // The remembered networks from libcros/flimflam don't include the signal - // strength, so fall back to the detected networks for this data. We - // consider networks to be the same if they have the same name and encryption - // type, so create a map of detected networks indexed by name + encryption. - std::map<std::string, chromeos::WifiNetwork*> wifi_map; - for (chromeos::WifiNetworkVector::const_iterator it = wifi_networks.begin(); - it != wifi_networks.end(); ++it) { - wifi_map[GetWifiUniqueIdentifier(*it)] = *it; - } - - for (chromeos::WifiNetworkVector::const_iterator rit = - remembered_wifi_networks.begin(); - rit != remembered_wifi_networks.end(); ++rit) { - chromeos::WifiNetwork* wifi = *rit; - // Check if this remembered network has a matching detected network. - std::map<std::string, chromeos::WifiNetwork*>::const_iterator it = - wifi_map.find(GetWifiUniqueIdentifier(wifi)); - bool found = it != wifi_map.end(); - - // Don't show the active network in the remembered list. - if (found && (it->second)->connected()) - continue; - const SkBitmap* icon = found ? - chromeos::NetworkMenu::IconForNetworkStrength(it->second, true) : - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_BARS0_BLACK); - // Place the secure badge on the icon if the remembered network is - // encrypted (the matching detected network, if any, will have the same - // encrypted property by definition). - const SkBitmap* badge = wifi->encrypted() ? - rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_SECURE) : NULL; - list->Append(GetNetwork( - wifi->service_path(), - chromeos::NetworkMenu::IconForDisplay(icon, badge), - wifi->name(), - wifi->connecting(), - wifi->connected(), - true, - chromeos::TYPE_WIFI, - true, - chromeos::ACTIVATION_STATE_UNKNOWN, - false)); - } - return list; -} - -void InternetOptionsHandler::FillNetworkInfo( - DictionaryValue* dictionary, chromeos::NetworkLibrary* cros) { - dictionary->SetBoolean("accessLocked", cros->IsLocked()); - dictionary->Set("wiredList", GetWiredList()); - dictionary->Set("wirelessList", GetWirelessList()); - dictionary->Set("rememberedList", GetRememberedList()); - dictionary->SetBoolean("wifiAvailable", cros->wifi_available()); - dictionary->SetBoolean("wifiEnabled", cros->wifi_enabled()); - dictionary->SetBoolean("cellularAvailable", cros->cellular_available()); - dictionary->SetBoolean("cellularEnabled", cros->cellular_enabled()); -} diff --git a/chrome/browser/chromeos/webui/internet_options_handler.h b/chrome/browser/chromeos/webui/internet_options_handler.h deleted file mode 100644 index 346419b..0000000 --- a/chrome/browser/chromeos/webui/internet_options_handler.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_INTERNET_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_INTERNET_OPTIONS_HANDLER_H_ - -#include <string> - -#include "chrome/browser/chromeos/cros/network_library.h" -#include "chrome/browser/chromeos/webui/cros_options_page_ui_handler.h" - -class SkBitmap; -namespace views { -class WindowDelegate; -} - -// ChromeOS internet options page UI handler. -class InternetOptionsHandler - : public chromeos::CrosOptionsPageUIHandler, - public chromeos::NetworkLibrary::NetworkManagerObserver, - public chromeos::NetworkLibrary::NetworkObserver, - public chromeos::NetworkLibrary::CellularDataPlanObserver { - public: - InternetOptionsHandler(); - virtual ~InternetOptionsHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - virtual void Initialize(); - - // WebUIMessageHandler implementation. - virtual void RegisterMessages(); - - // NetworkLibrary::NetworkManagerObserver implementation. - virtual void OnNetworkManagerChanged(chromeos::NetworkLibrary* network_lib); - // NetworkLibrary::NetworkObserver implementation. - virtual void OnNetworkChanged(chromeos::NetworkLibrary* network_lib, - const chromeos::Network* network); - // NetworkLibrary::CellularDataPlanObserver implementation. - virtual void OnCellularDataPlanChanged(chromeos::NetworkLibrary* network_lib); - - private: - // Opens a modal popup dialog. - void CreateModalPopup(views::WindowDelegate* view); - - // Passes data needed to show details overlay for network. - // |args| will be [ network_type, service_path, command ] - // And command is one of 'options', 'connect', disconnect', 'activate' or - // 'forget' - // Handle{Wifi,Cellular}ButtonClick handles button click on a wireless - // network item and a cellular network item respectively. - void ButtonClickCallback(const ListValue* args); - void HandleWifiButtonClick(const std::string& service_path, - const std::string& command); - void HandleCellularButtonClick(const std::string& service_path, - const std::string& command); - - // Initiates cellular plan data refresh. The results from libcros will be - // passed through CellularDataPlanChanged() callback method. - // |args| will be [ service_path ] - void RefreshCellularPlanCallback(const ListValue* args); - void SetActivationButtonVisibility( - const chromeos::CellularNetwork* cellular, - DictionaryValue* dictionary); - - void LoginCallback(const ListValue* args); - void LoginCertCallback(const ListValue* args); - void LoginToOtherCallback(const ListValue* args); - void SetDetailsCallback(const ListValue* args); - void EnableWifiCallback(const ListValue* args); - void DisableWifiCallback(const ListValue* args); - void EnableCellularCallback(const ListValue* args); - void DisableCellularCallback(const ListValue* args); - void BuyDataPlanCallback(const ListValue* args); - - // Parses 'path' to determine if the certificate is stored in a pkcs#11 - // device. flimflam recognizes the string "SETTINGS:" to specify - // authentication parameters. 'key_id=' indicates that the certificate is - // stored in a pkcs#11 device. - // See src/third_party/flimflam/files/doc/service-api.txt. - bool IsCertificateInPkcs11(const std::string& path); - - // Populates the ui with the details of the given device path. This forces - // an overlay to be displayed in the UI. - void PopulateDictionaryDetails(const chromeos::Network* net, - chromeos::NetworkLibrary* cros); - void PopulateWifiDetails(const chromeos::WifiNetwork* wifi, - DictionaryValue* dictionary); - void PopulateCellularDetails(chromeos::NetworkLibrary* cros, - const chromeos::CellularNetwork* cellular, - DictionaryValue* dictionary); - - // Converts CellularDataPlan structure into dictionary for JS. Formats plan - // settings into human readable texts. - DictionaryValue* CellularDataPlanToDictionary( - const chromeos::CellularDataPlan* plan); - // Creates the map of a network. - ListValue* GetNetwork(const std::string& service_path, - const SkBitmap& icon, - const std::string& name, - bool connecting, - bool connected, - bool connectable, - chromeos::ConnectionType connection_type, - bool remembered, - chromeos::ActivationState activation_state, - bool restricted_ip); - - // Creates the map of wired networks. - ListValue* GetWiredList(); - // Creates the map of wireless networks. - ListValue* GetWirelessList(); - // Creates the map of remembered networks. - ListValue* GetRememberedList(); - // Fills network information into JS dictionary for displaying network lists. - void FillNetworkInfo(DictionaryValue* dictionary, - chromeos::NetworkLibrary* cros); - // Refreshes the display of network information. - void RefreshNetworkData(chromeos::NetworkLibrary* cros); - // Adds observers for wireless networks, if any, so that we can dynamically - // display the correct icon for that network's signal strength and, in the - // case of cellular networks, network technology and roaming status. - void MonitorNetworks(chromeos::NetworkLibrary* cros); - - // A boolean flag of whether to use WebUI for connect UI. True to use WebUI - // and false to use Views dialogs. - bool use_settings_ui_; - - DISALLOW_COPY_AND_ASSIGN(InternetOptionsHandler); -}; - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_INTERNET_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/language_chewing_options_handler.cc b/chrome/browser/chromeos/webui/language_chewing_options_handler.cc deleted file mode 100644 index 58333be..0000000 --- a/chrome/browser/chromeos/webui/language_chewing_options_handler.cc +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/language_chewing_options_handler.h" - -#include <limits> - -#include "base/logging.h" -#include "base/string_number_conversions.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/language_preferences.h" -#include "chrome/browser/chromeos/webui/language_options_util.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -namespace { -const char kI18nPrefix[] = "Chewing_"; -} // namespace - -namespace chromeos { - -LanguageChewingOptionsHandler::LanguageChewingOptionsHandler() { -} - -LanguageChewingOptionsHandler::~LanguageChewingOptionsHandler() { -} - -void LanguageChewingOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - RegisterTitle(localized_strings, "languageChewingPage", - IDS_OPTIONS_SETTINGS_LANGUAGES_CHEWING_SETTINGS_TITLE); - - for (size_t i = 0; i < language_prefs::kNumChewingBooleanPrefs; ++i) { - localized_strings->SetString( - GetI18nContentValue(language_prefs::kChewingBooleanPrefs[i], - kI18nPrefix), - l10n_util::GetStringUTF16( - language_prefs::kChewingBooleanPrefs[i].message_id)); - } - - // For maximum Chinese characters in pre-edit buffer, we use slider UI. - { - const language_prefs::LanguageIntegerRangePreference& preference = - language_prefs::kChewingIntegerPrefs[ - language_prefs::kChewingMaxChiSymbolLenIndex]; - localized_strings->SetString( - GetI18nContentValue(preference, kI18nPrefix), - l10n_util::GetStringUTF16(preference.message_id)); - localized_strings->SetString( - GetTemplateDataMinName(preference, kI18nPrefix), - base::IntToString(preference.min_pref_value)); - localized_strings->SetString( - GetTemplateDataMaxName(preference, kI18nPrefix), - base::IntToString(preference.max_pref_value)); - } - - // For number of candidates per page, we use select-option UI. - { - const language_prefs::LanguageIntegerRangePreference& preference = - language_prefs::kChewingIntegerPrefs[ - language_prefs::kChewingCandPerPageIndex]; - localized_strings->SetString( - GetI18nContentValue(preference, kI18nPrefix), - l10n_util::GetStringUTF16(preference.message_id)); - ListValue* list_value = new ListValue(); - for (int i = preference.min_pref_value; i <= preference.max_pref_value; - ++i) { - ListValue* option = new ListValue(); - option->Append(CreateValue(i)); - option->Append(CreateValue(i)); - list_value->Append(option); - } - localized_strings->Set(GetTemplateDataPropertyName(preference, kI18nPrefix), - list_value); - } - - for (size_t i = 0; i < language_prefs::kNumChewingMultipleChoicePrefs; - ++i) { - const language_prefs::LanguageMultipleChoicePreference<const char*>& - preference = language_prefs::kChewingMultipleChoicePrefs[i]; - localized_strings->SetString( - GetI18nContentValue(preference, kI18nPrefix), - l10n_util::GetStringUTF16(preference.label_message_id)); - localized_strings->Set( - GetTemplateDataPropertyName(preference, kI18nPrefix), - CreateMultipleChoiceList(preference)); - } - - localized_strings->SetString( - GetI18nContentValue(language_prefs::kChewingHsuSelKeyType, kI18nPrefix), - l10n_util::GetStringUTF16( - language_prefs::kChewingHsuSelKeyType.label_message_id)); - localized_strings->Set( - GetTemplateDataPropertyName(language_prefs::kChewingHsuSelKeyType, - kI18nPrefix), - CreateMultipleChoiceList(language_prefs::kChewingHsuSelKeyType)); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/language_chewing_options_handler.h b/chrome/browser/chromeos/webui/language_chewing_options_handler.h deleted file mode 100644 index c243d67..0000000 --- a/chrome/browser/chromeos/webui/language_chewing_options_handler.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_CHEWING_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_CHEWING_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/ui/webui/options/options_ui.h" - -class DictionaryValue; - -namespace chromeos { - -// Chewing options page UI handler. -class LanguageChewingOptionsHandler : public OptionsPageUIHandler { - public: - LanguageChewingOptionsHandler(); - virtual ~LanguageChewingOptionsHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - - private: - DISALLOW_COPY_AND_ASSIGN(LanguageChewingOptionsHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_CHEWING_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/language_customize_modifier_keys_handler.cc b/chrome/browser/chromeos/webui/language_customize_modifier_keys_handler.cc deleted file mode 100644 index 02ad3c1..0000000 --- a/chrome/browser/chromeos/webui/language_customize_modifier_keys_handler.cc +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/language_customize_modifier_keys_handler.h" - -#include "base/values.h" -#include "grit/generated_resources.h" -#include "third_party/cros/chromeos_keyboard.h" -#include "ui/base/l10n/l10n_util.h" - -namespace { -const struct ModifierKeysSelectItem { - int message_id; - chromeos::ModifierKey value; -} kModifierKeysSelectItems[] = { - { IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_SEARCH_LABEL, - chromeos::kSearchKey }, - { IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_LEFT_CTRL, - chromeos::kLeftControlKey }, - { IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_LEFT_ALT, - chromeos::kLeftAltKey }, - { IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_VOID, - chromeos::kVoidKey }, - { IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_CAPSLOCK, - chromeos::kCapsLockKey }, -}; - -const char* kDataValuesNames[] = { - "xkbRemapSearchKeyToValue", - "xkbRemapControlKeyToValue", - "xkbRemapAltKeyToValue", -}; -} // namespace - -namespace chromeos { - -LanguageCustomizeModifierKeysHandler::LanguageCustomizeModifierKeysHandler() { -} - -LanguageCustomizeModifierKeysHandler::~LanguageCustomizeModifierKeysHandler() { -} - -void LanguageCustomizeModifierKeysHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - localized_strings->SetString("xkbRemapSearchKeyToContent", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_SEARCH_LABEL)); - localized_strings->SetString("xkbRemapControlKeyToContent", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_LEFT_CTRL_LABEL)); - localized_strings->SetString("xkbRemapAltKeyToContent", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_XKB_KEY_LEFT_ALT_LABEL)); - - for (size_t i = 0; i < arraysize(kDataValuesNames); ++i) { - ListValue* list_value = new ListValue(); - for (size_t j = 0; j < arraysize(kModifierKeysSelectItems); ++j) { - const ModifierKey value = kModifierKeysSelectItems[j].value; - const int message_id = kModifierKeysSelectItems[j].message_id; - // Only the seach key can be remapped to the caps lock key. - if (kDataValuesNames[i] != std::string("xkbRemapSearchKeyToValue") && - value == kCapsLockKey) { - continue; - } - ListValue* option = new ListValue(); - option->Append(Value::CreateIntegerValue(value)); - option->Append(Value::CreateStringValue(l10n_util::GetStringUTF16( - message_id))); - list_value->Append(option); - } - localized_strings->Set(kDataValuesNames[i], list_value); - } -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/language_customize_modifier_keys_handler.h b/chrome/browser/chromeos/webui/language_customize_modifier_keys_handler.h deleted file mode 100644 index 643afb1..0000000 --- a/chrome/browser/chromeos/webui/language_customize_modifier_keys_handler.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_CUSTOMIZE_MODIFIER_KEYS_HANDLER_H_ // NOLINT -#define CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_CUSTOMIZE_MODIFIER_KEYS_HANDLER_H_ // NOLINT -#pragma once - -#include "chrome/browser/prefs/pref_member.h" -#include "chrome/browser/ui/webui/options/options_ui.h" - -namespace chromeos { - -// Customize modifier keys overlay page UI handler. -class LanguageCustomizeModifierKeysHandler : public OptionsPageUIHandler { - public: - LanguageCustomizeModifierKeysHandler(); - virtual ~LanguageCustomizeModifierKeysHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - - private: - DISALLOW_COPY_AND_ASSIGN(LanguageCustomizeModifierKeysHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_CUSTOMIZE_MODIFIER_KEYS_HANDLER_H_ // NOLINT diff --git a/chrome/browser/chromeos/webui/language_hangul_options_handler.cc b/chrome/browser/chromeos/webui/language_hangul_options_handler.cc deleted file mode 100644 index 7b4aeb0..0000000 --- a/chrome/browser/chromeos/webui/language_hangul_options_handler.cc +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/language_hangul_options_handler.h" - -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/language_preferences.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -namespace chromeos { - -LanguageHangulOptionsHandler::LanguageHangulOptionsHandler() { -} - -LanguageHangulOptionsHandler::~LanguageHangulOptionsHandler() { -} - -void LanguageHangulOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - RegisterTitle(localized_strings, "languageHangulPage", - IDS_OPTIONS_SETTINGS_LANGUAGES_HANGUL_SETTINGS_TITLE); - - localized_strings->SetString("hangul_keyboard_layout", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_KEYBOARD_LAYOUT_TEXT)); - - localized_strings->Set("HangulkeyboardLayoutList", GetKeyboardLayoutList()); -} - -ListValue* LanguageHangulOptionsHandler::GetKeyboardLayoutList() { - ListValue* keyboard_layout_list = new ListValue(); - for (size_t i = 0; i < language_prefs::kNumHangulKeyboardNameIDPairs; ++i) { - ListValue* option = new ListValue(); - option->Append(Value::CreateStringValue( - language_prefs::kHangulKeyboardNameIDPairs[i].keyboard_id)); - option->Append(Value::CreateStringValue(l10n_util::GetStringUTF16( - language_prefs::kHangulKeyboardNameIDPairs[i].message_id))); - keyboard_layout_list->Append(option); - } - return keyboard_layout_list; -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/language_hangul_options_handler.h b/chrome/browser/chromeos/webui/language_hangul_options_handler.h deleted file mode 100644 index 3fe469f..0000000 --- a/chrome/browser/chromeos/webui/language_hangul_options_handler.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_HANGUL_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_HANGUL_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/ui/webui/options/options_ui.h" - -class DictionaryValue; -class ListValue; - -namespace chromeos { - -// Hangul options page UI handler. -class LanguageHangulOptionsHandler : public OptionsPageUIHandler { - public: - LanguageHangulOptionsHandler(); - virtual ~LanguageHangulOptionsHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - - private: - // Returns the list of hangul keyboards. - static ListValue* GetKeyboardLayoutList(); - - DISALLOW_COPY_AND_ASSIGN(LanguageHangulOptionsHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_HANGUL_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/language_mozc_options_handler.cc b/chrome/browser/chromeos/webui/language_mozc_options_handler.cc deleted file mode 100644 index f80a19a..0000000 --- a/chrome/browser/chromeos/webui/language_mozc_options_handler.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/language_mozc_options_handler.h" - -#include "base/string_number_conversions.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/language_preferences.h" -#include "chrome/browser/chromeos/webui/language_options_util.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -namespace { -const char kI18nPrefix[] = "mozc_"; -} // namespace - -namespace chromeos { - -LanguageMozcOptionsHandler::LanguageMozcOptionsHandler() { -} - -LanguageMozcOptionsHandler::~LanguageMozcOptionsHandler() { -} - -void LanguageMozcOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - RegisterTitle(localized_strings, "languageMozcPage", - IDS_OPTIONS_SETTINGS_LANGUAGES_MOZC_SETTINGS_TITLE); - - for (size_t i = 0; i < language_prefs::kNumMozcBooleanPrefs; ++i) { - localized_strings->SetString( - GetI18nContentValue(language_prefs::kMozcBooleanPrefs[i], kI18nPrefix), - l10n_util::GetStringUTF16( - language_prefs::kMozcBooleanPrefs[i].message_id)); - } - - for (size_t i = 0; i < language_prefs::kNumMozcMultipleChoicePrefs; ++i) { - const language_prefs::LanguageMultipleChoicePreference<const char*>& - preference = language_prefs::kMozcMultipleChoicePrefs[i]; - localized_strings->SetString( - GetI18nContentValue(preference, kI18nPrefix), - l10n_util::GetStringUTF16(preference.label_message_id)); - localized_strings->Set(GetTemplateDataPropertyName(preference, kI18nPrefix), - CreateMultipleChoiceList(preference)); - } - - for (size_t i = 0; i < language_prefs::kNumMozcIntegerPrefs; ++i) { - const language_prefs::LanguageIntegerRangePreference& preference = - language_prefs::kMozcIntegerPrefs[i]; - localized_strings->SetString( - GetI18nContentValue(preference, kI18nPrefix), - l10n_util::GetStringUTF16(preference.message_id)); - ListValue* list_value = new ListValue(); - for (int j = preference.min_pref_value; j <= preference.max_pref_value; - ++j) { - ListValue* option = new ListValue(); - option->Append(CreateValue(j)); - option->Append(CreateValue(j)); - list_value->Append(option); - } - localized_strings->Set(GetTemplateDataPropertyName(preference, kI18nPrefix), - list_value); - } -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/language_mozc_options_handler.h b/chrome/browser/chromeos/webui/language_mozc_options_handler.h deleted file mode 100644 index 4db0b39..0000000 --- a/chrome/browser/chromeos/webui/language_mozc_options_handler.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_MOZC_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_MOZC_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/ui/webui/options/options_ui.h" - -class DictionaryValue; - -namespace chromeos { - -// Mozc options page UI handler. -class LanguageMozcOptionsHandler : public OptionsPageUIHandler { - public: - LanguageMozcOptionsHandler(); - virtual ~LanguageMozcOptionsHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - - private: - DISALLOW_COPY_AND_ASSIGN(LanguageMozcOptionsHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_MOZC_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/language_options_util.cc b/chrome/browser/chromeos/webui/language_options_util.cc deleted file mode 100644 index 2f85a4e..0000000 --- a/chrome/browser/chromeos/webui/language_options_util.cc +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/language_options_util.h" - -namespace chromeos { - -// See comments in .h. -Value* CreateValue(const char* in_value) { - return Value::CreateStringValue(in_value); -} - -Value* CreateValue(int in_value) { - return Value::CreateIntegerValue(in_value); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/language_options_util.h b/chrome/browser/chromeos/webui/language_options_util.h deleted file mode 100644 index c4f69a3..0000000 --- a/chrome/browser/chromeos/webui/language_options_util.h +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_OPTIONS_UTIL_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_OPTIONS_UTIL_H_ -#pragma once - -#include <string> - -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/language_preferences.h" -#include "ui/base/l10n/l10n_util.h" - -class ListValue; - -namespace chromeos { - -// Returns an i18n-content value corresponding to |preference|. -template <typename T> -std::string GetI18nContentValue(const T& preference, const char* prefix) { - return std::string(prefix) + preference.ibus_config_name; -} - -// Returns a property name of templateData corresponding to |preference|. -template <typename T> -std::string GetTemplateDataPropertyName(const T& preference, - const char* prefix) { - return std::string(prefix) + preference.ibus_config_name + "Value"; -} - -// Returns an property name of templateData corresponding the value of the min -// attribute. -template <typename T> -std::string GetTemplateDataMinName(const T& preference, const char* prefix) { - return std::string(prefix) + preference.ibus_config_name + "Min"; -} - -// Returns an property name of templateData corresponding the value of the max -// attribute. -template <typename T> -std::string GetTemplateDataMaxName(const T& preference, const char* prefix) { - return std::string(prefix) + preference.ibus_config_name + "Max"; -} - -// Creates a Value object from the given value. Here we use function -// overloading to handle string and integer preferences in -// CreateMultipleChoiceList. -Value* CreateValue(const char* in_value); -Value* CreateValue(int in_value); - -// Creates a multiple choice list from the given preference. -template <typename T> -ListValue* CreateMultipleChoiceList( - const language_prefs::LanguageMultipleChoicePreference<T>& preference) { - int list_length = 0; - for (size_t i = 0; - i < language_prefs::LanguageMultipleChoicePreference<T>::kMaxItems; - ++i) { - if (preference.values_and_ids[i].item_message_id == 0) - break; - ++list_length; - } - DCHECK_GT(list_length, 0); - - ListValue* list_value = new ListValue(); - for (int i = 0; i < list_length; ++i) { - ListValue* option = new ListValue(); - option->Append(CreateValue( - preference.values_and_ids[i].ibus_config_value)); - option->Append(Value::CreateStringValue(l10n_util::GetStringUTF16( - preference.values_and_ids[i].item_message_id))); - list_value->Append(option); - } - return list_value; -} - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_OPTIONS_UTIL_H_ diff --git a/chrome/browser/chromeos/webui/language_pinyin_options_handler.cc b/chrome/browser/chromeos/webui/language_pinyin_options_handler.cc deleted file mode 100644 index 7099406..0000000 --- a/chrome/browser/chromeos/webui/language_pinyin_options_handler.cc +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/language_pinyin_options_handler.h" - -#include "base/values.h" -#include "chrome/browser/chromeos/language_preferences.h" -#include "chrome/browser/chromeos/webui/language_options_util.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" - -namespace { -const char kI18nPrefix[] = "Pinyin"; -} // namespace - -namespace chromeos { - -LanguagePinyinOptionsHandler::LanguagePinyinOptionsHandler() { -} - -LanguagePinyinOptionsHandler::~LanguagePinyinOptionsHandler() { -} - -void LanguagePinyinOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - RegisterTitle(localized_strings, "languagePinyinPage", - IDS_OPTIONS_SETTINGS_LANGUAGES_PINYIN_SETTINGS_TITLE); - - for (size_t i = 0; i < language_prefs::kNumPinyinBooleanPrefs; ++i) { - localized_strings->SetString( - GetI18nContentValue(language_prefs::kPinyinBooleanPrefs[i], - kI18nPrefix), - l10n_util::GetStringUTF16( - language_prefs::kPinyinBooleanPrefs[i].message_id)); - } - - localized_strings->SetString( - GetI18nContentValue(language_prefs::kPinyinDoublePinyinSchema, - kI18nPrefix), - l10n_util::GetStringUTF16( - language_prefs::kPinyinDoublePinyinSchema.label_message_id)); - ListValue* list_value = new ListValue(); - for (size_t i = 0; - i < language_prefs::LanguageMultipleChoicePreference<int>::kMaxItems; - ++i) { - if (language_prefs::kPinyinDoublePinyinSchema.values_and_ids[i]. - item_message_id == 0) - break; - ListValue* option = new ListValue(); - option->Append(Value::CreateIntegerValue( - language_prefs::kPinyinDoublePinyinSchema.values_and_ids[i]. - ibus_config_value)); - option->Append(Value::CreateStringValue(l10n_util::GetStringUTF16( - language_prefs::kPinyinDoublePinyinSchema.values_and_ids[i]. - item_message_id))); - list_value->Append(option); - } - localized_strings->Set( - GetTemplateDataPropertyName(language_prefs::kPinyinDoublePinyinSchema, - kI18nPrefix), - list_value); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/language_pinyin_options_handler.h b/chrome/browser/chromeos/webui/language_pinyin_options_handler.h deleted file mode 100644 index 9a5c378..0000000 --- a/chrome/browser/chromeos/webui/language_pinyin_options_handler.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_PINYIN_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_PINYIN_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/ui/webui/options/options_ui.h" - -class DictionaryValue; - -namespace chromeos { - -// Pinyin options page UI handler. -class LanguagePinyinOptionsHandler : public OptionsPageUIHandler { - public: - LanguagePinyinOptionsHandler(); - virtual ~LanguagePinyinOptionsHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - - private: - DISALLOW_COPY_AND_ASSIGN(LanguagePinyinOptionsHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_LANGUAGE_PINYIN_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/proxy_handler.cc b/chrome/browser/chromeos/webui/proxy_handler.cc deleted file mode 100644 index 6659fe7..0000000 --- a/chrome/browser/chromeos/webui/proxy_handler.cc +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/proxy_handler.h" - -#include "base/basictypes.h" -#include "base/callback.h" -#include "base/stl_util-inl.h" -#include "base/time.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/proxy_cros_settings_provider.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#include "grit/locale_settings.h" -#include "grit/theme_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" - -namespace chromeos { - -ProxyHandler::ProxyHandler() - : CrosOptionsPageUIHandler(new ProxyCrosSettingsProvider()) { -} - -ProxyHandler::~ProxyHandler() { -} - -void ProxyHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - // Proxy page - ChromeOS - localized_strings->SetString("proxyPage", - l10n_util::GetStringUTF16(IDS_OPTIONS_PROXY_TAB_LABEL)); - localized_strings->SetString("proxy_config_title", - l10n_util::GetStringUTF16(IDS_PROXY_CONFIG_TITLE)); - localized_strings->SetString("proxyDirectInternetConnection", - l10n_util::GetStringUTF16(IDS_PROXY_DIRECT_CONNECTION)); - - localized_strings->SetString("proxyManual", - l10n_util::GetStringUTF16(IDS_PROXY_MANUAL_CONFIG)); - localized_strings->SetString("sameProxyProtocols", - l10n_util::GetStringUTF16(IDS_PROXY_SAME_FORALL)); - - localized_strings->SetString("httpProxy", - l10n_util::GetStringUTF16(IDS_PROXY_HTTP_PROXY)); - localized_strings->SetString("secureHttpProxy", - l10n_util::GetStringUTF16(IDS_PROXY_HTTP_SECURE_HTTP_PROXY)); - localized_strings->SetString("ftpProxy", - l10n_util::GetStringUTF16(IDS_PROXY_FTP_PROXY)); - localized_strings->SetString("socksHost", - l10n_util::GetStringUTF16(IDS_PROXY_SOCKS_HOST)); - localized_strings->SetString("proxyAutomatic", - l10n_util::GetStringUTF16(IDS_PROXY_AUTOMATIC)); - localized_strings->SetString("proxyConfigUrl", - l10n_util::GetStringUTF16(IDS_PROXY_CONFIG_URL)); - localized_strings->SetString("advanced_proxy_config", - l10n_util::GetStringUTF16(IDS_PROXY_ADVANCED_CONFIG)); - localized_strings->SetString("addHost", - l10n_util::GetStringUTF16(IDS_PROXY_ADD_HOST)); - localized_strings->SetString("removeHost", - l10n_util::GetStringUTF16(IDS_PROXY_REMOVE_HOST)); - localized_strings->SetString("proxyPort", - l10n_util::GetStringUTF16(IDS_PROXY_PORT)); - localized_strings->SetString("proxyBypass", - l10n_util::GetStringUTF16(IDS_PROXY_BYPASS)); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/proxy_handler.h b/chrome/browser/chromeos/webui/proxy_handler.h deleted file mode 100644 index d531557..0000000 --- a/chrome/browser/chromeos/webui/proxy_handler.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_PROXY_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_PROXY_HANDLER_H_ - -#include "chrome/browser/chromeos/webui/cros_options_page_ui_handler.h" -namespace chromeos { - -// ChromeOS proxy options page UI handler. -class ProxyHandler : public CrosOptionsPageUIHandler { - public: - ProxyHandler(); - virtual ~ProxyHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - - private: - - DISALLOW_COPY_AND_ASSIGN(ProxyHandler); -}; -} // namespace chromeos -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_PROXY_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/stats_options_handler.cc b/chrome/browser/chromeos/webui/stats_options_handler.cc deleted file mode 100644 index 8dcb093..0000000 --- a/chrome/browser/chromeos/webui/stats_options_handler.cc +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/stats_options_handler.h" - -#include "base/basictypes.h" -#include "base/callback.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/cros_settings_names.h" -#include "chrome/browser/chromeos/login/user_manager.h" -#include "chrome/browser/chromeos/metrics_cros_settings_provider.h" -#include "chrome/browser/metrics/user_metrics.h" - -namespace chromeos { - -StatsOptionsHandler::StatsOptionsHandler() - : CrosOptionsPageUIHandler(new MetricsCrosSettingsProvider()) { -} - -// OptionsPageUIHandler implementation. -void StatsOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { -} -void StatsOptionsHandler::Initialize() { - SetupMetricsReportingCheckbox(false); -} - -// WebUIMessageHandler implementation. -void StatsOptionsHandler::RegisterMessages() { - web_ui_->RegisterMessageCallback( - "metricsReportingCheckboxAction", - NewCallback(this, &StatsOptionsHandler::HandleMetricsReportingCheckbox)); -} - -MetricsCrosSettingsProvider* StatsOptionsHandler::provider() const { - return static_cast<MetricsCrosSettingsProvider*>(settings_provider_.get()); -} - -void StatsOptionsHandler::HandleMetricsReportingCheckbox( - const ListValue* args) { -#if defined(GOOGLE_CHROME_BUILD) - const std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); - const bool enabled = (checked_str == "true"); - UserMetricsRecordAction( - enabled ? - UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : - UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); - const bool is_enabled = MetricsCrosSettingsProvider::GetMetricsStatus(); - SetupMetricsReportingCheckbox(enabled == is_enabled); -#endif -} - -void StatsOptionsHandler::SetupMetricsReportingCheckbox(bool user_changed) { -#if defined(GOOGLE_CHROME_BUILD) - FundamentalValue checked(MetricsCrosSettingsProvider::GetMetricsStatus()); - FundamentalValue disabled(!UserManager::Get()->current_user_is_owner()); - FundamentalValue user_has_changed(user_changed); - web_ui_->CallJavascriptFunction( - "options.AdvancedOptions.SetMetricsReportingCheckboxState", checked, - disabled, user_has_changed); -#endif -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/stats_options_handler.h b/chrome/browser/chromeos/webui/stats_options_handler.h deleted file mode 100644 index 36b8bf0..0000000 --- a/chrome/browser/chromeos/webui/stats_options_handler.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_STATS_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_STATS_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/chromeos/webui/cros_options_page_ui_handler.h" - -namespace chromeos { - -class MetricsCrosSettingsProvider; - -// ChromeOS handler for "Stats/crash reporting to Google" option of the Advanced -// settings page. This handler does only ChromeOS-specific actions while default -// code is in Chrome's AdvancedOptionsHandler -// (chrome/browser/webui/advanced_options_handler.cc). -class StatsOptionsHandler : public CrosOptionsPageUIHandler { - public: - StatsOptionsHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - virtual void Initialize(); - - // WebUIMessageHandler implementation. - virtual void RegisterMessages(); - - private: - MetricsCrosSettingsProvider* provider() const; - void HandleMetricsReportingCheckbox(const ListValue* args); - void SetupMetricsReportingCheckbox(bool user_changed); - - DISALLOW_COPY_AND_ASSIGN(StatsOptionsHandler); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_STATS_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/system_options_handler.cc b/chrome/browser/chromeos/webui/system_options_handler.cc deleted file mode 100644 index 027504a..0000000 --- a/chrome/browser/chromeos/webui/system_options_handler.cc +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/system_options_handler.h" - -#include <string> - -#include "base/basictypes.h" -#include "base/callback.h" -#include "base/string_number_conversions.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/chromeos/language_preferences.h" -#include "chrome/browser/chromeos/webui/system_settings_provider.h" -#include "chrome/browser/prefs/pref_service.h" -#include "chrome/common/pref_names.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#include "grit/locale_settings.h" -#include "grit/theme_resources.h" -#include "ui/base/l10n/l10n_util.h" - -SystemOptionsHandler::SystemOptionsHandler() - : chromeos::CrosOptionsPageUIHandler( - new chromeos::SystemSettingsProvider()) { -} - -SystemOptionsHandler::~SystemOptionsHandler() { -} - -void SystemOptionsHandler::GetLocalizedValues( - DictionaryValue* localized_strings) { - DCHECK(localized_strings); - - RegisterTitle(localized_strings, "systemPage", IDS_OPTIONS_SYSTEM_TAB_LABEL); - localized_strings->SetString("datetime_title", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME)); - localized_strings->SetString("timezone", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION)); - - localized_strings->SetString("touchpad", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_TOUCHPAD)); - localized_strings->SetString("enable_tap_to_click", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_TAP_TO_CLICK_ENABLED_DESCRIPTION)); - localized_strings->SetString("sensitivity", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SENSITIVITY_DESCRIPTION)); - localized_strings->SetString("sensitivity_less", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_SENSITIVITY_LESS_DESCRIPTION)); - localized_strings->SetString("sensitivity_more", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION)); - - localized_strings->SetString("language", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_SECTION_TITLE_LANGUAGE)); - localized_strings->SetString("language_customize", - l10n_util::GetStringUTF16(IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE)); - localized_strings->SetString("modifier_keys_customize", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE)); - - localized_strings->SetString("accessibility_title", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY)); - localized_strings->SetString("accessibility", - l10n_util::GetStringUTF16( - IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION)); - - localized_strings->Set("timezoneList", - reinterpret_cast<chromeos::SystemSettingsProvider*>( - settings_provider_.get())->GetTimezoneList()); -} - -void SystemOptionsHandler::Initialize() { - DCHECK(web_ui_); - PrefService* pref_service = g_browser_process->local_state(); - bool acc_enabled = pref_service->GetBoolean(prefs::kAccessibilityEnabled); - FundamentalValue checked(acc_enabled); - web_ui_->CallJavascriptFunction( - "options.SystemOptions.SetAccessibilityCheckboxState", checked); -} - -void SystemOptionsHandler::RegisterMessages() { - DCHECK(web_ui_); - web_ui_->RegisterMessageCallback("accessibilityChange", - NewCallback(this, &SystemOptionsHandler::AccessibilityChangeCallback)); -} - -void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { - std::string checked_str; - args->GetString(0, &checked_str); - bool accessibility_enabled = (checked_str == "true"); - PrefService* pref_service = g_browser_process->local_state(); - pref_service->SetBoolean(prefs::kAccessibilityEnabled, accessibility_enabled); -} diff --git a/chrome/browser/chromeos/webui/system_options_handler.h b/chrome/browser/chromeos/webui/system_options_handler.h deleted file mode 100644 index fa36532..0000000 --- a/chrome/browser/chromeos/webui/system_options_handler.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_SYSTEM_OPTIONS_HANDLER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_SYSTEM_OPTIONS_HANDLER_H_ -#pragma once - -#include "chrome/browser/chromeos/webui/cros_options_page_ui_handler.h" - -class DictionaryValue; - -// ChromeOS system options page UI handler. -class SystemOptionsHandler : public chromeos::CrosOptionsPageUIHandler { - public: - SystemOptionsHandler(); - virtual ~SystemOptionsHandler(); - - // OptionsPageUIHandler implementation. - virtual void GetLocalizedValues(DictionaryValue* localized_strings); - virtual void Initialize(); - - virtual void RegisterMessages(); - - // Called when the accessibility checkbox value is changed. - // |args| will contain the checkbox checked state as a string - // ("true" or "false"). - void AccessibilityChangeCallback(const ListValue* args); - - private: - DISALLOW_COPY_AND_ASSIGN(SystemOptionsHandler); -}; - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_SYSTEM_OPTIONS_HANDLER_H_ diff --git a/chrome/browser/chromeos/webui/system_settings_provider.cc b/chrome/browser/chromeos/webui/system_settings_provider.cc deleted file mode 100644 index c29cca2..0000000 --- a/chrome/browser/chromeos/webui/system_settings_provider.cc +++ /dev/null @@ -1,316 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/system_settings_provider.h" - -#include <string> - -#include "base/i18n/rtl.h" -#include "base/memory/scoped_ptr.h" -#include "base/stl_util-inl.h" -#include "base/string_util.h" -#include "base/stringprintf.h" -#include "base/synchronization/lock.h" -#include "base/time.h" -#include "base/utf_string_conversions.h" -#include "base/values.h" -#include "chrome/browser/chromeos/cros/cros_library.h" -#include "chrome/browser/chromeos/cros_settings.h" -#include "chrome/browser/chromeos/cros_settings_names.h" -#include "chrome/browser/chromeos/login/user_manager.h" -#include "grit/generated_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "unicode/calendar.h" -#include "unicode/timezone.h" -#include "unicode/ures.h" - -namespace { - -// TODO(jungshik): Using Enumerate method in ICU gives 600+ timezones. -// Even after filtering out duplicate entries with a strict identity check, -// we still have 400+ zones. Relaxing the criteria for the timezone -// identity is likely to cut down the number to < 100. Until we -// come up with a better list, we hard-code the following list as used by -// Android. -static const char* kTimeZones[] = { - "Pacific/Majuro", - "Pacific/Midway", - "Pacific/Honolulu", - "America/Anchorage", - "America/Los_Angeles", - "America/Tijuana", - "America/Denver", - "America/Phoenix", - "America/Chihuahua", - "America/Chicago", - "America/Mexico_City", - "America/Costa_Rica", - "America/Regina", - "America/New_York", - "America/Bogota", - "America/Caracas", - "America/Barbados", - "America/Manaus", - "America/Santiago", - "America/St_Johns", - "America/Sao_Paulo", - "America/Araguaina", - "America/Argentina/Buenos_Aires", - "America/Godthab", - "America/Montevideo", - "Atlantic/South_Georgia", - "Atlantic/Azores", - "Atlantic/Cape_Verde", - "Africa/Casablanca", - "Europe/London", - "Europe/Amsterdam", - "Europe/Belgrade", - "Europe/Brussels", - "Europe/Sarajevo", - "Africa/Windhoek", - "Africa/Brazzaville", - "Asia/Amman", - "Europe/Athens", - "Asia/Beirut", - "Africa/Cairo", - "Europe/Helsinki", - "Asia/Jerusalem", - "Europe/Minsk", - "Africa/Harare", - "Asia/Baghdad", - "Europe/Moscow", - "Asia/Kuwait", - "Africa/Nairobi", - "Asia/Tehran", - "Asia/Baku", - "Asia/Tbilisi", - "Asia/Yerevan", - "Asia/Dubai", - "Asia/Kabul", - "Asia/Karachi", - "Asia/Oral", - "Asia/Yekaterinburg", - "Asia/Calcutta", - "Asia/Colombo", - "Asia/Katmandu", - "Asia/Almaty", - "Asia/Rangoon", - "Asia/Krasnoyarsk", - "Asia/Bangkok", - "Asia/Shanghai", - "Asia/Hong_Kong", - "Asia/Irkutsk", - "Asia/Kuala_Lumpur", - "Australia/Perth", - "Asia/Taipei", - "Asia/Seoul", - "Asia/Tokyo", - "Asia/Yakutsk", - "Australia/Adelaide", - "Australia/Darwin", - "Australia/Brisbane", - "Australia/Hobart", - "Australia/Sydney", - "Asia/Vladivostok", - "Pacific/Guam", - "Asia/Magadan", - "Pacific/Auckland", - "Pacific/Fiji", - "Pacific/Tongatapu", -}; - -static base::Lock timezone_bundle_lock; - -struct UResClose { - inline void operator() (UResourceBundle* b) const { - ures_close(b); - } -}; - -string16 GetExemplarCity(const icu::TimeZone& zone) { - // TODO(jungshik): After upgrading to ICU 4.6, use U_ICUDATA_ZONE - static const char* zone_bundle_name = NULL; - - // These will be leaked at the end. - static UResourceBundle *zone_bundle = NULL; - static UResourceBundle *zone_strings = NULL; - - UErrorCode status = U_ZERO_ERROR; - { - base::AutoLock lock(timezone_bundle_lock); - if (zone_bundle == NULL) - zone_bundle = ures_open(zone_bundle_name, uloc_getDefault(), &status); - - if (zone_strings == NULL) - zone_strings = ures_getByKey(zone_bundle, "zone_strings", NULL, &status); - } - - icu::UnicodeString zone_id; - zone.getID(zone_id); - std::string zone_id_str; - zone_id.toUTF8String(zone_id_str); - - // resource keys for timezones use ':' in place of '/'. - ReplaceSubstringsAfterOffset(&zone_id_str, 0, "/", ":"); - scoped_ptr_malloc<UResourceBundle, UResClose> zone_item( - ures_getByKey(zone_strings, zone_id_str.c_str(), NULL, &status)); - icu::UnicodeString city; - if (U_FAILURE(status)) - goto fallback; - city = icu::ures_getUnicodeStringByKey(zone_item.get(), "ec", &status); - if (U_SUCCESS(status)) - return string16(city.getBuffer(), city.length()); - - fallback: - ReplaceSubstringsAfterOffset(&zone_id_str, 0, ":", "/"); - // Take the last component of a timezone id (e.g. 'Baz' in 'Foo/Bar/Baz'). - // Depending on timezones, keeping all but the 1st component - // (e.g. Bar/Baz) may be better, but our current list does not have - // any timezone for which that's the case. - std::string::size_type slash_pos = zone_id_str.rfind('/'); - if (slash_pos != std::string::npos && slash_pos < zone_id_str.size()) - zone_id_str.erase(0, slash_pos + 1); - // zone id has '_' in place of ' '. - ReplaceSubstringsAfterOffset(&zone_id_str, 0, "_", " "); - return ASCIIToUTF16(zone_id_str); -} - -} // namespace anonymous - -namespace chromeos { - -SystemSettingsProvider::SystemSettingsProvider() { - for (size_t i = 0; i < arraysize(kTimeZones); i++) { - timezones_.push_back(icu::TimeZone::createTimeZone( - icu::UnicodeString(kTimeZones[i], -1, US_INV))); - } - CrosLibrary::Get()->GetSystemLibrary()->AddObserver(this); - -} - -SystemSettingsProvider::~SystemSettingsProvider() { - CrosLibrary::Get()->GetSystemLibrary()->RemoveObserver(this); - STLDeleteElements(&timezones_); -} - -void SystemSettingsProvider::DoSet(const std::string& path, Value* in_value) { - // Only the owner can change the time zone. - if (!UserManager::Get()->current_user_is_owner()) - return; - - if (path == kSystemTimezone) { - string16 value; - if (!in_value || !in_value->IsType(Value::TYPE_STRING) || - !in_value->GetAsString(&value)) - return; - const icu::TimeZone* timezone = GetTimezone(value); - if (!timezone) - return; - CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); - } -} - -bool SystemSettingsProvider::Get(const std::string& path, - Value** out_value) const { - if (path == kSystemTimezone) { - *out_value = Value::CreateStringValue(GetKnownTimezoneID( - CrosLibrary::Get()->GetSystemLibrary()->GetTimezone())); - return true; - } - return false; -} - -bool SystemSettingsProvider::HandlesSetting(const std::string& path) { - return ::StartsWithASCII(path, std::string("cros.system."), true); -} - -void SystemSettingsProvider::TimezoneChanged(const icu::TimeZone& timezone) { - // Fires system setting change notification. - CrosSettings::Get()->FireObservers(kSystemTimezone); -} - -ListValue* SystemSettingsProvider::GetTimezoneList() { - ListValue* timezoneList = new ListValue(); - for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin(); - iter != timezones_.end(); ++iter) { - const icu::TimeZone* timezone = *iter; - ListValue* option = new ListValue(); - option->Append(Value::CreateStringValue(GetTimezoneID(*timezone))); - option->Append(Value::CreateStringValue(GetTimezoneName(*timezone))); - timezoneList->Append(option); - } - return timezoneList; -} - -string16 SystemSettingsProvider::GetTimezoneName( - const icu::TimeZone& timezone) { - // Instead of using the raw_offset, use the offset in effect now. - // For instance, US Pacific Time, the offset shown will be -7 in summer - // while it'll be -8 in winter. - int raw_offset, dst_offset; - UDate now = icu::Calendar::getNow(); - UErrorCode status = U_ZERO_ERROR; - timezone.getOffset(now, false, raw_offset, dst_offset, status); - DCHECK(U_SUCCESS(status)); - int offset = raw_offset + dst_offset; - // offset is in msec. - int minute_offset = std::abs(offset) / 60000; - int hour_offset = minute_offset / 60; - int min_remainder = minute_offset % 60; - // Some timezones have a non-integral hour offset. So, we need to - // use hh:mm form. - std::string offset_str = base::StringPrintf(offset >= 0 ? - "UTC+%d:%02d" : "UTC-%d:%02d", hour_offset, min_remainder); - - // TODO(jungshik): When coming up with a better list of timezones, we also - // have to come up with better 'display' names. One possibility is to list - // multiple cities (e.g. "Los Angeles, Vancouver .." in the order of - // the population of a country the city belongs to.). - // We can also think of using LONG_GENERIC or LOCATION once we upgrade - // to ICU 4.6. - // In the meantime, we use "LONG" name with "Exemplar City" to distinguish - // multiple timezones with the same "LONG" name but with different - // rules (e.g. US Mountain Time in Denver vs Phoenix). - icu::UnicodeString name; - timezone.getDisplayName(dst_offset != 0, icu::TimeZone::LONG, name); - string16 result(l10n_util::GetStringFUTF16( - IDS_OPTIONS_SETTINGS_TIMEZONE_DISPLAY_TEMPLATE, ASCIIToUTF16(offset_str), - string16(name.getBuffer(), name.length()), GetExemplarCity(timezone))); - base::i18n::AdjustStringForLocaleDirection(&result); - return result; -} - -string16 SystemSettingsProvider::GetTimezoneID( - const icu::TimeZone& timezone) { - icu::UnicodeString id; - timezone.getID(id); - return string16(id.getBuffer(), id.length()); -} - -const icu::TimeZone* SystemSettingsProvider::GetTimezone( - const string16& timezone_id) { - for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin(); - iter != timezones_.end(); ++iter) { - const icu::TimeZone* timezone = *iter; - if (GetTimezoneID(*timezone) == timezone_id) { - return timezone; - } - } - return NULL; -} - -string16 SystemSettingsProvider::GetKnownTimezoneID( - const icu::TimeZone& timezone) const { - for (std::vector<icu::TimeZone*>::const_iterator iter = timezones_.begin(); - iter != timezones_.end(); ++iter) { - const icu::TimeZone* known_timezone = *iter; - if (known_timezone->hasSameRules(timezone)) - return GetTimezoneID(*known_timezone); - } - - // Not able to find a matching timezone in our list. - return string16(); -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/system_settings_provider.h b/chrome/browser/chromeos/webui/system_settings_provider.h deleted file mode 100644 index 72dba46..0000000 --- a/chrome/browser/chromeos/webui/system_settings_provider.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_SYSTEM_SETTINGS_PROVIDER_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_SYSTEM_SETTINGS_PROVIDER_H_ - -#include <vector> - -#include "base/string16.h" -#include "chrome/browser/chromeos/cros/system_library.h" -#include "chrome/browser/chromeos/cros_settings_provider.h" -#include "third_party/icu/public/i18n/unicode/timezone.h" - -class Value; -class ListValue; - -namespace chromeos { - -class SystemSettingsProvider : public CrosSettingsProvider, - public SystemLibrary::Observer { - public: - SystemSettingsProvider(); - virtual ~SystemSettingsProvider(); - - // CrosSettingsProvider overrides. - virtual bool Get(const std::string& path, Value** out_value) const; - virtual bool HandlesSetting(const std::string& path); - - // Overridden from SystemLibrary::Observer: - virtual void TimezoneChanged(const icu::TimeZone& timezone); - - // Creates the map of timezones used by the options page. - ListValue* GetTimezoneList(); - - private: - // CrosSettingsProvider overrides. - virtual void DoSet(const std::string& path, Value* in_value); - - // Gets timezone name. - static string16 GetTimezoneName(const icu::TimeZone& timezone); - - // Gets timezone ID which is also used as timezone pref value. - static string16 GetTimezoneID(const icu::TimeZone& timezone); - - // Gets timezone object from its id. - const icu::TimeZone* GetTimezone(const string16& timezone_id); - - // Gets a timezone id from a timezone in |timezones_| that has the same - // rule of given |timezone|. - // One timezone could have multiple timezones, - // e.g. - // US/Pacific == America/Los_Angeles - // We should always use the known timezone id when passing back as - // pref values. - string16 GetKnownTimezoneID(const icu::TimeZone& timezone) const; - - // Timezones. - std::vector<icu::TimeZone*> timezones_; - - DISALLOW_COPY_AND_ASSIGN(SystemSettingsProvider); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_SYSTEM_SETTINGS_PROVIDER_H_ diff --git a/chrome/browser/chromeos/webui/user_image_source.cc b/chrome/browser/chromeos/webui/user_image_source.cc deleted file mode 100644 index 3a4b0aa..0000000 --- a/chrome/browser/chromeos/webui/user_image_source.cc +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/chromeos/webui/user_image_source.h" - -#include "base/memory/ref_counted_memory.h" -#include "chrome/browser/chromeos/login/user_manager.h" -#include "chrome/common/url_constants.h" -#include "grit/theme_resources.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/codec/png_codec.h" - -namespace chromeos { - -std::vector<unsigned char> UserImageSource::GetUserImage( - const std::string& email) const { - std::vector<unsigned char> user_image; - chromeos::UserVector users = chromeos::UserManager::Get()->GetUsers(); - for (size_t i = 0; i < users.size(); ++i) { - if (users[i].email() == email) { - gfx::PNGCodec::EncodeBGRASkBitmap(users[i].image(), true, &user_image); - return user_image; - } - } - gfx::PNGCodec::EncodeBGRASkBitmap( - *ResourceBundle::GetSharedInstance().GetBitmapNamed( - IDR_LOGIN_DEFAULT_USER), - true, - &user_image); - return user_image; -} - -UserImageSource::UserImageSource() - : DataSource(chrome::kChromeUIUserImageHost, MessageLoop::current()) { -} - -UserImageSource::~UserImageSource() {} - -void UserImageSource::StartDataRequest(const std::string& path, - bool is_incognito, - int request_id) { - // Strip the query param value - we only use it as a hack to ensure our - // image gets reloaded instead of being pulled from the browser cache - std::string email = path.substr(0, path.find_first_of("?")); - SendResponse(request_id, new RefCountedBytes(GetUserImage(email))); -} - -std::string UserImageSource::GetMimeType(const std::string&) const { - // We need to explicitly return a mime type, otherwise if the user tries to - // drag the image they get no extension. - return "image/png"; -} - -} // namespace chromeos diff --git a/chrome/browser/chromeos/webui/user_image_source.h b/chrome/browser/chromeos/webui/user_image_source.h deleted file mode 100644 index d68a4c8..0000000 --- a/chrome/browser/chromeos/webui/user_image_source.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_CHROMEOS_WEBUI_USER_IMAGE_SOURCE_H_ -#define CHROME_BROWSER_CHROMEOS_WEBUI_USER_IMAGE_SOURCE_H_ -#pragma once - -#include <string> -#include <vector> - -#include "base/basictypes.h" -#include "chrome/browser/ui/webui/chrome_url_data_manager.h" - -namespace chromeos { - -// UserImageSource is the data source that serves user images for users that -// have it. -class UserImageSource : public ChromeURLDataManager::DataSource { - public: - UserImageSource(); - - // Called when the network layer has requested a resource underneath - // the path we registered. - virtual void StartDataRequest(const std::string& path, - bool is_incognito, - int request_id); - - virtual std::string GetMimeType(const std::string&) const; - - // Returns PNG encoded image for user with specified email. - // If there's no user with such email, returns the default image. - std::vector<unsigned char> GetUserImage(const std::string& email) const; - - private: - virtual ~UserImageSource(); - - DISALLOW_COPY_AND_ASSIGN(UserImageSource); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_WEBUI_USER_IMAGE_SOURCE_H_ |