summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 19:33:11 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-18 19:33:11 +0000
commit9384d383165e6e99e4430d9074a754ccebed34f9 (patch)
tree1dead35ee35b5b4119d713fe30f29586573d5b8e /chrome/common
parente989df19ef4bce3cd257ef77c19b0f3f4e1376bd (diff)
downloadchromium_src-9384d383165e6e99e4430d9074a754ccebed34f9.zip
chromium_src-9384d383165e6e99e4430d9074a754ccebed34f9.tar.gz
chromium_src-9384d383165e6e99e4430d9074a754ccebed34f9.tar.bz2
Revert 39366 - Initial Geolocation implementation
Adds IPC plumbing. Adds Infobar buttons for requesting permission TEST=geolocation_browsertest.cc Review URL: http://codereview.chromium.org/548188 TBR=bulach@chromium.org Review URL: http://codereview.chromium.org/646027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39374 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/common_param_traits.cc63
-rw-r--r--chrome/common/common_param_traits.h17
-rw-r--r--chrome/common/common_param_traits_unittest.cc39
-rw-r--r--chrome/common/geoposition.cc67
-rw-r--r--chrome/common/geoposition.h61
-rw-r--r--chrome/common/render_messages_internal.h77
6 files changed, 1 insertions, 323 deletions
diff --git a/chrome/common/common_param_traits.cc b/chrome/common/common_param_traits.cc
index 62e57ff..e213f6d 100644
--- a/chrome/common/common_param_traits.cc
+++ b/chrome/common/common_param_traits.cc
@@ -245,66 +245,5 @@ void ParamTraits<webkit_glue::WebApplicationInfo>::Log(
l->append(L"<WebApplicationInfo>");
}
-void ParamTraits<Geoposition::ErrorCode>::Write(
- Message* m, const Geoposition::ErrorCode& p) {
- int error_code = p;
- WriteParam(m, error_code);
-}
-
-bool ParamTraits<Geoposition::ErrorCode>::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<Geoposition::ErrorCode>(error_code_param);
- return ret;
-}
-
-void ParamTraits<Geoposition::ErrorCode>::Log(
- const Geoposition::ErrorCode& p, std::wstring* l) {
- int error_code = p;
- l->append(StringPrintf(L"<Geoposition::ErrorCode>%d", error_code));
-}
-
-void ParamTraits<Geoposition>::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<Geoposition>::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<Geoposition>::Log(const Geoposition& p, std::wstring* l) {
- l->append(
- StringPrintf(
- L"<Geoposition>"
- 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<Geoposition::ErrorCode>(p.error_code, l);
-}
-
} // namespace IPC
+
diff --git a/chrome/common/common_param_traits.h b/chrome/common/common_param_traits.h
index 99b1896..83148a6 100644
--- a/chrome/common/common_param_traits.h
+++ b/chrome/common/common_param_traits.h
@@ -15,7 +15,6 @@
#include "app/gfx/native_widget_types.h"
#include "chrome/common/content_settings.h"
-#include "chrome/common/geoposition.h"
#include "chrome/common/page_zoom.h"
#include "chrome/common/thumbnail_score.h"
#include "chrome/common/transport_dib.h"
@@ -393,22 +392,6 @@ struct ParamTraits<ThumbnailScore> {
}
};
-template <>
-struct ParamTraits<Geoposition> {
- typedef Geoposition param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, void** iter, param_type* p);
- static void Log(const param_type& p, std::wstring* l);
-};
-
-template <>
-struct ParamTraits<Geoposition::ErrorCode> {
- typedef Geoposition::ErrorCode param_type;
- static void Write(Message* m, const param_type& p);
- static bool Read(const Message* m, void** iter, param_type* p);
- static void Log(const param_type& p, std::wstring* l);
-};
-
} // namespace IPC
#endif // CHROME_COMMON_COMMON_PARAM_TRAITS_H_
diff --git a/chrome/common/common_param_traits_unittest.cc b/chrome/common/common_param_traits_unittest.cc
index d888084..f5db121 100644
--- a/chrome/common/common_param_traits_unittest.cc
+++ b/chrome/common/common_param_traits_unittest.cc
@@ -166,42 +166,3 @@ TEST(IPCMessageTest, DictionaryValue) {
iter = NULL;
EXPECT_FALSE(IPC::ReadParam(&bad_msg, &iter, &output));
}
-
-TEST(IPCMessageTest, Geoposition) {
- Geoposition input;
- input.latitude = 0.1;
- input.longitude = 51.3;
- input.accuracy = 13.7;
- input.altitude = 42.24;
- input.altitude_accuracy = 9.3;
- input.speed = 55;
- input.heading = 120;
- input.timestamp = 1977;
- input.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE;
- input.error_message = L"unittest error message for geoposition";
-
- IPC::Message msg(1, 2, IPC::Message::PRIORITY_NORMAL);
- IPC::WriteParam(&msg, input);
-
- Geoposition output;
- void* iter = NULL;
- EXPECT_TRUE(IPC::ReadParam(&msg, &iter, &output));
- EXPECT_EQ(input.altitude, output.altitude);
- EXPECT_EQ(input.altitude_accuracy, output.altitude_accuracy);
- EXPECT_EQ(input.latitude, output.latitude);
- EXPECT_EQ(input.longitude, output.longitude);
- EXPECT_EQ(input.accuracy, output.accuracy);
- EXPECT_EQ(input.heading, output.heading);
- EXPECT_EQ(input.speed, output.speed);
- EXPECT_EQ(input.error_code, output.error_code);
- EXPECT_EQ(input.error_message, output.error_message);
-
- std::wstring log_message;
- IPC::LogParam(output, &log_message);
- EXPECT_STREQ(L"<Geoposition>"
- L"0.100000 51.300000 13.700000 42.240000 "
- L"9.300000 55.000000 120.000000 "
- L"1977 unittest error message for geoposition"
- L"<Geoposition::ErrorCode>2",
- log_message.c_str());
-}
diff --git a/chrome/common/geoposition.cc b/chrome/common/geoposition.cc
deleted file mode 100644
index d4989ed..0000000
--- a/chrome/common/geoposition.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// 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.
-
-#include "chrome/common/geoposition.h"
-
-namespace {
-// Sentinel values to mark invalid data. (WebKit carries companion is_valid
-// bools for this purpose; we may eventually follow that approach, but
-// sentinels worked OK in the gears code this is based on.)
-const double kBadLatitudeLongitude = 200;
-// Lowest point on land is at approximately -400 meters.
-const int kBadAltitude = -10000;
-const int kBadAccuracy = -1; // Accuracy must be non-negative.
-const int64 kBadTimestamp = kint64min;
-const int kBadHeading = -1; // Heading must be non-negative.
-const int kBadSpeed = -1;
-}
-
-Geoposition::Geoposition()
- : latitude(kBadLatitudeLongitude),
- longitude(kBadLatitudeLongitude),
- altitude(kBadAltitude),
- accuracy(kBadAccuracy),
- altitude_accuracy(kBadAccuracy),
- heading(kBadHeading),
- speed(kBadSpeed),
- timestamp(kBadTimestamp),
- error_code(ERROR_CODE_NONE) {
-}
-
-bool Geoposition::is_valid_latlong() const {
- return latitude >= -90.0 && latitude <= 90.0 &&
- longitude >= -180.0 && longitude <= 180.0;
-}
-
-bool Geoposition::is_valid_altitude() const {
- return altitude > kBadAltitude;
-}
-
-bool Geoposition::is_valid_accuracy() const {
- return accuracy >= 0.0;
-}
-
-bool Geoposition::is_valid_altitude_accuracy() const {
- return altitude_accuracy >= 0.0;
-}
-
-bool Geoposition::is_valid_heading() const {
- return heading >= 0 && heading <= 360;
-}
-
-bool Geoposition::is_valid_speed() const {
- return speed >= 0;
-}
-
-bool Geoposition::is_valid_timestamp() const {
- return timestamp != kBadTimestamp;
-}
-
-bool Geoposition::IsValidFix() const {
- return is_valid_latlong() && is_valid_accuracy() && is_valid_timestamp();
-}
-
-bool Geoposition::IsInitialized() const {
- return error_code != ERROR_CODE_NONE || IsValidFix();
-}
diff --git a/chrome/common/geoposition.h b/chrome/common/geoposition.h
deleted file mode 100644
index 94c1dc9..0000000
--- a/chrome/common/geoposition.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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.
-
-// This file declares the Position structure, which is used to represent a
-// position fix. Originally derived from
-// http://gears.googlecode.com/svn/trunk/gears/geolocation/geolocation.h
-
-#ifndef CHROME_COMMON_GEOPOSITION_H_
-#define CHROME_COMMON_GEOPOSITION_H_
-
-#include "base/string16.h"
-
-// The internal representation of a geo position. Some properties use different
-// types when passed to JavaScript.
-struct Geoposition {
- public:
- // Error codes for returning to JavaScript. These values are defined by the
- // W3C spec. Note that Gears does not use all of these codes, but we need
- // values for all of them to allow us to provide the constants on the error
- // object.
- enum ErrorCode {
- ERROR_CODE_NONE = 0, // Chrome addition
- ERROR_CODE_PERMISSION_DENIED = 1,
- ERROR_CODE_POSITION_UNAVAILABLE = 2,
- ERROR_CODE_TIMEOUT = 3,
- };
-
- Geoposition();
-
- bool is_valid_latlong() const;
- bool is_valid_altitude() const;
- bool is_valid_accuracy() const;
- bool is_valid_altitude_accuracy() const;
- bool is_valid_heading() const;
- bool is_valid_speed() const;
- bool is_valid_timestamp() const;
-
- // A valid fix has a valid latitude, longitude, accuracy and timestamp.
- bool IsValidFix() const;
-
- // A position is considered initialized if it has either a valid fix or
- // an error code other than NONE.
- bool IsInitialized() const;
-
- // These properties correspond to the JavaScript Position object.
- double latitude; // In degrees
- double longitude; // In degrees
- double altitude; // In metres
- double accuracy; // In metres
- double altitude_accuracy; // In metres
- double heading; // In degrees clockwise relative to the true north
- double speed; // In meters per second
- int64 timestamp; // Milliseconds since 1st Jan 1970
-
- // These properties are returned to JavaScript as a PositionError object.
- ErrorCode error_code;
- std::wstring error_message; // Human-readable error message
-};
-
-#endif // CHROME_COMMON_GEOPOSITION_H_
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index a07dd2e..208a280 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -19,7 +19,6 @@
#include "base/values.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/extensions/update_manifest.h"
-#include "chrome/common/geoposition.h"
#include "chrome/common/nacl_types.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/page_zoom.h"
@@ -900,22 +899,6 @@ IPC_BEGIN_MESSAGES(View)
int /* error id of translation work */,
std::vector<string16> /* the translated text chunks */)
- // Reply in response to ViewHostMsg_Geolocation_RequestPermission.
- IPC_MESSAGE_ROUTED2(ViewMsg_Geolocation_PermissionSet,
- int /* bridge_id */,
- bool /* is_allowed */)
-
- // Sent after ViewHostMsg_Geolocation_StartUpdating iff the user has granted
- // permission and we have a position available.
- IPC_MESSAGE_ROUTED1(ViewMsg_Geolocation_PositionUpdated,
- Geoposition /* geoposition */)
-
- // Sent after ViewHostMsg_Geolocation_StartUpdating in case of error (such as
- // permission denied, position unavailable, etc.).
- IPC_MESSAGE_ROUTED2(ViewMsg_Geolocation_Error,
- int /* code */,
- std::string /* message */)
-
IPC_END_MESSAGES(View)
@@ -2147,64 +2130,4 @@ IPC_BEGIN_MESSAGES(ViewHost)
IPC_MESSAGE_CONTROL1(ViewHostMsg_TranslateText,
ViewHostMsg_TranslateTextParam)
- //---------------------------------------------------------------------------
- // Geolocation services messages
-
- // A GeolocationServiceBridgeImpl in the renderer process has been created.
- // This is used to lazily initialize the host dispatchers and related
- // Geolocation infrastructure in the browser process.
- IPC_MESSAGE_CONTROL1(ViewHostMsg_Geolocation_RegisterDispatcher,
- int /* route_id */)
-
- // A GeolocationServiceBridgeImpl has been destroyed.
- // This is used to let the Geolocation infrastructure do its cleanup.
- IPC_MESSAGE_CONTROL1(ViewHostMsg_Geolocation_UnregisterDispatcher,
- int /* route_id */)
-
- // The |route_id| and |bridge_id| representing |URL| is requesting permission
- // to access geolocation position.
- // This will be replied by ViewMsg_Geolocation_PermissionSet.
- IPC_MESSAGE_CONTROL3(ViewHostMsg_Geolocation_RequestPermission,
- int /* route_id */,
- int /* bridge_id */,
- GURL /* URL of the page*/)
-
- // The |route_id| and |bridge_id| requests Geolocation service to start
- // updating.
- // This is an asynchronous call, and the browser process may eventually reply
- // with the updated geoposition, or an error (access denied, location
- // unavailable, etc.)
- IPC_MESSAGE_CONTROL3(ViewHostMsg_Geolocation_StartUpdating,
- int /* route_id */,
- int /* bridge_id */,
- bool /* high_accuracy */)
-
- // The |route_id| and |bridge_id| requests Geolocation service to stop
- // updating.
- // Note that the geolocation service may continue to fetch geolocation data
- // for other origins.
- IPC_MESSAGE_CONTROL2(ViewHostMsg_Geolocation_StopUpdating,
- int /* route_id */,
- int /* bridge_id */)
-
- // The |route_id| and |bridge_id| requests Geolocation service to suspend.
- // Note that the geolocation service may continue to fetch geolocation data
- // for other origins.
- IPC_MESSAGE_CONTROL2(ViewHostMsg_Geolocation_Suspend,
- int /* route_id */,
- int /* bridge_id */)
-
- // The |route_id| and |bridge_id| requests Geolocation service to resume.
- IPC_MESSAGE_CONTROL2(ViewHostMsg_Geolocation_Resume,
- int /* route_id */,
- int /* bridge_id */)
-
- // Sent to indicate whether this particular GeolocationServiceBridgeImpl
- // (identified by |route_id| and |bridge_id|) is allowed to use geolocation
- // services.
- IPC_MESSAGE_CONTROL3(ViewHostMsg_Geolocation_PermissionSet,
- int /* route_id */,
- int /* bridge_id */,
- bool /* is_allowed */)
-
IPC_END_MESSAGES(ViewHost)