From 434afdcf94e2319ff03872db312d489a44637508 Mon Sep 17 00:00:00 2001 From: "bulach@chromium.org" Date: Thu, 18 Feb 2010 16:44:22 +0000 Subject: Initial Geolocation implementation Adds IPC plumbing. Adds Infobar buttons for requesting permission TEST=geolocation_browsertest.cc Review URL: http://codereview.chromium.org/548188 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39366 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/common/common_param_traits.cc | 63 +++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) (limited to 'chrome/common/common_param_traits.cc') diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc index e213f6d..62e57ff 100644 --- a/chrome/common/common_param_traits.cc +++ b/chrome/common/common_param_traits.cc @@ -245,5 +245,66 @@ void ParamTraits::Log( l->append(L""); } -} // namespace IPC +void ParamTraits::Write( + Message* m, const Geoposition::ErrorCode& p) { + int error_code = p; + WriteParam(m, error_code); +} + +bool ParamTraits::Read( + const Message* m, void** iter, Geoposition::ErrorCode* p) { + int error_code_param = 0; + bool ret = ReadParam(m, iter, &error_code_param); + *p = static_cast(error_code_param); + return ret; +} +void ParamTraits::Log( + const Geoposition::ErrorCode& p, std::wstring* l) { + int error_code = p; + l->append(StringPrintf(L"%d", error_code)); +} + +void ParamTraits::Write(Message* m, const Geoposition& p) { + WriteParam(m, p.latitude); + WriteParam(m, p.longitude); + WriteParam(m, p.accuracy); + WriteParam(m, p.altitude); + WriteParam(m, p.altitude_accuracy); + WriteParam(m, p.speed); + WriteParam(m, p.heading); + WriteParam(m, p.timestamp); + WriteParam(m, p.error_code); + WriteParam(m, p.error_message); +} + +bool ParamTraits::Read( + const Message* m, void** iter, Geoposition* p) { + bool ret = ReadParam(m, iter, &p->latitude); + ret = ret && ReadParam(m, iter, &p->longitude); + ret = ret && ReadParam(m, iter, &p->accuracy); + ret = ret && ReadParam(m, iter, &p->altitude); + ret = ret && ReadParam(m, iter, &p->altitude_accuracy); + ret = ret && ReadParam(m, iter, &p->speed); + ret = ret && ReadParam(m, iter, &p->heading); + ret = ret && ReadParam(m, iter, &p->timestamp); + ret = ret && ReadParam(m, iter, &p->error_code); + ret = ret && ReadParam(m, iter, &p->error_message); + return ret; +} + +void ParamTraits::Log(const Geoposition& p, std::wstring* l) { + l->append( + StringPrintf( + L"" + L"%.6f %.6f %.6f %.6f " + L"%.6f %.6f %.6f " + L"%lld ", + p.latitude, p.longitude, p.accuracy, p.altitude, + p.altitude_accuracy, p.speed, p.heading, + p.timestamp)); + l->append(p.error_message); + LogParam(p.error_code, l); +} + +} // namespace IPC -- cgit v1.1