diff options
author | jknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 17:26:33 +0000 |
---|---|---|
committer | jknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 17:26:33 +0000 |
commit | 24ebb8c857a6c479854c328b9d5b0bc44292f415 (patch) | |
tree | aaadc1d40e9eff51c112428c418f77d0bdb58c75 /chrome/browser/geolocation | |
parent | 878761aef2460c1c2b8922e3e4c5da234f5c7b60 (diff) | |
download | chromium_src-24ebb8c857a6c479854c328b9d5b0bc44292f415.zip chromium_src-24ebb8c857a6c479854c328b9d5b0bc44292f415.tar.gz chromium_src-24ebb8c857a6c479854c328b9d5b0bc44292f415.tar.bz2 |
Revert rev 69137 due to incorrect change log.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/5744005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69152 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation')
-rw-r--r-- | chrome/browser/geolocation/geolocation_dispatcher_host.h | 31 | ||||
-rw-r--r-- | chrome/browser/geolocation/geolocation_dispatcher_host_old.cc (renamed from chrome/browser/geolocation/geolocation_dispatcher_host.cc) | 94 | ||||
-rw-r--r-- | chrome/browser/geolocation/geolocation_dispatcher_host_old.h | 39 | ||||
-rw-r--r-- | chrome/browser/geolocation/geolocation_permission_context.cc | 10 | ||||
-rw-r--r-- | chrome/browser/geolocation/geolocation_permission_context.h | 2 | ||||
-rw-r--r-- | chrome/browser/geolocation/mock_location_provider.cc | 4 |
6 files changed, 86 insertions, 94 deletions
diff --git a/chrome/browser/geolocation/geolocation_dispatcher_host.h b/chrome/browser/geolocation/geolocation_dispatcher_host.h deleted file mode 100644 index 293cb33..0000000 --- a/chrome/browser/geolocation/geolocation_dispatcher_host.h +++ /dev/null @@ -1,31 +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. - -#ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ -#define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ -#pragma once - -#include "chrome/browser/browser_message_filter.h" - -class GeolocationPermissionContext; - -// GeolocationDispatcherHost is a browser filter for Geolocation messages. -// It's the complement of GeolocationDispatcher (owned by RenderView). - -class GeolocationDispatcherHost : public BrowserMessageFilter { - public: - static GeolocationDispatcherHost* New( - int render_process_id, - GeolocationPermissionContext* geolocation_permission_context); - - virtual bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok) = 0; - - protected: - GeolocationDispatcherHost() {} - virtual ~GeolocationDispatcherHost() {} - - DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost); -}; - -#endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_ diff --git a/chrome/browser/geolocation/geolocation_dispatcher_host.cc b/chrome/browser/geolocation/geolocation_dispatcher_host_old.cc index 4f4020b3..ca5298d 100644 --- a/chrome/browser/geolocation/geolocation_dispatcher_host.cc +++ b/chrome/browser/geolocation/geolocation_dispatcher_host_old.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/geolocation/geolocation_dispatcher_host.h" +#include "chrome/browser/geolocation/geolocation_dispatcher_host_old.h" #include <map> #include <set> @@ -19,21 +19,24 @@ #include "ipc/ipc_message.h" namespace { -class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost, - public GeolocationObserver { +class GeolocationDispatcherHostOldImpl : public GeolocationDispatcherHostOld, + public GeolocationObserver { public: - GeolocationDispatcherHostImpl( - int render_process_id, + GeolocationDispatcherHostOldImpl( + int resource_message_filter_process_id, GeolocationPermissionContext* geolocation_permission_context); - // GeolocationDispatcherHost + // GeolocationDispatcherHostOld + // Called to possibly handle the incoming IPC message. Returns true if + // handled. Called in the browser process. virtual bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); - // GeolocationObserver + // GeolocationArbitrator::Delegate virtual void OnLocationUpdate(const Geoposition& position); private: - virtual ~GeolocationDispatcherHostImpl(); + friend class base::RefCountedThreadSafe<GeolocationDispatcherHostOldImpl>; + virtual ~GeolocationDispatcherHostOldImpl(); void OnRegisterDispatcher(int render_view_id); void OnUnregisterDispatcher(int render_view_id); @@ -52,7 +55,7 @@ class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost, // options, based on |bridge_update_options_|. void RefreshGeolocationObserverOptions(); - int render_process_id_; + int resource_message_filter_process_id_; scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; // Iterated when sending location updates to renderer processes. The fan out @@ -67,13 +70,13 @@ class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost, // Only set whilst we are registered with the arbitrator. GeolocationProvider* location_provider_; - DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostImpl); + DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostOldImpl); }; -GeolocationDispatcherHostImpl::GeolocationDispatcherHostImpl( - int render_process_id, +GeolocationDispatcherHostOldImpl::GeolocationDispatcherHostOldImpl( + int resource_message_filter_process_id, GeolocationPermissionContext* geolocation_permission_context) - : render_process_id_(render_process_id), + : resource_message_filter_process_id_(resource_message_filter_process_id), geolocation_permission_context_(geolocation_permission_context), location_provider_(NULL) { // This is initialized by ResourceMessageFilter. Do not add any non-trivial @@ -81,17 +84,17 @@ GeolocationDispatcherHostImpl::GeolocationDispatcherHostImpl( // a javascript geolocation object is actually initialized. } -GeolocationDispatcherHostImpl::~GeolocationDispatcherHostImpl() { +GeolocationDispatcherHostOldImpl::~GeolocationDispatcherHostOldImpl() { if (location_provider_) location_provider_->RemoveObserver(this); } -bool GeolocationDispatcherHostImpl::OnMessageReceived( +bool GeolocationDispatcherHostOldImpl::OnMessageReceived( const IPC::Message& msg, bool* msg_was_ok) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); *msg_was_ok = true; bool handled = true; - IPC_BEGIN_MESSAGE_MAP_EX(GeolocationDispatcherHostImpl, msg, *msg_was_ok) + IPC_BEGIN_MESSAGE_MAP_EX(GeolocationDispatcherHostOldImpl, msg, *msg_was_ok) IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_RegisterDispatcher, OnRegisterDispatcher) IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_UnregisterDispatcher, @@ -113,112 +116,103 @@ bool GeolocationDispatcherHostImpl::OnMessageReceived( return handled; } -void GeolocationDispatcherHostImpl::OnLocationUpdate( +void GeolocationDispatcherHostOldImpl::OnLocationUpdate( const Geoposition& geoposition) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); for (std::set<int>::iterator it = geolocation_renderer_ids_.begin(); it != geolocation_renderer_ids_.end(); ++it) { IPC::Message* message = new ViewMsg_Geolocation_PositionUpdated(*it, geoposition); - CallRenderViewHost(render_process_id_, *it, + CallRenderViewHost(resource_message_filter_process_id_, *it, &RenderViewHost::Send, message); } } -void GeolocationDispatcherHostImpl::OnRegisterDispatcher( +void GeolocationDispatcherHostOldImpl::OnRegisterDispatcher( int render_view_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK_EQ(0u, geolocation_renderer_ids_.count(render_view_id)); geolocation_renderer_ids_.insert(render_view_id); } -void GeolocationDispatcherHostImpl::OnUnregisterDispatcher( +void GeolocationDispatcherHostOldImpl::OnUnregisterDispatcher( int render_view_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK_EQ(1u, geolocation_renderer_ids_.count(render_view_id)); geolocation_renderer_ids_.erase(render_view_id); } -void GeolocationDispatcherHostImpl::OnRequestPermission( +void GeolocationDispatcherHostOldImpl::OnRequestPermission( int render_view_id, int bridge_id, const GURL& requesting_frame) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" << render_view_id << ":" << bridge_id; geolocation_permission_context_->RequestGeolocationPermission( - render_process_id_, render_view_id, bridge_id, + resource_message_filter_process_id_, render_view_id, bridge_id, requesting_frame); } -void GeolocationDispatcherHostImpl::OnCancelPermissionRequest( +void GeolocationDispatcherHostOldImpl::OnCancelPermissionRequest( int render_view_id, int bridge_id, const GURL& requesting_frame) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" << render_view_id << ":" << bridge_id; geolocation_permission_context_->CancelGeolocationPermissionRequest( - render_process_id_, render_view_id, bridge_id, + resource_message_filter_process_id_, render_view_id, bridge_id, requesting_frame); } -void GeolocationDispatcherHostImpl::OnStartUpdating( +void GeolocationDispatcherHostOldImpl::OnStartUpdating( int render_view_id, int bridge_id, const GURL& requesting_frame, bool enable_high_accuracy) { -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - // StartUpdating() can be invoked as a result of high-accuracy mode - // being enabled / disabled. No need to register the dispatcher again. - if (!geolocation_renderer_ids_.count(render_view_id)) - OnRegisterDispatcher(render_view_id); -#endif // WebKit sends the startupdating request before checking permissions, to // optimize the no-location-available case and reduce latency in the success // case (location lookup happens in parallel with the permission request). DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" << render_view_id << ":" << bridge_id; bridge_update_options_[std::make_pair(render_view_id, bridge_id)] = GeolocationObserverOptions(enable_high_accuracy); geolocation_permission_context_->StartUpdatingRequested( - render_process_id_, render_view_id, bridge_id, + resource_message_filter_process_id_, render_view_id, bridge_id, requesting_frame); RefreshGeolocationObserverOptions(); } -void GeolocationDispatcherHostImpl::OnStopUpdating(int render_view_id, +void GeolocationDispatcherHostOldImpl::OnStopUpdating(int render_view_id, int bridge_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" << render_view_id << ":" << bridge_id; if (bridge_update_options_.erase(std::make_pair(render_view_id, bridge_id))) RefreshGeolocationObserverOptions(); geolocation_permission_context_->StopUpdatingRequested( - render_process_id_, render_view_id, bridge_id); -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - OnUnregisterDispatcher(render_view_id); -#endif + resource_message_filter_process_id_, render_view_id, bridge_id); } -void GeolocationDispatcherHostImpl::OnSuspend(int render_view_id, +void GeolocationDispatcherHostOldImpl::OnSuspend(int render_view_id, int bridge_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" << render_view_id << ":" << bridge_id; // TODO(bulach): connect this with GeolocationArbitrator. } -void GeolocationDispatcherHostImpl::OnResume(int render_view_id, +void GeolocationDispatcherHostOldImpl::OnResume(int render_view_id, int bridge_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" << render_view_id << ":" << bridge_id; // TODO(bulach): connect this with GeolocationArbitrator. } -void GeolocationDispatcherHostImpl::RefreshGeolocationObserverOptions() { +void GeolocationDispatcherHostOldImpl::RefreshGeolocationObserverOptions() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (bridge_update_options_.empty()) { if (location_provider_) { @@ -236,10 +230,10 @@ void GeolocationDispatcherHostImpl::RefreshGeolocationObserverOptions() { } } // namespace -GeolocationDispatcherHost* GeolocationDispatcherHost::New( - int render_process_id, +GeolocationDispatcherHostOld* GeolocationDispatcherHostOld::New( + int resource_message_filter_process_id, GeolocationPermissionContext* geolocation_permission_context) { - return new GeolocationDispatcherHostImpl( - render_process_id, + return new GeolocationDispatcherHostOldImpl( + resource_message_filter_process_id, geolocation_permission_context); } diff --git a/chrome/browser/geolocation/geolocation_dispatcher_host_old.h b/chrome/browser/geolocation/geolocation_dispatcher_host_old.h new file mode 100644 index 0000000..655049a --- /dev/null +++ b/chrome/browser/geolocation/geolocation_dispatcher_host_old.h @@ -0,0 +1,39 @@ +// 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. + +#ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_OLD_H_ +#define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_OLD_H_ +#pragma once + +#include "base/ref_counted.h" + +class GeolocationPermissionContext; +namespace IPC { class Message; } + +// GeolocationDispatcherHostOld is a delegate for Geolocation messages used by +// ResourceMessageFilter. +// It's the complement of GeolocationDispatcher (owned by RenderView). + +// TODO(jknotten): Remove this class once the new client-based implementation is +// checked in (see http://crbug.com/59908). +class GeolocationDispatcherHostOld + : public base::RefCountedThreadSafe<GeolocationDispatcherHostOld> { + public: + static GeolocationDispatcherHostOld* New( + int resource_message_filter_process_id, + GeolocationPermissionContext* geolocation_permission_context); + + // Called to possibly handle the incoming IPC message. Returns true if + // handled. Called in the browser process. + virtual bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok) = 0; + + protected: + friend class base::RefCountedThreadSafe<GeolocationDispatcherHostOld>; + GeolocationDispatcherHostOld() {} + virtual ~GeolocationDispatcherHostOld() {} + + DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostOld); +}; + +#endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_OLD_H_ diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/geolocation_permission_context.cc index 1f8160d..2a8e542 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.cc +++ b/chrome/browser/geolocation/geolocation_permission_context.cc @@ -10,6 +10,7 @@ #include "chrome/browser/browser_thread.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" +#include "chrome/browser/geolocation/geolocation_dispatcher_host_old.h" #include "chrome/browser/geolocation/geolocation_provider.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/prefs/pref_service.h" @@ -439,12 +440,6 @@ void GeolocationPermissionContext::StartUpdatingRequested( // Note we cannot store the arbitrator as a member as it is not thread safe. GeolocationProvider* provider = GeolocationProvider::GetInstance(); -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - // Client-based Geolocation uses a preemptive permission model, so permission - // ought to have been requested and granted before the controller requests - // the client to start updating. - DCHECK(provider->HasPermissionBeenGranted()); -#else // WebKit will not request permission until it has received a valid // location, but the google network location provider will not give a // valid location until the user has granted permission. So we cut the Gordian @@ -454,14 +449,11 @@ void GeolocationPermissionContext::StartUpdatingRequested( RequestGeolocationPermission(render_process_id, render_view_id, bridge_id, requesting_frame); } -#endif } void GeolocationPermissionContext::StopUpdatingRequested( int render_process_id, int render_view_id, int bridge_id) { -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); -#endif } void GeolocationPermissionContext::NotifyPermissionSet( diff --git a/chrome/browser/geolocation/geolocation_permission_context.h b/chrome/browser/geolocation/geolocation_permission_context.h index c2a08e7..432c9a2 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.h +++ b/chrome/browser/geolocation/geolocation_permission_context.h @@ -46,7 +46,7 @@ class GeolocationPermissionContext // Called when a geolocation object wants to start receiving location updates. // This also applies global policy around which location providers may be - // enabled at a given time (e.g. prior to the user agreeing to any geolocation + // enbaled at a given time (e.g. prior to the user agreeing to any geolocation // permission requests). void StartUpdatingRequested( int render_process_id, int render_view_id, int bridge_id, diff --git a/chrome/browser/geolocation/mock_location_provider.cc b/chrome/browser/geolocation/mock_location_provider.cc index e3575f0..689ab9c 100644 --- a/chrome/browser/geolocation/mock_location_provider.cc +++ b/chrome/browser/geolocation/mock_location_provider.cc @@ -78,9 +78,7 @@ class AutoMockLocationProvider : public MockLocationProvider { position_.accuracy = 3; position_.latitude = 4.3; position_.longitude = -7.8; - // Webkit compares the timestamp to wall clock time, so we need it to be - // contemporary. - position_.timestamp = base::Time::Now(); + position_.timestamp = base::Time::FromDoubleT(4567.8); } else { position_.error_code = Geoposition::ERROR_CODE_POSITION_UNAVAILABLE; } |