summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/chromeos/dom_ui/system_options_handler.cc27
-rw-r--r--chrome/browser/chromeos/dom_ui/system_options_handler.h4
-rw-r--r--chrome/browser/dom_ui/core_options_handler.cc79
-rw-r--r--chrome/browser/dom_ui/core_options_handler.h6
-rw-r--r--chrome/browser/dom_ui/options_ui.cc4
-rw-r--r--chrome/browser/resources/options.html270
-rw-r--r--chrome/browser/resources/options/chromeos_system_options.html68
-rw-r--r--chrome/browser/resources/options/chromeos_system_options.js41
-rw-r--r--chrome/browser/resources/options/options_page.js99
-rw-r--r--chrome/browser/resources/options/pref_ui.js160
-rw-r--r--chrome/browser/resources/options/preferences.js147
-rwxr-xr-xtools/grit/grit/format/html_inline.py9
12 files changed, 691 insertions, 223 deletions
diff --git a/chrome/browser/chromeos/dom_ui/system_options_handler.cc b/chrome/browser/chromeos/dom_ui/system_options_handler.cc
index 3246902..4d16972 100644
--- a/chrome/browser/chromeos/dom_ui/system_options_handler.cc
+++ b/chrome/browser/chromeos/dom_ui/system_options_handler.cc
@@ -97,33 +97,36 @@ void SystemOptionsHandler::GetLocalizedValues(
localized_strings->SetString(L"accessibility",
l10n_util::GetString(IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION));
- localized_strings->Set(L"timezoneMap", GetTimezoneMap());
+ localized_strings->Set(L"timezoneList", GetTimezoneList());
}
-DictionaryValue* SystemOptionsHandler::GetTimezoneMap() {
- DictionaryValue* timezoneMap = new DictionaryValue();
+ListValue* SystemOptionsHandler::GetTimezoneList() {
+ ListValue* timezoneList = new ListValue();
for (std::vector<icu::TimeZone*>::iterator iter = timezones_.begin();
iter != timezones_.end(); ++iter) {
const icu::TimeZone* timezone = *iter;
- timezoneMap->SetString(GetTimezoneID(timezone).c_str(),
- GetTimezoneName(timezone));
+ static const std::wstring delimiter(L"|");
+ std::wstring value = GetTimezoneID(timezone);
+ value += delimiter;
+ value += GetTimezoneName(timezone);
+ timezoneList->Append(Value::CreateStringValue(value));
}
- return timezoneMap;
+ return timezoneList;
}
-std::string SystemOptionsHandler::GetTimezoneName(
+std::wstring SystemOptionsHandler::GetTimezoneName(
const icu::TimeZone* timezone) {
DCHECK(timezone);
icu::UnicodeString name;
timezone->getDisplayName(name);
- std::string output;
- UTF16ToUTF8(name.getBuffer(), name.length(), &output);
+ std::wstring output;
+ UTF16ToWide(name.getBuffer(), name.length(), &output);
int hour_offset = timezone->getRawOffset() / 3600000;
- const char* format;
+ const wchar_t* format;
if (hour_offset == 0)
- format = "(GMT) ";
+ format = L"(GMT) ";
else
- format = "(GMT%+d) ";
+ format = L"(GMT%+d) ";
return StringPrintf(format, hour_offset) + output;
}
diff --git a/chrome/browser/chromeos/dom_ui/system_options_handler.h b/chrome/browser/chromeos/dom_ui/system_options_handler.h
index 488eccd..c21d5b0 100644
--- a/chrome/browser/chromeos/dom_ui/system_options_handler.h
+++ b/chrome/browser/chromeos/dom_ui/system_options_handler.h
@@ -22,10 +22,10 @@ class SystemOptionsHandler : public OptionsPageUIHandler {
private:
// Creates the map of timezones used by the options page.
- DictionaryValue* GetTimezoneMap();
+ ListValue* GetTimezoneList();
// Gets timezone name.
- std::string GetTimezoneName(const icu::TimeZone* timezone);
+ std::wstring GetTimezoneName(const icu::TimeZone* timezone);
// Gets timezone ID which is also used as timezone pref value.
std::wstring GetTimezoneID(const icu::TimeZone* timezone);
diff --git a/chrome/browser/dom_ui/core_options_handler.cc b/chrome/browser/dom_ui/core_options_handler.cc
index d040d7f..5853d4f 100644
--- a/chrome/browser/dom_ui/core_options_handler.cc
+++ b/chrome/browser/dom_ui/core_options_handler.cc
@@ -21,6 +21,21 @@
CoreOptionsHandler::CoreOptionsHandler() {
}
+CoreOptionsHandler::~CoreOptionsHandler() {
+ // Remove registered preference change notification observers.
+ DCHECK(dom_ui_);
+ PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs();
+ std::wstring last_pref;
+ for (PreferenceCallbackMap::const_iterator iter = pref_callback_map_.begin();
+ iter != pref_callback_map_.end();
+ ++iter) {
+ if (last_pref != iter->first) {
+ pref_service->RemovePrefObserver(iter->first.c_str(), this);
+ last_pref = iter->first;
+ }
+ }
+}
+
void CoreOptionsHandler::GetLocalizedValues(
DictionaryValue* localized_strings) {
DCHECK(localized_strings);
@@ -55,7 +70,7 @@ void CoreOptionsHandler::RegisterMessages() {
dom_ui_->RegisterMessageCallback("fetchPrefs",
NewCallback(this, &CoreOptionsHandler::HandleFetchPrefs));
dom_ui_->RegisterMessageCallback("observePrefs",
- NewCallback(this, &CoreOptionsHandler::HandleFetchPrefs));
+ NewCallback(this, &CoreOptionsHandler::HandleObservePefs));
dom_ui_->RegisterMessageCallback("setBooleanPref",
NewCallback(this, &CoreOptionsHandler::HandleSetBooleanPref));
dom_ui_->RegisterMessageCallback("setIntegerPref",
@@ -71,10 +86,9 @@ void CoreOptionsHandler::HandleFetchPrefs(const Value* value) {
const ListValue* param_values = static_cast<const ListValue*>(value);
- // First param is name of callback function, the second one is the value of
- // context that is just passed through - so, there needs to be at least one
- // more for the actual preference identifier.
- const size_t kMinFetchPrefsParamCount = 3;
+ // First param is name of callback function, so, there needs to be at least
+ // one more element for the actual preference identifier.
+ const size_t kMinFetchPrefsParamCount = 2;
if (param_values->GetSize() < kMinFetchPrefsParamCount)
return;
@@ -89,18 +103,13 @@ void CoreOptionsHandler::HandleFetchPrefs(const Value* value) {
if (!callback->GetAsString(&callback_function))
return;
- // Get context param (just passthrough value)
- Value* context;
- if (!param_values->Get(1, &context) || !context)
- return;
-
// Get the list of name for prefs to build the response dictionary.
DictionaryValue result_value;
Value* list_member;
DCHECK(dom_ui_);
PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs();
- for (size_t i = 2; i < param_values->GetSize(); i++) {
+ for (size_t i = 1; i < param_values->GetSize(); i++) {
if (!param_values->Get(i, &list_member))
break;
@@ -116,8 +125,7 @@ void CoreOptionsHandler::HandleFetchPrefs(const Value* value) {
result_value.Set(pref_name.c_str(),
pref ? pref->GetValue()->DeepCopy() : Value::CreateNullValue());
}
- dom_ui_->CallJavascriptFunction(callback_function.c_str(), *context,
- result_value);
+ dom_ui_->CallJavascriptFunction(callback_function.c_str(), result_value);
}
void CoreOptionsHandler::HandleObservePefs(const Value* value) {
@@ -128,19 +136,37 @@ void CoreOptionsHandler::HandleObservePefs(const Value* value) {
PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs();
DictionaryValue result_value;
const ListValue* list_value = static_cast<const ListValue*>(value);
- Value* list_member;
- for (size_t i = 0; i < list_value->GetSize(); i++) {
+
+ // First param is name is JS callback function name, the rest are pref
+ // identifiers that we are observing.
+ const size_t kMinObservePrefsParamCount = 2;
+ if (list_value->GetSize() < kMinObservePrefsParamCount)
+ return;
+
+ // Get preference change callback function name.
+ std::wstring callback_func_name;
+ Value* list_member = 0;
+ if (!list_value->Get(0, &list_member) ||
+ !list_member->IsType(Value::TYPE_STRING) ||
+ !list_member->GetAsString(&callback_func_name))
+ return;
+
+ // Get all other parameters - pref identifiers.
+ for (size_t i = 1; i < list_value->GetSize(); i++) {
if (!list_value->Get(i, &list_member))
break;
- if (!list_member->IsType(Value::TYPE_STRING))
- continue;
-
+ // Just ignore bad pref identifiers for now.
std::wstring pref_name;
- if (!list_member->GetAsString(&pref_name))
+ if (!list_member->IsType(Value::TYPE_STRING) ||
+ !list_member->GetAsString(&pref_name))
continue;
- pref_service->AddPrefObserver(pref_name.c_str(), this);
+ if (pref_callback_map_.find(pref_name) == pref_callback_map_.end())
+ pref_service->AddPrefObserver(pref_name.c_str(), this);
+
+ pref_callback_map_.insert(
+ PreferenceCallbackMap::value_type(pref_name, callback_func_name));
}
}
@@ -201,13 +227,20 @@ void CoreOptionsHandler::HandleSetPref(const Value* value,
}
void CoreOptionsHandler::NotifyPrefChanged(const std::wstring* pref_name) {
+ DCHECK(pref_name);
DCHECK(dom_ui_);
PrefService* pref_service = dom_ui_->GetProfile()->GetPrefs();
const PrefService::Preference* pref =
pref_service->FindPreference(pref_name->c_str());
if (pref) {
- DictionaryValue result_value;
- result_value.Set(pref_name->c_str(), pref->GetValue()->DeepCopy());
- dom_ui_->CallJavascriptFunction(L"prefsChanged", result_value);
+ for (PreferenceCallbackMap::const_iterator iter =
+ pref_callback_map_.find(*pref_name);
+ iter != pref_callback_map_.end(); ++iter) {
+ const std::wstring& callback_function = iter->second;
+ ListValue result_value;
+ result_value.Append(Value::CreateStringValue(pref_name->c_str()));
+ result_value.Append(pref->GetValue()->DeepCopy());
+ dom_ui_->CallJavascriptFunction(callback_function, result_value);
+ }
}
}
diff --git a/chrome/browser/dom_ui/core_options_handler.h b/chrome/browser/dom_ui/core_options_handler.h
index a71489f..370f1f1 100644
--- a/chrome/browser/dom_ui/core_options_handler.h
+++ b/chrome/browser/dom_ui/core_options_handler.h
@@ -5,6 +5,9 @@
#ifndef CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_
#define CHROME_BROWSER_DOM_UI_CORE_OPTIONS_HANDLER_H_
+#include <map>
+#include <string>
+
#include "base/values.h"
#include "chrome/browser/dom_ui/options_ui.h"
@@ -13,6 +16,7 @@
class CoreOptionsHandler : public OptionsPageUIHandler {
public:
CoreOptionsHandler();
+ virtual ~CoreOptionsHandler();
// OptionsUIHandler implementation.
virtual void GetLocalizedValues(DictionaryValue* localized_strings);
@@ -26,6 +30,7 @@ class CoreOptionsHandler : public OptionsPageUIHandler {
virtual void RegisterMessages();
private:
+ typedef std::multimap<std::wstring, std::wstring> PreferenceCallbackMap;
// Callback for the "fetchPrefs" message. This message accepts the list of
// preference names passed as |value| parameter (ListValue). It passes results
// dictionary of preference values by calling prefsFetched() JS method on the
@@ -47,6 +52,7 @@ class CoreOptionsHandler : public OptionsPageUIHandler {
void NotifyPrefChanged(const std::wstring* pref_name);
+ PreferenceCallbackMap pref_callback_map_;
DISALLOW_COPY_AND_ASSIGN(CoreOptionsHandler);
};
diff --git a/chrome/browser/dom_ui/options_ui.cc b/chrome/browser/dom_ui/options_ui.cc
index 2994e7c..19897d8 100644
--- a/chrome/browser/dom_ui/options_ui.cc
+++ b/chrome/browser/dom_ui/options_ui.cc
@@ -71,7 +71,7 @@ void OptionsUIHTMLSource::StartDataRequest(const std::string& path,
////////////////////////////////////////////////////////////////////////////////
//
-// OptionsUIHandler
+// OptionsPageUIHandler
//
////////////////////////////////////////////////////////////////////////////////
@@ -90,7 +90,7 @@ void OptionsPageUIHandler::UserMetricsRecordAction(
////////////////////////////////////////////////////////////////////////////////
//
-// OptionsUIContents
+// OptionsUI
//
////////////////////////////////////////////////////////////////////////////////
diff --git a/chrome/browser/resources/options.html b/chrome/browser/resources/options.html
index 8bdec64..d120b25 100644
--- a/chrome/browser/resources/options.html
+++ b/chrome/browser/resources/options.html
@@ -3,31 +3,45 @@
<head>
<meta charset="utf-8">
<title i18n-content="title"></title>
+
+<!-- TODO(zelidrag) need a better icon here -->
<link rel="icon" href="../../app/theme/history_favicon.png">
-<script src="shared/js/local_strings.js"></script>
+
+<script src="chrome://resources/js/class_list.js"></script>
+<script src="chrome://resources/js/cr.js"></script>
+<script src="chrome://resources/js/cr/event_target.js"></script>
+<script src="chrome://resources/js/cr/ui.js"></script>
+<script src="chrome://resources/js/local_strings.js"></script>
+<script src="chrome://resources/js/util.js"></script>
+<script src="options/preferences.js"></script>
+<script src="options/pref_ui.js"></script>
+<script src="options/options_page.js"></script>
+<script src="options/chromeos_system_options.js"></script>
<script>
-///////////////////////////////////////////////////////////////////////////////
-// Globals:
-function $(o) {return document.getElementById(o);}
+///////////////////////////////////////////////////////////////////////////////
+// DummyOptions Functions:
+// TODO(zelidrag): Remove DummyOptions once we put the second page in.
-// Extracts preference value out of reponse callback of fetchPrefs call.
-function getPref(dict, name) {
- return eval('dict.'+name);
+function DummyOptions(model) {
+ OptionsPage.call(this, 'dummy', 'Dummy Options Page', 'dummyPage');
}
-// Sets new value for preference.
-function setBooleanPref(name, value) {
- chrome.send('setBooleanPref', [name, String(value)]);
-}
+DummyOptions.instance = null;
-function setIntegerPref(name, value) {
- chrome.send('setIntegerPref', [name, String(value)]);
+DummyOptions.getInstance = function() {
+ if (DummyOptions.instance)
+ return DummyOptions.instance;
+ // TODO(zelidrag): hook model in.
+ DummyOptions.instance = new DummyOptions(null);
+ return DummyOptions.instance;
}
-function setStringPref(name, value) {
- chrome.send('setStringPref', [name, value]);
-}
+// Inherit SystemOptions from OptionsPage.
+DummyOptions.prototype = {
+ __proto__: OptionsPage.prototype,
+};
+
///////////////////////////////////////////////////////////////////////////////
// Document Functions:
/**
@@ -35,224 +49,112 @@ function setStringPref(name, value) {
*/
function load() {
localStrings = new LocalStrings();
- loadSystemPrefs();
-
- selectPage('system');
- // TODO(zelidrag): preserve first that needs to be shown.
-}
-
-function selectPage(name) {
- var page = $(name+'Page');
- var nav = $(name+'PageNav');
- page.style.visibility = 'visible';
- nav.class = 'navbar_item navbar_item_selected';
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// System (ChromeOS) Functions:
-
-var kTimeZone = 'settings.datetime.timezone';
-var kTapToClickEnabled = 'settings.touchpad.enable_tap_to_click';
-var kVertEdgeScrollEnabled = 'settings.touchpad.enable_vert_edge_scroll';
-var kTouchpadSpeedFactor = 'settings.touchpad.speed_factor';
-var kTouchpadSensitivity = 'settings.touchpad.sensitivity';
-var kAccessibilityEnabled = 'settings.accessibility';
-
-/**
- * Loads ChromeOS System preferences.
- */
-function loadSystemPrefs() {
- chrome.send("fetchPrefs", ['systemPrefsFetched', '',
- kTimeZone,
- kTapToClickEnabled,
- kVertEdgeScrollEnabled,
- kTouchpadSpeedFactor,
- kTouchpadSensitivity,
- kAccessibilityEnabled]);
-}
+ OptionsPage.register(SystemOptions.getInstance());
+ OptionsPage.register(DummyOptions.getInstance());
-function setupTimezones(selectedValue) {
- timezoneSel = $('timezoneSel');
- for (key in templateData.timezoneMap) {
- var selected = key == selectedValue;
- timezoneSel.options[timezoneSel.options.length] =
- new Option(templateData.timezoneMap[key], key, false, selected);
- }
+ Preferences.getInstance().initialize();
+ OptionsPage.showPageByName(SystemOptions.getInstance().name);
}
-function systemPrefsFetched(context, dict) {
- $('tapToClickChk').checked = getPref(dict, kTapToClickEnabled);
- $('vertScrollChk').checked = getPref(dict, kVertEdgeScrollEnabled);
- $('sensitivityRng').value = getPref(dict, kTouchpadSensitivity);
- $('speedRng').value = getPref(dict, kTouchpadSpeedFactor);
- $('accesibilityChk').checked = getPref(dict, kAccessibilityEnabled);
- setupTimezones(getPref(dict, kTimeZone));
-}
-
-function selectChanged(control) {
- if (control.id == 'timezoneSel') {
- setStringPref(kTimeZone, control.options[control.selectedIndex].value);
- }
-}
-
-function checkboxChanged(control) {
- if (control.id == 'tapToClickChk') {
- setBooleanPref(kTapToClickEnabled, control.checked);
- } else if (control.id == 'vertScrollChk') {
- setBooleanPref(kVertEdgeScrollEnabled, control.checked);
- } else if (control.id == 'vertScrollChk') {
- setBooleanPref(kTapToClickEnabled, control.checked);
- } else if (control.id == 'accesibilityChk') {
- setBooleanPref(kAccessibilityEnabled, control.checked);
- }
-}
-
-function rangeChanged(control) {
- if (control.id == 'sensitivityRng') {
- setIntegerPref(kTouchpadSensitivity, control.value);
- } else if (control.id == 'speedRng') {
- setIntegerPref(kTouchpadSpeedFactor, control.value);
- }
-}
-
-function buttonClicked(control) {
- if (conrol.id == 'languageBtn') {
- // TODO: Open ChromeOS language settings page.
- }
-}
+window.onpopstate = function(e) {
+ OptionsPage.setState(e.state);
+};
</script>
<link rel="stylesheet" href="dom_ui.css">
<!-- TODO(zelidrag) just a temp style placeholder until redesign -->
<style>
-.navbar_container {
+#main-content {
+ display: -webkit-box;
+}
+
+#navbar-container {
border: 1px solid black;
background-color: #dfdfdf;
- cursor:pointer;
+ cursor: pointer;
font-weight: bold;
- float:left;
height: 400px;
padding: 10px;
- position:relative;
+ position: relative;
width: 200px;
}
-.navbar_item, .navbar_item2 {
+
+.navbar-item, .navbar-item2 {
margin: 5px;
padding: 5px;
}
-.navbar_item_selected {
- background-color: #000000;
+
+.navbar-item-selected {
+ background-color: #FFFFFF;
}
-.navbar_item_normal {
- background-color: #dfdfdf;
+
+.navbar-item-normal {
+ background-color: #dfdfdf;
}
+
#mainview {
+ -webkit-box-align: stretch;
border: 1px solid black;
- float:left;
height: 400px;
width: 600px;
padding: 10px;
- position:relative;
+ position: relative;
}
+
.section {
margin-top: 10px;
}
+
.option {
margin-top: 5px;
}
-.section_title {
+
+.section-title {
font-weight: bold;
}
-.option_control_table {
- padding-left:10px;
+
+.option-control-table {
+ margin-top: 5px;
+ -webkit-padding-start: 10px;
}
-.navbar2 {
+
+.hidden {
visibility: hidden;
}
-.page {
- visibility: hidden;
+
+.touch-slider {
+ -webkit-appearance: slider-horizontal;
}
+
</style>
</head>
-<body onload="load();" i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
+<body onload="load();"
+ i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<div class="header">
</div>
-<div class="main">
- <div class="navbar_container">
- <ul class="navbar">
- <li class="navbar_item navbar_item_normal" id="systemPageNav" i18n-values=".innerText:systemPage"></li>
- <li class="navbar_item navbar_item_normal" id="internetPageNav" i18n-values=".innerText:internetPage"></li>
- <li class="navbar_item navbar_item_normal" id="basicsPageNav" i18n-values=".innerText:basicsPage"></li>
- <li class="navbar_item navbar_item_normal" id="personalStuffPageNav" i18n-values=".innerText:personalStuffPage"></li>
- <li class="navbar_item navbar_item_normal" id="underHoodPageNav" i18n-values=".innerText:underHoodPage"></li>
+<div id="main-content">
+ <div id="navbar-container">
+ <ul id="navbar">
</ul>
<hr/>
- <ul class="navbar2">
+ <ul class="hidden">
</ul>
</div>
<div id="mainview">
- <div class="page" id="systemPage">
- <div class="section">
- <div class="section_title" i18n-values=".innerText:datetime_title"></div>
- <div class="option">
- <table class="option_control_table">
- <tr>
- <td class="option_name" i18n-values=".innerText:timezone"></td>
- <td class="option_value">
- <select id="timezoneSel" class="control timezone_dropdown" onchange="selectChanged(this)"></select>
- </td>
- </tr>
- </table>
- </div>
- </div>
- <div class="section">
- <div class="section_title" i18n-values=".innerText:touchpad"></div>
- <div class="option">
- <table class="option_control_table">
- <tr>
- <td class="option_name" i18n-values=".innerText:sensitivity"></td>
- <td class="option_value">
- <input id="sensitivityRng" type="range" min="1" max="10" class="touchSlider" style="-webkit-appearance:slider-horizontal;" onchange="rangeChanged(this)">
- </td>
- </tr>
- <tr>
- <td class="option_name" i18n-values=".innerText:speed_factor"></td>
- <td class="option_value">
- <input id="speedRng" type="range" min="1" max="10" class="touchSlider" style="-webkit-appearance:slider-horizontal;" onchange="rangeChanged(this)">
- </td>
- </tr>
- <tr>
- <td class="option_name" colspan="2"><input id="tapToClickChk" type="checkbox" onchange="checkboxChanged(this)"/><span i18n-values=".innerText:enable_tap_to_click"></span></td>
- </tr>
- <tr>
- <td class="option_name" colspan="2"><input id="vertScrollChk" type="checkbox" onchange="checkboxChanged(this)"/><span i18n-values=".innerText:enable_vert_edge_scroll"></span></td>
- </tr>
- </table>
- </div>
- </div>
- <div class="section">
- <div class="section_title" i18n-values=".innerText:language"></div>
- <div class="option">
- <table class="option_control_table">
- <tr>
- <td class="option_name"><button id="languageBtn" onclick="buttonClicked" i18n-values=".innerText:language_customize"></button></td>
- </tr>
- </table>
- </div>
- </div>
- <div class="section">
- <div class="section_title" i18n-values=".innerText:accessibility_title"></div>
- <div class="option">
- <table class="option_control_table">
- <tr>
- <td class="option_name"><input id="accesibilityChk" onchange="checkboxChanged(this)" type="checkbox"/><span i18n-values=".innerText:accessibility"></span></td>
- </tr>
- </table>
- </div>
- </div>
+ <!-- include file="options/chromeos_system_options.html" -->
+ <div class="page hidden" id="dummyPage">
+ <!-- TODO(zelidrag): remove this one once we get another page here -->
+ Dummy page
</div>
</div>
</div>
+<script>
+// Decorate the existing elements in the document.
+cr.ui.decorate('input[pref][type=checkbox]', PrefCheckbox);
+cr.ui.decorate('input[pref][type=range]', PrefRange);
+cr.ui.decorate('select[pref]', PrefSelect);
+<!-- TODO(zelidrag) add other elements here when we implement them -->
+</script>
</body>
</html>
diff --git a/chrome/browser/resources/options/chromeos_system_options.html b/chrome/browser/resources/options/chromeos_system_options.html
new file mode 100644
index 0000000..3d19fba
--- /dev/null
+++ b/chrome/browser/resources/options/chromeos_system_options.html
@@ -0,0 +1,68 @@
+<div class="page hidden" id="systemPage">
+ <div class="section">
+ <div class="section-title" i18n-content="datetime_title"></div>
+ <div class="option">
+ <table class="option-control-table">
+ <tr>
+ <td class="option-name" i18n-content="timezone"></td>
+ <td class="option-value">
+ <select id="timezone-select" class="control"
+ pref="settings.datetime.timezone"></select>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </div>
+ <div class="section">
+ <div class="section-title" i18n-content="touchpad"></div>
+ <table class="option-control-table">
+ <tr>
+ <td class="option-name" i18n-content="sensitivity"></td>
+ <td class="option-value">
+ <input id="sensitivity-range" type="range" min="1" max="10"
+ pref="settings.touchpad.sensitivity" class="touch-slider">
+ </td>
+ </tr>
+ <tr>
+ <td class="option-name" i18n-content="speed_factor"></td>
+ <td class="option-value">
+ <input id="speed-range" type="range" min="1" max="10"
+ pref="settings.touchpad.speed_factor" class="touch-slider">
+ </td>
+ </tr>
+ <tr>
+ <td class="option-name" colspan="2"><label><input
+ id="tap-to-click-check"
+ pref="settings.touchpad.enable_tap_to_click"
+ type="checkbox"><span i18n-content="enable_tap_to_click"></span></label></td>
+ </tr>
+ <tr>
+ <td class="option-name" colspan="2"><label><input
+ id="vert-scroll-check"
+ pref="settings.touchpad.enable_vert_edge_scroll"
+ type="checkbox"><span
+ i18n-content="enable_vert_edge_scroll"></span></label></td>
+ </tr>
+ </table>
+ </div>
+ <div class="section">
+ <div class="section-title" i18n-content="language"></div>
+ <table class="option-control-table">
+ <tr>
+ <td class="option-name"><button id="language-button"
+ i18n-content="language_customize"></button>
+ </td>
+ </tr>
+ </table>
+ </div>
+ <div class="section">
+ <div class="section-title" i18n-content="accessibility_title"></div>
+ <table class="option-control-table">
+ <tr>
+ <td class="option-name"><label><input id="accesibility-check"
+ pref="settings.accessibility" type="checkbox"><span
+ i18n-content="accessibility"></span></label></td>
+ </tr>
+ </table>
+ </div>
+</div>
diff --git a/chrome/browser/resources/options/chromeos_system_options.js b/chrome/browser/resources/options/chromeos_system_options.js
new file mode 100644
index 0000000..3741233
--- /dev/null
+++ b/chrome/browser/resources/options/chromeos_system_options.js
@@ -0,0 +1,41 @@
+// Copyright (c) 2010 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.
+
+///////////////////////////////////////////////////////////////////////////////
+// SystemOptions class:
+
+/**
+ * Encapsulated handling of ChromeOS system options page.
+ * @constructor
+ */
+function SystemOptions(model) {
+ OptionsPage.call(this, 'system', templateData.systemPage, 'systemPage');
+}
+
+SystemOptions.getInstance = function() {
+ if (SystemOptions.instance_)
+ return SystemOptions.instance_;
+ SystemOptions.instance_ = new SystemOptions(null);
+ return SystemOptions.instance_;
+}
+
+// Inherit SystemOptions from OptionsPage.
+SystemOptions.prototype = {
+ __proto__: OptionsPage.prototype,
+
+ /**
+ * Initializes SystemOptions page.
+ * Calls base class implementation to starts preference initialization.
+ */
+ initializePage: function() {
+ OptionsPage.prototype.initializePage.call(this);
+ var timezone = $('timezone-select');
+ timezone.initializeValues(templateData.timezoneList);
+
+ $('language-button').onclick = function(event) {
+ // TODO: Open ChromeOS language settings page.
+ };
+ },
+};
+
diff --git a/chrome/browser/resources/options/options_page.js b/chrome/browser/resources/options/options_page.js
new file mode 100644
index 0000000..0962e65
--- /dev/null
+++ b/chrome/browser/resources/options/options_page.js
@@ -0,0 +1,99 @@
+// Copyright (c) 2010 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.
+
+///////////////////////////////////////////////////////////////////////////////
+// OptionsPage class:
+
+/**
+ * Base class for options page.
+ * @constructor
+ * @param {string} name Options page name, also defines id of the div element
+ * containing the options view and the name of options page navigation bar
+ * item as name+'PageNav'.
+ * @param {string} title Options page title, used for navigation bar
+ */
+function OptionsPage(name, title, pageDivName) {
+ this.name = name;
+ this.title = title;
+ this.pageDivName = pageDivName;
+ this.pageDiv = $(this.pageDivName);
+ this.tab = null;
+}
+
+OptionsPage.registeredPages_ = {};
+
+/**
+ * Shows a registered page.
+ * @param {string} pageName Page name.
+ */
+OptionsPage.showPageByName = function(pageName) {
+ for (var name in OptionsPage.registeredPages_) {
+ var page = OptionsPage.registeredPages_[name];
+ page.visible = name == pageName;
+ }
+};
+
+OptionsPage.setState = function(state) {
+ if (state.pageName)
+ OptionsPage.showPageByName(state.pageName);
+};
+
+/**
+ * Registers new options page.
+ * @param {OptionsPage} page Page to register, must be of a class derived from
+ * OptionsPage.
+ */
+OptionsPage.register = function(page) {
+ OptionsPage.registeredPages_[page.name] = page;
+ // Create and add new page <li> element to navbar.
+ var pageNav = document.createElement('li');
+ pageNav.id = page.name + 'PageNav';
+ pageNav.className = 'navbar-item';
+ pageNav.setAttribute('pageName', page.name);
+ pageNav.textContent = page.title;
+ pageNav.onclick = function(event) {
+ OptionsPage.showPageByName(this.getAttribute('pageName'));
+ };
+ var navbar = $('navbar');
+ navbar.appendChild(pageNav);
+ page.tab = pageNav;
+ page.initializePage();
+};
+
+OptionsPage.prototype = {
+ /**
+ * Initializes page content.
+ */
+ initializePage: function() {},
+
+ /**
+ * Gets page visibility state.
+ */
+ get visible() {
+ var page = $(this.pageDivName);
+ return page.ownerDocument.defaultView.getComputedStyle(
+ page).visibility == 'visible';
+ },
+
+ /**
+ * Sets page visibility.
+ */
+ set visible(visible) {
+ if ((this.visible && visible) || (!this.visible && !visible))
+ return;
+
+ if (visible) {
+ window.history.pushState({pageName: this.name},
+ this.title,
+ '/' + this.name);
+ this.pageDiv.style.visibility = 'visible';
+ this.tab.classList.add('navbar-item-selected');
+ } else {
+ this.pageDiv.style.visibility = 'hidden';
+ this.tab.classList.remove('navbar-item-selected');
+ }
+ }
+};
+
+
diff --git a/chrome/browser/resources/options/pref_ui.js b/chrome/browser/resources/options/pref_ui.js
new file mode 100644
index 0000000..7d8eb35
--- /dev/null
+++ b/chrome/browser/resources/options/pref_ui.js
@@ -0,0 +1,160 @@
+// Copyright (c) 2010 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.
+
+///////////////////////////////////////////////////////////////////////////////
+// PrefCheckbox class:
+
+// Define a constructor that uses an input element as its underlying element.
+var PrefCheckbox = cr.ui.define('input');
+
+PrefCheckbox.prototype = {
+ // Set up the prototype chain
+ __proto__: HTMLInputElement.prototype,
+
+ /**
+ * Initialization function for the cr.ui framework.
+ */
+ decorate: function() {
+ this.type = 'checkbox';
+ var self = this;
+
+ // Listen to pref changes.
+ Preferences.getInstance().addEventListener(this.pref,
+ function(event) {
+ self.checked = event.value;
+ });
+
+ // Listen to user events.
+ this.addEventListener('click',
+ function(e) {
+ Preferences.setBooleanPref(self.pref,
+ self.checked);
+ });
+ },
+
+ /**
+ * Getter for preference name attribute.
+ */
+ get pref() {
+ return this.getAttribute('pref');
+ },
+
+ /**
+ * Setter for preference name attribute.
+ */
+ set pref(name) {
+ this.setAttribute('pref', name);
+ }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// PrefRange class:
+
+// Define a constructor that uses an input element as its underlying element.
+var PrefRange = cr.ui.define('input');
+
+PrefRange.prototype = {
+ // Set up the prototype chain
+ __proto__: HTMLInputElement.prototype,
+
+ /**
+ * Initialization function for the cr.ui framework.
+ */
+ decorate: function() {
+ this.type = 'range';
+ var self = this;
+
+ // Listen to pref changes.
+ Preferences.getInstance().addEventListener(this.pref,
+ function(event) {
+ self.value = event.value;
+ });
+
+ // Listen to user events.
+ this.addEventListener('change',
+ function(e) {
+ Preferences.setIntegerPref(self.pref, self.value);
+ });
+ },
+
+ /**
+ * Getter for preference name attribute.
+ */
+ get pref() {
+ return this.getAttribute('pref');
+ },
+
+ /**
+ * Setter for preference name attribute.
+ */
+ set pref(name) {
+ this.setAttribute('pref', name);
+ }
+};
+
+
+///////////////////////////////////////////////////////////////////////////////
+// PrefSelect class:
+
+// Define a constructor that uses an select element as its underlying element.
+var PrefSelect = cr.ui.define('select');
+
+PrefSelect.prototype = {
+ // Set up the prototype chain
+ __proto__: HTMLSelectElement.prototype,
+
+ /**
+ * Initialization function for the cr.ui framework.
+ */
+ decorate: function() {
+ var self = this;
+ // Listen to pref changes.
+ Preferences.getInstance().addEventListener(this.pref,
+ function(event) {
+ for (var i = 0; i < self.options.length; i++) {
+ if (self.options[i].value == event.value) {
+ self.selectedIndex = i;
+ return;
+ }
+ }
+ self.selectedIndex = -1;
+ });
+
+ // Listen to user events.
+ this.addEventListener('change',
+ function(e) {
+ Preferences.setStringPref(self.pref,
+ self.options[self.selectedIndex].value);
+ });
+ },
+
+ /**
+ * Sets up options in select element.
+ * @param {Array} options List of option and their display text.
+ * Each string in the array contains options value and display text split
+ * with '|' character.
+ *
+ * TODO(zelidrag): move this to that i18n template classes.
+ */
+ initializeValues: function(options) {
+ var self = this;
+ options.forEach(function (option) {
+ var values = option.split('|');
+ self.appendChild(new Option(values[1], values[0], false, false));
+ });
+ },
+ /**
+ * Getter for preference name attribute.
+ */
+ get pref() {
+ return this.getAttribute('pref');
+ },
+
+ /**
+ * Setter for preference name attribute.
+ */
+ set pref(name) {
+ this.setAttribute('pref', name);
+ }
+};
diff --git a/chrome/browser/resources/options/preferences.js b/chrome/browser/resources/options/preferences.js
new file mode 100644
index 0000000..12ff304
--- /dev/null
+++ b/chrome/browser/resources/options/preferences.js
@@ -0,0 +1,147 @@
+// Copyright (c) 2010 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.
+
+///////////////////////////////////////////////////////////////////////////////
+// Preferences class:
+
+/**
+ * Preferences class manages access to Chrome profile preferences.
+ * @constructor
+ */
+function Preferences() {
+}
+
+/**
+ * Gets Preferences object instance.
+ * @return Preferences singleton instance.
+ * @type Preferences
+ */
+Preferences.getInstance = function() {
+ if (Preferences.instance_)
+ return Preferences.instance_;
+ Preferences.instance_ = new Preferences();
+ return Preferences.instance_;
+};
+
+/**
+ * Extracts preference value.
+ * @param {Object} dict Map of preference values passed to fetchPrefs callback.
+ * @param {string} name Preference name.
+ * @return preference value.
+ */
+Preferences.getPref = function (dict, name) {
+ var parts = name.split('.');
+ var cur = dict;
+ for (var part; part = parts.shift(); ) {
+ if (cur[part]) {
+ cur = cur[part];
+ } else {
+ return null;
+ }
+ }
+ return cur;
+};
+
+/**
+ * Sets value of a boolean preference.
+ * and signals its changed value.
+ * @param {string} name Preference name.
+ * @param {boolean} value New preference value.
+ */
+Preferences.setBooleanPref = function (name, value) {
+ chrome.send('setBooleanPref', [name, value ? 'true' : 'false']);
+};
+
+/**
+ * Sets value of an integer preference.
+ * and signals its changed value.
+ * @param {string} name Preference name.
+ * @param {number} value New preference value.
+ */
+Preferences.setIntegerPref = function(name, value) {
+ chrome.send('setIntegerPref', [name, String(value)]);
+};
+
+/**
+ * Sets value of a string preference.
+ * and signals its changed value.
+ * @param {string} name Preference name.
+ * @param {string} value New preference value.
+ */
+Preferences.setStringPref = function(name, value) {
+ chrome.send('setStringPref', [name, value]);
+};
+
+Preferences.prototype = {
+ __proto__: cr.EventTarget.prototype,
+
+ // Map of registered preferences.
+ registeredPreferences_: {},
+
+ /**
+ * Adds an event listener to the target.
+ * @param {string} type The name of the event.
+ * @param {!Function|{handleEvent:Function}} handler The handler for the
+ * event. This is called when the event is dispatched.
+ */
+ addEventListener: function(type, handler) {
+ cr.EventTarget.prototype.addEventListener.call(this, type, handler);
+ this.registeredPreferences_[type] = true;
+ },
+
+ /**
+ * Initializes preference reading and change notifications.
+ */
+ initialize: function() {
+ var params1 = ['Preferences.prefsFetchedCallback'];
+ var params2 = ['Preferences.prefsChangedCallback'];
+ for (var prefName in this.registeredPreferences_) {
+ params1.push(prefName);
+ params2.push(prefName);
+ }
+ chrome.send('fetchPrefs', params1);
+ chrome.send('observePrefs', params2);
+ },
+
+ /**
+ * Helper function for flattening of dictionary passed via fetchPrefs
+ * callback.
+ * @param {string} prefix Preference name prefix.
+ * @param {object} dict Map with preference values.
+ */
+ flattenMapAndDispatchEvent_: function(prefix, dict) {
+ for (var prefName in dict) {
+ if (typeof dict[prefName] == 'object') {
+ this.flattenMapAndDispatchEvent_(prefix + prefName + '.',
+ dict[prefName]);
+ } else {
+ var event = new cr.Event(prefix + prefName);
+ event.value = dict[prefName];
+ this.dispatchEvent(event);
+ }
+ }
+ }
+};
+
+/**
+ * Callback for fetchPrefs method.
+ * @param {object} dict Map of fetched property values.
+ */
+Preferences.prefsFetchedCallback = function(dict) {
+ Preferences.getInstance().flattenMapAndDispatchEvent_('', dict);
+};
+
+/**
+ * Callback for observePrefs method.
+ * @param {array} notification An array defining changed preference values.
+ * notification[0] contains name of the change preference while its new value
+ * is stored in notification[1].
+ */
+Preferences.prefsChangedCallback = function(notification) {
+ var event = new cr.Event(notification[0]);
+ event.value = notification[1];
+ Preferences.getInstance().dispatchEvent(event);
+};
+
+
diff --git a/tools/grit/grit/format/html_inline.py b/tools/grit/grit/format/html_inline.py
index 8be2e81..128b267 100755
--- a/tools/grit/grit/format/html_inline.py
+++ b/tools/grit/grit/format/html_inline.py
@@ -107,6 +107,10 @@ def InlineFile(input_filename, output_filename):
return src_match.group(0)
return pattern % ReadFile(filepath)
+ def InlineIncludeFiles(src_match):
+ """Helper function to inline external script files"""
+ return InlineFileContents(src_match, '%s')
+
def InlineScript(src_match):
"""Helper function to inline external script files"""
return InlineFileContents(src_match, '<script>%s</script>')
@@ -152,6 +156,11 @@ def InlineFile(input_filename, output_filename):
InlineCssFile,
flat_text)
+ flat_text = re.sub(
+ '<!--\s*include\s+file="(?P<filename>[^"\']*)".*-->',
+ InlineIncludeFiles,
+ flat_text)
+
# TODO(glen): Make this regex not match src="" text that is not inside a tag
flat_text = re.sub('src="(?P<filename>[^"\']*)"',
SrcReplace,