Expose initial_locale via chrome.chromeosInfoPrivate

BUG=chromium-os:16288
TEST=ExtensionApiTest.CustomizationPrivateTest

Review URL: http://codereview.chromium.org/6995105

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88643 0039d316-1c4b-4281-b951-d872f2087c98
parent 89ec0bc4
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/system_access.h" #include "chrome/browser/chromeos/system_access.h"
using chromeos::CrosLibrary; using chromeos::CrosLibrary;
...@@ -23,6 +24,9 @@ const char kPropertyHWID[] = "hwid"; ...@@ -23,6 +24,9 @@ const char kPropertyHWID[] = "hwid";
// Key which corresponds to the home provider property. // Key which corresponds to the home provider property.
const char kPropertyHomeProvider[] = "homeProvider"; const char kPropertyHomeProvider[] = "homeProvider";
// Key which corresponds to the initial_locale property.
const char kPropertyInitialLocale[] = "initialLocale";
} // namespace } // namespace
GetChromeosInfoFunction::GetChromeosInfoFunction() { GetChromeosInfoFunction::GetChromeosInfoFunction() {
...@@ -60,6 +64,8 @@ bool GetChromeosInfoFunction::GetValue(const std::string& property_name, ...@@ -60,6 +64,8 @@ bool GetChromeosInfoFunction::GetValue(const std::string& property_name,
} else { } else {
LOG(ERROR) << "CrosLibrary can't be loaded."; LOG(ERROR) << "CrosLibrary can't be loaded.";
} }
} else if (property_name == kPropertyInitialLocale) {
*value = chromeos::WizardController::GetInitialLocale();
} else { } else {
LOG(ERROR) << "Unknown property request: " << property_name; LOG(ERROR) << "Unknown property request: " << property_name;
return false; return false;
......
...@@ -1139,12 +1139,12 @@ ...@@ -1139,12 +1139,12 @@
"description": "A URL to navigate the tab to." "description": "A URL to navigate the tab to."
}, },
"selected": { "selected": {
"type": "boolean", "type": "boolean",
"optional": true, "optional": true,
"description": "Whether the tab should be selected." "description": "Whether the tab should be selected."
}, },
"pinned": { "pinned": {
"type": "boolean", "type": "boolean",
"optional": true, "optional": true,
"description": "Whether the tab should be pinned." "description": "Whether the tab should be pinned."
} }
...@@ -1454,13 +1454,13 @@ ...@@ -1454,13 +1454,13 @@
"description": "Fires when a tab is closed. Note: A listener can be registered for this event without requesting the 'tabs' permission in the manifest.", "description": "Fires when a tab is closed. Note: A listener can be registered for this event without requesting the 'tabs' permission in the manifest.",
"parameters": [ "parameters": [
{"type": "integer", "name": "tabId", "minimum": 0}, {"type": "integer", "name": "tabId", "minimum": 0},
{ {
"type": "object", "type": "object",
"name": "removeInfo", "name": "removeInfo",
"properties": { "properties": {
"isWindowClosing": {"type": "boolean", "description": "True when the tab is being closed because its window is being closed." } "isWindowClosing": {"type": "boolean", "description": "True when the tab is being closed because its window is being closed." }
} }
} }
] ]
} }
] ]
...@@ -3252,12 +3252,12 @@ ...@@ -3252,12 +3252,12 @@
"name": "callback", "name": "callback",
"parameters": [ "parameters": [
{ {
"name": "enabled", "name": "enabled",
"type": "boolean", "type": "boolean",
"description": "The actual value set. If it is not the one passed in parameter, the value couldn't be changed (e.g. because of security)." "description": "The actual value set. If it is not the one passed in parameter, the value couldn't be changed (e.g. because of security)."
} }
] ]
} }
] ]
}, },
{ {
...@@ -3392,7 +3392,8 @@ ...@@ -3392,7 +3392,8 @@
"description": "Dictionary which contains all requested properties", "description": "Dictionary which contains all requested properties",
"properties": { "properties": {
"hwid": {"type": "string", "optional": "true", "description": "Hardware ID"}, "hwid": {"type": "string", "optional": "true", "description": "Hardware ID"},
"homeProvider" : {"type": "string", "optional": "true", "description": "Home provider which is used by the cellular device"} "homeProvider" : {"type": "string", "optional": "true", "description": "Home provider which is used by the cellular device"},
"initialLocale" : {"type": "string", "optional": "true", "description": "Initial locale for the device"}
} }
} }
] ]
...@@ -5527,11 +5528,11 @@ ...@@ -5527,11 +5528,11 @@
"maximum": 65535, "maximum": 65535,
"description": "TCP port number." "description": "TCP port number."
}, },
{ {
"type": "function", "type": "function",
"name": "callback", "name": "callback",
"parameters": [ "parameters": [
{ {
"type": "string", "type": "string",
"name": "passport", "name": "passport",
"description": "Passport for passing to proxy." "description": "Passport for passing to proxy."
......
...@@ -5,16 +5,27 @@ ...@@ -5,16 +5,27 @@
function getTestFunctionFor(keys, fails) { function getTestFunctionFor(keys, fails) {
return function generatedTest () { return function generatedTest () {
// Debug. // Debug.
console.log("keys: " + keys + ", fails: " + fails); console.log("keys: " + keys + "; fails: " + fails);
chrome.chromeosInfoPrivate.get( chrome.chromeosInfoPrivate.get(
keys, keys,
pass(function(values) { pass(
// Debug function(values) {
console.log("values: ", values); for (var i = 0; i < keys.length; ++i) {
for (var i = 0; i < keys.length; ++i) // Debug
chrome.test.assertEq(!(i in fails), keys[i] in values); if (keys[i] in values) {
})); console.log(" values['" + keys[i] + "'] = " +
values[keys[i]]);
} else {
console.log(" " + keys[i] + " is missing in values");
}
chrome.test.assertEq(fails.indexOf(keys[i]) == -1,
keys[i] in values);
}
}
)
);
} }
} }
...@@ -25,8 +36,8 @@ ...@@ -25,8 +36,8 @@
// Test with all the keys at one. // Test with all the keys at one.
tests.push(getTestFunctionFor(keys, [])); tests.push(getTestFunctionFor(keys, []));
// Tests with key which hasn't corresponding value. // Tests with key which hasn't corresponding value.
var noValueKey = "no-value-for-this-key"; var noValueKey = "noValueForThisKey";
tests.push(getTestFunctionFor([noValueKey], [0])); tests.push(getTestFunctionFor([noValueKey], [noValueKey]));
if (keys.length > 1) { if (keys.length > 1) {
// Tests with the separate keys. // Tests with the separate keys.
...@@ -34,13 +45,14 @@ ...@@ -34,13 +45,14 @@
tests.push(getTestFunctionFor([keys[i]], [])); tests.push(getTestFunctionFor([keys[i]], []));
} }
} }
if (keys.length > 2) { if (keys.length >= 2) {
tests.push(getTestFunctionFor([keys[0], keys[1]], [])); tests.push(getTestFunctionFor([keys[0], keys[1]], []));
tests.push(getTestFunctionFor([keys[0], noValueKey, keys[1]], [1])); tests.push(getTestFunctionFor([keys[0], noValueKey, keys[1]],
[noValueKey]));
} }
return tests; return tests;
} }
var tests = generateTestsForKeys(["hwid", "homeProvider"]) var tests = generateTestsForKeys(["hwid", "homeProvider", "initialLocale"])
chrome.test.runTests(tests); chrome.test.runTests(tests);
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment