From 24ebb8c857a6c479854c328b9d5b0bc44292f415 Mon Sep 17 00:00:00 2001 From: "jknotten@chromium.org" Date: Tue, 14 Dec 2010 17:26:33 +0000 Subject: 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 --- build/features_override.gypi | 1 - .../geolocation/geolocation_dispatcher_host.cc | 245 --------------------- .../geolocation/geolocation_dispatcher_host.h | 31 --- .../geolocation/geolocation_dispatcher_host_old.cc | 239 ++++++++++++++++++++ .../geolocation/geolocation_dispatcher_host_old.h | 39 ++++ .../geolocation/geolocation_permission_context.cc | 10 +- .../geolocation/geolocation_permission_context.h | 2 +- .../browser/geolocation/mock_location_provider.cc | 4 +- .../renderer_host/browser_render_process_host.cc | 4 - .../browser/renderer_host/render_message_filter.cc | 9 +- .../browser/renderer_host/render_message_filter.h | 3 + chrome/chrome_browser.gypi | 12 +- chrome/chrome_renderer.gypi | 10 - chrome/renderer/geolocation_dispatcher.cc | 155 ------------- chrome/renderer/geolocation_dispatcher.h | 75 ------- chrome/renderer/geolocation_dispatcher_old.cc | 3 +- chrome/renderer/geolocation_dispatcher_old.h | 8 +- chrome/renderer/render_view.cc | 13 -- chrome/renderer/render_view.h | 10 - webkit/tools/test_shell/layout_test_controller.cc | 24 +- webkit/tools/test_shell/test_shell.cc | 17 -- webkit/tools/test_shell/test_shell.gypi | 3 - webkit/tools/test_shell/test_shell.h | 8 - webkit/tools/test_shell/test_webview_delegate.cc | 13 -- webkit/tools/test_shell/test_webview_delegate.h | 10 - 25 files changed, 297 insertions(+), 651 deletions(-) delete mode 100644 chrome/browser/geolocation/geolocation_dispatcher_host.cc delete mode 100644 chrome/browser/geolocation/geolocation_dispatcher_host.h create mode 100644 chrome/browser/geolocation/geolocation_dispatcher_host_old.cc create mode 100644 chrome/browser/geolocation/geolocation_dispatcher_host_old.h delete mode 100644 chrome/renderer/geolocation_dispatcher.cc delete mode 100644 chrome/renderer/geolocation_dispatcher.h diff --git a/build/features_override.gypi b/build/features_override.gypi index dc59950..5c069ea 100644 --- a/build/features_override.gypi +++ b/build/features_override.gypi @@ -15,7 +15,6 @@ 'ENABLE_BLOB=1', 'ENABLE_BLOB_SLICE=1', 'ENABLE_CHANNEL_MESSAGING=1', - 'ENABLE_CLIENT_BASED_GEOLOCATION=0', 'ENABLE_DASHBOARD_SUPPORT=0', 'ENABLE_DATABASE=1', 'ENABLE_DATAGRID=0', diff --git a/chrome/browser/geolocation/geolocation_dispatcher_host.cc b/chrome/browser/geolocation/geolocation_dispatcher_host.cc deleted file mode 100644 index 4f4020b3..0000000 --- a/chrome/browser/geolocation/geolocation_dispatcher_host.cc +++ /dev/null @@ -1,245 +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/browser/geolocation/geolocation_dispatcher_host.h" - -#include -#include -#include - -#include "chrome/common/geoposition.h" -#include "chrome/browser/geolocation/geolocation_permission_context.h" -#include "chrome/browser/geolocation/geolocation_provider.h" -#include "chrome/browser/renderer_host/render_message_filter.h" -#include "chrome/browser/renderer_host/render_process_host.h" -#include "chrome/browser/renderer_host/render_view_host.h" -#include "chrome/browser/renderer_host/render_view_host_notification_task.h" -#include "chrome/common/render_messages.h" -#include "ipc/ipc_message.h" - -namespace { -class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost, - public GeolocationObserver { - public: - GeolocationDispatcherHostImpl( - int render_process_id, - GeolocationPermissionContext* geolocation_permission_context); - - // GeolocationDispatcherHost - virtual bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); - - // GeolocationObserver - virtual void OnLocationUpdate(const Geoposition& position); - - private: - virtual ~GeolocationDispatcherHostImpl(); - - void OnRegisterDispatcher(int render_view_id); - void OnUnregisterDispatcher(int render_view_id); - void OnRequestPermission( - int render_view_id, int bridge_id, const GURL& requesting_frame); - void OnCancelPermissionRequest( - int render_view_id, int bridge_id, const GURL& requesting_frame); - void OnStartUpdating( - int render_view_id, int bridge_id, const GURL& requesting_frame, - bool enable_high_accuracy); - void OnStopUpdating(int render_view_id, int bridge_id); - void OnSuspend(int render_view_id, int bridge_id); - void OnResume(int render_view_id, int bridge_id); - - // Updates the |location_arbitrator_| with the currently required update - // options, based on |bridge_update_options_|. - void RefreshGeolocationObserverOptions(); - - int render_process_id_; - scoped_refptr geolocation_permission_context_; - - // Iterated when sending location updates to renderer processes. The fan out - // to individual bridge IDs happens renderer side, in order to minimize - // context switches. - // Only used on the IO thread. - std::set geolocation_renderer_ids_; - // Maps to the location arbitrator update options - // that correspond to this particular bridge. - std::map, GeolocationObserverOptions> - bridge_update_options_; - // Only set whilst we are registered with the arbitrator. - GeolocationProvider* location_provider_; - - DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostImpl); -}; - -GeolocationDispatcherHostImpl::GeolocationDispatcherHostImpl( - int render_process_id, - GeolocationPermissionContext* geolocation_permission_context) - : render_process_id_(render_process_id), - geolocation_permission_context_(geolocation_permission_context), - location_provider_(NULL) { - // This is initialized by ResourceMessageFilter. Do not add any non-trivial - // initialization here, defer to OnRegisterBridge which is triggered whenever - // a javascript geolocation object is actually initialized. -} - -GeolocationDispatcherHostImpl::~GeolocationDispatcherHostImpl() { - if (location_provider_) - location_provider_->RemoveObserver(this); -} - -bool GeolocationDispatcherHostImpl::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_MESSAGE_HANDLER(ViewHostMsg_Geolocation_RegisterDispatcher, - OnRegisterDispatcher) - IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_UnregisterDispatcher, - OnUnregisterDispatcher) - IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_CancelPermissionRequest, - OnCancelPermissionRequest) - IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_RequestPermission, - OnRequestPermission) - IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_StartUpdating, - OnStartUpdating) - IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_StopUpdating, - OnStopUpdating) - IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_Suspend, - OnSuspend) - IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_Resume, - OnResume) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void GeolocationDispatcherHostImpl::OnLocationUpdate( - const Geoposition& geoposition) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - for (std::set::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, - &RenderViewHost::Send, message); - } -} - -void GeolocationDispatcherHostImpl::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( - 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( - int render_view_id, - int bridge_id, - const GURL& requesting_frame) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" - << render_view_id << ":" << bridge_id; - geolocation_permission_context_->RequestGeolocationPermission( - render_process_id_, render_view_id, bridge_id, - requesting_frame); -} - -void GeolocationDispatcherHostImpl::OnCancelPermissionRequest( - int render_view_id, - int bridge_id, - const GURL& requesting_frame) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" - << render_view_id << ":" << bridge_id; - geolocation_permission_context_->CancelGeolocationPermissionRequest( - render_process_id_, render_view_id, bridge_id, - requesting_frame); -} - -void GeolocationDispatcherHostImpl::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_ << ":" - << 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, - requesting_frame); - RefreshGeolocationObserverOptions(); -} - -void GeolocationDispatcherHostImpl::OnStopUpdating(int render_view_id, - int bridge_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_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 -} - -void GeolocationDispatcherHostImpl::OnSuspend(int render_view_id, - int bridge_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" - << render_view_id << ":" << bridge_id; - // TODO(bulach): connect this with GeolocationArbitrator. -} - -void GeolocationDispatcherHostImpl::OnResume(int render_view_id, - int bridge_id) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" - << render_view_id << ":" << bridge_id; - // TODO(bulach): connect this with GeolocationArbitrator. -} - -void GeolocationDispatcherHostImpl::RefreshGeolocationObserverOptions() { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - if (bridge_update_options_.empty()) { - if (location_provider_) { - location_provider_->RemoveObserver(this); - location_provider_ = NULL; - } - } else { - if (!location_provider_) - location_provider_ = GeolocationProvider::GetInstance(); - // Re-add to re-establish our options, in case they changed. - location_provider_->AddObserver( - this, - GeolocationObserverOptions::Collapse(bridge_update_options_)); - } -} -} // namespace - -GeolocationDispatcherHost* GeolocationDispatcherHost::New( - int render_process_id, - GeolocationPermissionContext* geolocation_permission_context) { - return new GeolocationDispatcherHostImpl( - render_process_id, - geolocation_permission_context); -} 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_old.cc b/chrome/browser/geolocation/geolocation_dispatcher_host_old.cc new file mode 100644 index 0000000..ca5298d --- /dev/null +++ b/chrome/browser/geolocation/geolocation_dispatcher_host_old.cc @@ -0,0 +1,239 @@ +// 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/browser/geolocation/geolocation_dispatcher_host_old.h" + +#include +#include +#include + +#include "chrome/common/geoposition.h" +#include "chrome/browser/geolocation/geolocation_permission_context.h" +#include "chrome/browser/geolocation/geolocation_provider.h" +#include "chrome/browser/renderer_host/render_message_filter.h" +#include "chrome/browser/renderer_host/render_process_host.h" +#include "chrome/browser/renderer_host/render_view_host.h" +#include "chrome/browser/renderer_host/render_view_host_notification_task.h" +#include "chrome/common/render_messages.h" +#include "ipc/ipc_message.h" + +namespace { +class GeolocationDispatcherHostOldImpl : public GeolocationDispatcherHostOld, + public GeolocationObserver { + public: + GeolocationDispatcherHostOldImpl( + int resource_message_filter_process_id, + GeolocationPermissionContext* geolocation_permission_context); + + // 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); + + // GeolocationArbitrator::Delegate + virtual void OnLocationUpdate(const Geoposition& position); + + private: + friend class base::RefCountedThreadSafe; + virtual ~GeolocationDispatcherHostOldImpl(); + + void OnRegisterDispatcher(int render_view_id); + void OnUnregisterDispatcher(int render_view_id); + void OnRequestPermission( + int render_view_id, int bridge_id, const GURL& requesting_frame); + void OnCancelPermissionRequest( + int render_view_id, int bridge_id, const GURL& requesting_frame); + void OnStartUpdating( + int render_view_id, int bridge_id, const GURL& requesting_frame, + bool enable_high_accuracy); + void OnStopUpdating(int render_view_id, int bridge_id); + void OnSuspend(int render_view_id, int bridge_id); + void OnResume(int render_view_id, int bridge_id); + + // Updates the |location_arbitrator_| with the currently required update + // options, based on |bridge_update_options_|. + void RefreshGeolocationObserverOptions(); + + int resource_message_filter_process_id_; + scoped_refptr geolocation_permission_context_; + + // Iterated when sending location updates to renderer processes. The fan out + // to individual bridge IDs happens renderer side, in order to minimize + // context switches. + // Only used on the IO thread. + std::set geolocation_renderer_ids_; + // Maps to the location arbitrator update options + // that correspond to this particular bridge. + std::map, GeolocationObserverOptions> + bridge_update_options_; + // Only set whilst we are registered with the arbitrator. + GeolocationProvider* location_provider_; + + DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostOldImpl); +}; + +GeolocationDispatcherHostOldImpl::GeolocationDispatcherHostOldImpl( + int resource_message_filter_process_id, + GeolocationPermissionContext* geolocation_permission_context) + : 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 + // initialization here, defer to OnRegisterBridge which is triggered whenever + // a javascript geolocation object is actually initialized. +} + +GeolocationDispatcherHostOldImpl::~GeolocationDispatcherHostOldImpl() { + if (location_provider_) + location_provider_->RemoveObserver(this); +} + +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(GeolocationDispatcherHostOldImpl, msg, *msg_was_ok) + IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_RegisterDispatcher, + OnRegisterDispatcher) + IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_UnregisterDispatcher, + OnUnregisterDispatcher) + IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_CancelPermissionRequest, + OnCancelPermissionRequest) + IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_RequestPermission, + OnRequestPermission) + IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_StartUpdating, + OnStartUpdating) + IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_StopUpdating, + OnStopUpdating) + IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_Suspend, + OnSuspend) + IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_Resume, + OnResume) + IPC_MESSAGE_UNHANDLED(handled = false) + IPC_END_MESSAGE_MAP() + return handled; +} + +void GeolocationDispatcherHostOldImpl::OnLocationUpdate( + const Geoposition& geoposition) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + for (std::set::iterator it = geolocation_renderer_ids_.begin(); + it != geolocation_renderer_ids_.end(); ++it) { + IPC::Message* message = + new ViewMsg_Geolocation_PositionUpdated(*it, geoposition); + CallRenderViewHost(resource_message_filter_process_id_, *it, + &RenderViewHost::Send, message); + } +} + +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 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 GeolocationDispatcherHostOldImpl::OnRequestPermission( + int render_view_id, + int bridge_id, + const GURL& requesting_frame) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" + << render_view_id << ":" << bridge_id; + geolocation_permission_context_->RequestGeolocationPermission( + resource_message_filter_process_id_, render_view_id, bridge_id, + requesting_frame); +} + +void GeolocationDispatcherHostOldImpl::OnCancelPermissionRequest( + int render_view_id, + int bridge_id, + const GURL& requesting_frame) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" + << render_view_id << ":" << bridge_id; + geolocation_permission_context_->CancelGeolocationPermissionRequest( + resource_message_filter_process_id_, render_view_id, bridge_id, + requesting_frame); +} + +void GeolocationDispatcherHostOldImpl::OnStartUpdating( + int render_view_id, + int bridge_id, + const GURL& requesting_frame, + bool enable_high_accuracy) { + // 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__ << " " << 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( + resource_message_filter_process_id_, render_view_id, bridge_id, + requesting_frame); + RefreshGeolocationObserverOptions(); +} + +void GeolocationDispatcherHostOldImpl::OnStopUpdating(int render_view_id, + int bridge_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + 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( + resource_message_filter_process_id_, render_view_id, bridge_id); +} + +void GeolocationDispatcherHostOldImpl::OnSuspend(int render_view_id, + int bridge_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" + << render_view_id << ":" << bridge_id; + // TODO(bulach): connect this with GeolocationArbitrator. +} + +void GeolocationDispatcherHostOldImpl::OnResume(int render_view_id, + int bridge_id) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" + << render_view_id << ":" << bridge_id; + // TODO(bulach): connect this with GeolocationArbitrator. +} + +void GeolocationDispatcherHostOldImpl::RefreshGeolocationObserverOptions() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + if (bridge_update_options_.empty()) { + if (location_provider_) { + location_provider_->RemoveObserver(this); + location_provider_ = NULL; + } + } else { + if (!location_provider_) + location_provider_ = GeolocationProvider::GetInstance(); + // Re-add to re-establish our options, in case they changed. + location_provider_->AddObserver( + this, + GeolocationObserverOptions::Collapse(bridge_update_options_)); + } +} +} // namespace + +GeolocationDispatcherHostOld* GeolocationDispatcherHostOld::New( + int resource_message_filter_process_id, + GeolocationPermissionContext* geolocation_permission_context) { + 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 { + 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() {} + 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; } diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc index 61849ec..cb3eb82 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -37,7 +37,6 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/file_system/file_system_dispatcher_host.h" -#include "chrome/browser/geolocation/geolocation_dispatcher_host.h" #include "chrome/browser/gpu_process_host.h" #include "chrome/browser/history/history.h" #include "chrome/browser/in_process_webkit/dom_storage_message_filter.h" @@ -401,9 +400,6 @@ void BrowserRenderProcessHost::CreateMessageFilters() { new AppCacheDispatcherHost(profile()->GetRequestContext(), id())); channel_->AddFilter(new DOMStorageMessageFilter(id(), profile())); channel_->AddFilter(new IndexedDBDispatcherHost(id(), profile())); - channel_->AddFilter( - GeolocationDispatcherHost::New( - id(), profile()->GetGeolocationPermissionContext())); channel_->AddFilter(new PepperFileMessageFilter(id(), profile())); channel_->AddFilter(new speech_input::SpeechInputDispatcherHost(id())); channel_->AddFilter( diff --git a/chrome/browser/renderer_host/render_message_filter.cc b/chrome/browser/renderer_host/render_message_filter.cc index 5fa92ec..6f12cdd 100644 --- a/chrome/browser/renderer_host/render_message_filter.cc +++ b/chrome/browser/renderer_host/render_message_filter.cc @@ -21,7 +21,8 @@ #include "chrome/browser/clipboard_dispatcher.h" #include "chrome/browser/download/download_types.h" #include "chrome/browser/extensions/extension_message_service.h" -#include "chrome/browser/file_system/file_system_dispatcher_host.h" +#include "chrome/browser/geolocation/geolocation_dispatcher_host_old.h" +#include "chrome/browser/geolocation/geolocation_permission_context.h" #include "chrome/browser/gpu_process_host.h" #include "chrome/browser/host_zoom_map.h" #include "chrome/browser/metrics/histogram_synchronizer.h" @@ -250,6 +251,9 @@ RenderMessageFilter::RenderMessageFilter( off_the_record_(profile->IsOffTheRecord()), next_route_id_callback_(NewCallbackWithReturnValue( render_widget_helper, &RenderWidgetHelper::GetNextRoutingID)), + ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_dispatcher_host_( + GeolocationDispatcherHostOld::New( + this->id(), profile->GetGeolocationPermissionContext()))), webkit_context_(profile->GetWebKitContext()) { request_context_ = profile_->GetRequestContext(); DCHECK(request_context_); @@ -320,7 +324,8 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& msg) { bool handled = resource_dispatcher_host_->OnMessageReceived(msg, this, &msg_is_ok) || mp_dispatcher->OnMessageReceived( - msg, this, next_route_id_callback(), &msg_is_ok); + msg, this, next_route_id_callback(), &msg_is_ok) || + geolocation_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok); if (!handled) { DCHECK(msg_is_ok); // It should have been marked handled if it wasn't OK. diff --git a/chrome/browser/renderer_host/render_message_filter.h b/chrome/browser/renderer_host/render_message_filter.h index e912aaa..69bc8f7 100644 --- a/chrome/browser/renderer_host/render_message_filter.h +++ b/chrome/browser/renderer_host/render_message_filter.h @@ -34,6 +34,7 @@ class ChromeURLRequestContext; struct FontDescriptor; +class GeolocationDispatcherHostOld; class HostZoomMap; class NotificationsPrefsCache; class PpapiPluginProcessHost; @@ -448,6 +449,8 @@ class RenderMessageFilter : public IPC::ChannelProxy::MessageFilter, // A callback to create a routing id for the associated renderer process. scoped_ptr::Type> next_route_id_callback_; + // Used to handle geolocation-related messages. + scoped_refptr geolocation_dispatcher_host_; scoped_refptr webkit_context_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 5a6fbb7..ac54cfb 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1259,8 +1259,8 @@ 'browser/geolocation/gateway_data_provider_win.h', 'browser/geolocation/geolocation_content_settings_map.cc', 'browser/geolocation/geolocation_content_settings_map.h', - 'browser/geolocation/geolocation_dispatcher_host.cc', - 'browser/geolocation/geolocation_dispatcher_host.h', + 'browser/geolocation/geolocation_dispatcher_host_old.cc', + 'browser/geolocation/geolocation_dispatcher_host_old.h', 'browser/geolocation/geolocation_exceptions_table_model.cc', 'browser/geolocation/geolocation_exceptions_table_model.h', 'browser/geolocation/geolocation_observer.h', @@ -4349,14 +4349,6 @@ 'browser/importer/nss_decryptor_system_nss.h', ], }], - # We are migrating to client-based geolocation. Once the migration - # has finished, ENABLE_CLIENT_BASED_GEOLOCATION will disappear. - # See bugs: - # https://bugs.webkit.org/show_bug.cgi?id=45752 and - # http://code.google.com/p/chromium/issues/detail?id=59907 - ['"ENABLE_CLIENT_BASED_GEOLOCATION=1" in feature_defines', { - 'defines': [ 'ENABLE_CLIENT_BASED_GEOLOCATION=1' ] - }], ], }, { diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index 2a69cd7..87889aa 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -112,8 +112,6 @@ 'renderer/external_extension.h', 'renderer/form_manager.cc', 'renderer/form_manager.h', - 'renderer/geolocation_dispatcher.cc', - 'renderer/geolocation_dispatcher.h', 'renderer/geolocation_dispatcher_old.cc', 'renderer/geolocation_dispatcher_old.h', 'renderer/gpu_channel_host.cc', @@ -314,14 +312,6 @@ 'renderer/command_buffer_proxy.h', ], }], - # We are migrating to client-based geolocation. Once the migration - # has finished, ENABLE_CLIENT_BASED_GEOLOCATION will disappear. - # See bugs: - # https://bugs.webkit.org/show_bug.cgi?id=45752 and - # http://code.google.com/p/chromium/issues/detail?id=59907 - ['"ENABLE_CLIENT_BASED_GEOLOCATION=1" in feature_defines', { - 'defines': [ 'ENABLE_CLIENT_BASED_GEOLOCATION=1' ] - }], ], }, { diff --git a/chrome/renderer/geolocation_dispatcher.cc b/chrome/renderer/geolocation_dispatcher.cc deleted file mode 100644 index 39596af..0000000 --- a/chrome/renderer/geolocation_dispatcher.cc +++ /dev/null @@ -1,155 +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. - -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - -#include "chrome/renderer/geolocation_dispatcher.h" - -#include "chrome/renderer/render_view.h" -#include "ipc/ipc_message.h" -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationPermissionRequest.h" -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationPermissionRequestManager.h" -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClient.h" -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationPosition.h" -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationError.h" -#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" - -using namespace WebKit; - -GeolocationDispatcher::GeolocationDispatcher(RenderView* render_view) - : render_view_(render_view), - pending_permissions_(new WebGeolocationPermissionRequestManager()), - enable_high_accuracy_(false), - updating_(false) { -} - -GeolocationDispatcher::~GeolocationDispatcher() {} - -bool GeolocationDispatcher::OnMessageReceived(const IPC::Message& message) { - bool handled = true; - IPC_BEGIN_MESSAGE_MAP(GeolocationDispatcher, message) - IPC_MESSAGE_HANDLER(ViewMsg_Geolocation_PermissionSet, - OnGeolocationPermissionSet) - IPC_MESSAGE_HANDLER(ViewMsg_Geolocation_PositionUpdated, - OnGeolocationPositionUpdated) - IPC_MESSAGE_UNHANDLED(handled = false) - IPC_END_MESSAGE_MAP() - return handled; -} - -void GeolocationDispatcher::geolocationDestroyed() { - controller_.reset(); - DCHECK(!updating_); -} - -void GeolocationDispatcher::startUpdating() { - // TODO(jknotten): Remove url and bridge_id from StartUpdating message - // once we have switched over to client-based geolocation. - GURL url; - render_view_->Send(new ViewHostMsg_Geolocation_StartUpdating( - render_view_->routing_id(), -1, url, enable_high_accuracy_)); - updating_ = true; -} - -void GeolocationDispatcher::stopUpdating() { - // TODO(jknotten): Remove url and bridge_id from StopUpdating message - // once we have switched over to client-based geolocation. - render_view_->Send(new ViewHostMsg_Geolocation_StopUpdating( - render_view_->routing_id(), -1)); - updating_ = false; -} - -void GeolocationDispatcher::setEnableHighAccuracy(bool enable_high_accuracy) { - // GeolocationController calls setEnableHighAccuracy(true) before - // startUpdating in response to the first high-accuracy Geolocation - // subscription. When the last high-accuracy Geolocation unsubscribes - // it calls setEnableHighAccuracy(false) after stopUpdating. - bool has_changed = enable_high_accuracy_ != enable_high_accuracy; - enable_high_accuracy_ = enable_high_accuracy; - // We have a different accuracy requirement. Request browser to update. - if (updating_ && has_changed) - startUpdating(); -} - -void GeolocationDispatcher::setController( - WebGeolocationController* controller) { - controller_.reset(controller); -} - -bool GeolocationDispatcher::lastPosition(WebGeolocationPosition&) { - // The latest position is stored in the browser, not the renderer, so we - // would have to fetch it synchronously to give a good value here. The - // WebCore::GeolocationController already caches the last position it - // receives, so there is not much benefit to more position caching here. - return false; -} - -// TODO(jknotten): Change the messages to use a security origin, so no -// conversion is necessary. -void GeolocationDispatcher::requestPermission( - const WebGeolocationPermissionRequest& permissionRequest) { - int bridge_id = pending_permissions_->add(permissionRequest); - string16 origin = permissionRequest.securityOrigin().toString(); - render_view_->Send(new ViewHostMsg_Geolocation_RequestPermission( - render_view_->routing_id(), bridge_id, GURL(origin))); -} - -// TODO(jknotten): Change the messages to use a security origin, so no -// conversion is necessary. -void GeolocationDispatcher::cancelPermissionRequest( - const WebGeolocationPermissionRequest& permissionRequest) { - int bridge_id; - if (!pending_permissions_->remove(permissionRequest, bridge_id)) - return; - string16 origin = permissionRequest.securityOrigin().toString(); - render_view_->Send(new ViewHostMsg_Geolocation_CancelPermissionRequest( - render_view_->routing_id(), bridge_id, GURL(origin))); -} - -// Permission for using geolocation has been set. -void GeolocationDispatcher::OnGeolocationPermissionSet( - int bridge_id, bool is_allowed) { - WebGeolocationPermissionRequest permissionRequest; - if (!pending_permissions_->remove(bridge_id, permissionRequest)) - return; - permissionRequest.setIsAllowed(is_allowed); -} - -// We have an updated geolocation position or error code. -void GeolocationDispatcher::OnGeolocationPositionUpdated( - const Geoposition& geoposition) { - DCHECK(updating_); - DCHECK(geoposition.IsInitialized()); - if (geoposition.IsValidFix()) { - controller_->positionChanged( - WebGeolocationPosition( - static_cast(geoposition.timestamp.ToDoubleT() * 1000), - geoposition.latitude, geoposition.longitude, - geoposition.accuracy, - geoposition.is_valid_altitude(), geoposition.altitude, - geoposition.is_valid_altitude_accuracy(), - geoposition.altitude_accuracy, - geoposition.is_valid_heading(), geoposition.heading, - geoposition.is_valid_speed(), geoposition.speed)); - } else { - WebGeolocationError::Error code; - switch (geoposition.error_code) { - case Geoposition::ERROR_CODE_PERMISSION_DENIED: - code = WebGeolocationError::ErrorPermissionDenied; - break; - case Geoposition::ERROR_CODE_POSITION_UNAVAILABLE: - code = WebGeolocationError::ErrorPositionUnavailable; - break; - default: - DCHECK(false); - NOTREACHED() << geoposition.error_code; - return; - } - controller_->errorOccurred( - WebGeolocationError( - code, WebKit::WebString::fromUTF8(geoposition.error_message))); - } -} - -#endif // CLIENT_BASED_GEOLOCATION diff --git a/chrome/renderer/geolocation_dispatcher.h b/chrome/renderer/geolocation_dispatcher.h deleted file mode 100644 index 91c92a8..0000000 --- a/chrome/renderer/geolocation_dispatcher.h +++ /dev/null @@ -1,75 +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_RENDERER_GEOLOCATION_DISPATCHER_H_ -#define CHROME_RENDERER_GEOLOCATION_DISPATCHER_H_ -#pragma once - -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - -#include "base/scoped_ptr.h" -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClient.h" -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationController.h" - -class RenderView; -struct Geoposition; - -namespace WebKit { -class WebGeolocationController; -class WebGeolocationPermissionRequest; -class WebGeolocationPermissionRequestManager; -class WebGeolocationPosition; -class WebSecurityOrigin; -} - -namespace IPC { -class Message; -} - -// GeolocationDispatcher is a delegate for Geolocation messages used by -// WebKit. -// It's the complement of GeolocationDispatcherHost (owned by RenderViewHost). -class GeolocationDispatcher : public WebKit::WebGeolocationClient { - public: - explicit GeolocationDispatcher(RenderView* render_view); - virtual ~GeolocationDispatcher(); - - // IPC - bool OnMessageReceived(const IPC::Message& message); - - // WebGeolocationClient - virtual void geolocationDestroyed(); - virtual void startUpdating(); - virtual void stopUpdating(); - virtual void setEnableHighAccuracy(bool enable_high_accuracy); - virtual void setController(WebKit::WebGeolocationController* controller); - virtual bool lastPosition(WebKit::WebGeolocationPosition& position); - virtual void requestPermission( - const WebKit::WebGeolocationPermissionRequest& permissionRequest); - virtual void cancelPermissionRequest( - const WebKit::WebGeolocationPermissionRequest& permissionRequest); - - private: - // Permission for using geolocation has been set. - void OnGeolocationPermissionSet(int bridge_id, bool is_allowed); - - // We have an updated geolocation position or error code. - void OnGeolocationPositionUpdated(const Geoposition& geoposition); - - // GeolocationDispatcher is owned by RenderView. Back pointer for IPC. - RenderView* render_view_; - - // The controller_ is valid for the lifetime of the underlying - // WebCore::GeolocationController. geolocationDestroyed() is - // invoked when the underlying object is destroyed. - scoped_ptr< WebKit::WebGeolocationController> controller_; - - scoped_ptr - pending_permissions_; - bool enable_high_accuracy_; - bool updating_; -}; -#endif // ENABLE_CLIENT_BASED_GEOLOCATION - -#endif // CHROME_RENDERER_GEOLOCATION_DISPATCHER_H_ diff --git a/chrome/renderer/geolocation_dispatcher_old.cc b/chrome/renderer/geolocation_dispatcher_old.cc index 4a235c7..a6eff8b 100644 --- a/chrome/renderer/geolocation_dispatcher_old.cc +++ b/chrome/renderer/geolocation_dispatcher_old.cc @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) #include "chrome/renderer/geolocation_dispatcher_old.h" + #include "base/command_line.h" #include "chrome/common/chrome_switches.h" #include "chrome/renderer/render_view.h" @@ -113,4 +113,3 @@ void GeolocationDispatcherOld::OnGeolocationPositionUpdated( } } } -#endif // !ENABLE_CLIENT_BASED_GEOLOCATION diff --git a/chrome/renderer/geolocation_dispatcher_old.h b/chrome/renderer/geolocation_dispatcher_old.h index 51567ef..57f7d8a 100644 --- a/chrome/renderer/geolocation_dispatcher_old.h +++ b/chrome/renderer/geolocation_dispatcher_old.h @@ -6,10 +6,6 @@ #define CHROME_RENDERER_GEOLOCATION_DISPATCHER_OLD_H_ #pragma once -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) -// TODO(jknotten): Remove this class once the new client-based implementation is -// checked in (see http://crbug.com/59908). - #include "base/basictypes.h" #include "base/id_map.h" #include "ipc/ipc_message.h" @@ -25,6 +21,8 @@ struct Geoposition; // It's the complement of GeolocationDispatcherHostOld (owned by // RenderViewHost). +// TODO(jknotten): Remove this class once the new client-based implementation is +// checked in (see http://crbug.com/59908). class GeolocationDispatcherOld : public WebKit::WebGeolocationService { public: explicit GeolocationDispatcherOld(RenderView* render_view); @@ -63,6 +61,4 @@ class GeolocationDispatcherOld : public WebKit::WebGeolocationService { DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherOld); }; -#endif // ENABLE_CLIENT_BASED_GEOLOCATION - #endif // CHROME_RENDERER_GEOLOCATION_DISPATCHER_OLD_H_ diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index ca0c0e5..b639dd0 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -63,11 +63,7 @@ #include "chrome/renderer/extensions/renderer_extension_bindings.h" #include "chrome/renderer/external_host_bindings.h" #include "chrome/renderer/external_popup_menu.h" -#if ENABLE_CLIENT_BASED_GEOLOCATION -#include "chrome/renderer/geolocation_dispatcher.h" -#else #include "chrome/renderer/geolocation_dispatcher_old.h" -#endif #include "chrome/renderer/ggl/ggl.h" #include "chrome/renderer/localized_error.h" #include "chrome/renderer/media/audio_renderer_impl.h" @@ -5623,20 +5619,11 @@ void RenderView::OnPageTranslated() { autofill_helper_->FrameContentsAvailable(frame); } -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) -WebKit::WebGeolocationClient* RenderView::geolocationClient() -{ - if (!geolocation_dispatcher_.get()) - geolocation_dispatcher_.reset(new GeolocationDispatcher(this)); - return geolocation_dispatcher_.get(); -} -#else WebKit::WebGeolocationService* RenderView::geolocationService() { if (!geolocation_dispatcher_.get()) geolocation_dispatcher_.reset(new GeolocationDispatcherOld(this)); return geolocation_dispatcher_.get(); } -#endif WebKit::WebSpeechInputController* RenderView::speechInputController( WebKit::WebSpeechInputListener* listener) { diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 8b0fb5b..cdd2102 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -64,7 +64,6 @@ class DomAutomationController; class DOMUIBindings; class ExternalHostBindings; class FilePath; -class GeolocationDispatcher; class GeolocationDispatcherOld; class GURL; class ListValue; @@ -121,7 +120,6 @@ class WebDataSource; class WebDocument; class WebDragData; class WebFrame; -class WebGeolocationClient; class WebGeolocationServiceInterface; class WebImage; class WebInputElement; @@ -484,11 +482,7 @@ class RenderView : public RenderWidget, virtual void didClearAutoFillSelection(const WebKit::WebNode& node); virtual void didAcceptAutocompleteSuggestion( const WebKit::WebInputElement& element); -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - virtual WebKit::WebGeolocationClient* geolocationClient(); -#else virtual WebKit::WebGeolocationService* geolocationService(); -#endif virtual WebKit::WebSpeechInputController* speechInputController( WebKit::WebSpeechInputListener* listener); virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient(); @@ -1380,11 +1374,7 @@ class RenderView : public RenderWidget, scoped_refptr audio_message_filter_; // The geolocation dispatcher attached to this view, lazily initialized. -#if ENABLE_CLIENT_BASED_GEOLOCATION - scoped_ptr geolocation_dispatcher_; -#else scoped_ptr geolocation_dispatcher_; -#endif // Handles accessibility requests into the renderer side, as well as // maintains the cache and other features of the accessibility tree. diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index 3ddfaab..16d7bcd 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -26,11 +26,7 @@ #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClientMock.h" -#else #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceMock.h" -#endif #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" #include "third_party/WebKit/WebKit/chromium/public/WebSecurityPolicy.h" @@ -56,16 +52,13 @@ using std::wstring; using WebKit::WebBindings; using WebKit::WebConsoleMessage; using WebKit::WebElement; +using WebKit::WebGeolocationServiceMock; using WebKit::WebScriptSource; using WebKit::WebSecurityPolicy; using WebKit::WebSize; using WebKit::WebString; using WebKit::WebURL; -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) -using WebKit::WebGeolocationServiceMock; -#endif - TestShell* LayoutTestController::shell_ = NULL; // Most of these flags need to be cleared in Reset() so that they get turned // off between each test run. @@ -1500,12 +1493,7 @@ void LayoutTestController::setGeolocationPermission(const CppArgumentList& args, CppVariant* result) { if (args.size() < 1 || !args[0].isBool()) return; -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - shell_->geolocation_client_mock()->setPermission( - args[0].ToBoolean()); -#else shell_->delegate()->SetGeolocationPermission(args[0].ToBoolean()); -#endif } void LayoutTestController::setMockGeolocationPosition( @@ -1513,26 +1501,16 @@ void LayoutTestController::setMockGeolocationPosition( if (args.size() < 3 || !args[0].isNumber() || !args[1].isNumber() || !args[2].isNumber()) return; -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - shell_->geolocation_client_mock()->setPosition( - args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); -#else WebGeolocationServiceMock::setMockGeolocationPosition( args[0].ToDouble(), args[1].ToDouble(), args[2].ToDouble()); -#endif } void LayoutTestController::setMockGeolocationError(const CppArgumentList& args, CppVariant* result) { if (args.size() < 2 || !args[0].isNumber() || !args[1].isString()) return; -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - shell_->geolocation_client_mock()->setError( - args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); -#else WebGeolocationServiceMock::setMockGeolocationError( args[0].ToInt32(), WebString::fromUTF8(args[1].ToString())); -#endif } void LayoutTestController::markerTextForListItem(const CppArgumentList& args, diff --git a/webkit/tools/test_shell/test_shell.cc b/webkit/tools/test_shell/test_shell.cc index 96d5415..fcd1773 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -34,9 +34,6 @@ #include "third_party/skia/include/core/SkBitmap.h" #include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h" #include "third_party/WebKit/WebKit/chromium/public/WebDeviceOrientationClientMock.h" -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClientMock.h" -#endif #include "third_party/WebKit/WebKit/chromium/public/WebSpeechInputControllerMock.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" @@ -652,10 +649,6 @@ void TestShell::ResetTestController() { event_sending_controller_->Reset(); notification_presenter_->Reset(); delegate_->Reset(); -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - if (geolocation_client_mock_.get()) - geolocation_client_mock_->resetMock(); -#endif } void TestShell::LoadFile(const FilePath& file) { @@ -795,16 +788,6 @@ TestShell::speech_input_controller_mock() { return speech_input_controller_mock_.get(); } -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) -WebKit::WebGeolocationClientMock* TestShell::geolocation_client_mock() { - if (!geolocation_client_mock_.get()) { - geolocation_client_mock_.reset( - WebKit::WebGeolocationClientMock::create()); - } - return geolocation_client_mock_.get(); -} -#endif - //----------------------------------------------------------------------------- namespace webkit_glue { diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi index 088773f..d265a69 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -160,9 +160,6 @@ 'drop_delegate.cc', ], }], - ['"ENABLE_CLIENT_BASED_GEOLOCATION=1" in feature_defines', { - 'defines': [ 'ENABLE_CLIENT_BASED_GEOLOCATION=1' ] - }], ], }, { diff --git a/webkit/tools/test_shell/test_shell.h b/webkit/tools/test_shell/test_shell.h index 29d3d1f..56ade05 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -67,7 +67,6 @@ class StringPiece; namespace WebKit { class WebDeviceOrientationClientMock; -class WebGeolocationClientMock; class WebSpeechInputControllerMock; class WebSpeechInputListener; } @@ -373,10 +372,6 @@ public: WebKit::WebSpeechInputListener* listener); WebKit::WebSpeechInputControllerMock* speech_input_controller_mock(); -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - WebKit::WebGeolocationClientMock* geolocation_client_mock(); -#endif - protected: void CreateDevToolsClient(TestShellDevToolsAgent* agent); bool Initialize(const GURL& starting_url); @@ -461,9 +456,6 @@ private: scoped_ptr speech_input_controller_mock_; -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - scoped_ptr geolocation_client_mock_; -#endif const TestParams* test_params_; // True while a test is preparing to run diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index b791cf2..cd95bad 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -33,9 +33,6 @@ #include "third_party/WebKit/WebKit/chromium/public/WebFileError.h" #include "third_party/WebKit/WebKit/chromium/public/WebFileSystemCallbacks.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) -#include "third_party/WebKit/WebKit/chromium/public/WebGeolocationClientMock.h" -#endif #include "third_party/WebKit/WebKit/chromium/public/WebKit.h" #include "third_party/WebKit/WebKit/chromium/public/WebKitClient.h" #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" @@ -657,15 +654,9 @@ WebNotificationPresenter* TestWebViewDelegate::notificationPresenter() { return shell_->notification_presenter(); } -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) -WebKit::WebGeolocationClient* TestWebViewDelegate::geolocationClient() { - return shell_->geolocation_client_mock(); -} -#else WebKit::WebGeolocationService* TestWebViewDelegate::geolocationService() { return GetTestGeolocationService(); } -#endif WebKit::WebDeviceOrientationClient* TestWebViewDelegate::deviceOrientationClient() { @@ -1216,11 +1207,9 @@ void TestWebViewDelegate::WaitForPolicyDelegate() { policy_delegate_should_notify_done_ = true; } -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) void TestWebViewDelegate::SetGeolocationPermission(bool allowed) { GetTestGeolocationService()->SetGeolocationPermission(allowed); } -#endif // Private methods ----------------------------------------------------------- @@ -1342,13 +1331,11 @@ std::wstring TestWebViewDelegate::GetFrameDescription(WebFrame* webframe) { } } -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) TestGeolocationService* TestWebViewDelegate::GetTestGeolocationService() { if (!test_geolocation_service_.get()) test_geolocation_service_.reset(new TestGeolocationService); return test_geolocation_service_.get(); } -#endif void TestWebViewDelegate::set_fake_window_rect(const WebRect& rect) { fake_rect_ = rect; diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index f5d81ad..3c7f38d 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -141,11 +141,7 @@ class TestWebViewDelegate : public WebKit::WebViewClient, virtual void focusAccessibilityObject( const WebKit::WebAccessibilityObject& object); virtual WebKit::WebNotificationPresenter* notificationPresenter(); -#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) - WebKit::WebGeolocationClient* geolocationClient(); -#else virtual WebKit::WebGeolocationService* geolocationService(); -#endif virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient(); virtual WebKit::WebSpeechInputController* speechInputController( WebKit::WebSpeechInputListener*); @@ -327,9 +323,7 @@ class TestWebViewDelegate : public WebKit::WebViewClient, edit_command_value_.clear(); } -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) void SetGeolocationPermission(bool allowed); -#endif void ClearContextMenuData(); @@ -385,10 +379,8 @@ class TestWebViewDelegate : public WebKit::WebViewClient, // Get a string suitable for dumping a frame to the console. std::wstring GetFrameDescription(WebKit::WebFrame* webframe); -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) // Returns a TestGeolocationService owned by this delegate. TestGeolocationService* GetTestGeolocationService(); -#endif // Causes navigation actions just printout the intended navigation instead // of taking you to the page. This is used for cases like mailto, where you @@ -467,9 +459,7 @@ class TestWebViewDelegate : public WebKit::WebViewClient, // The mock spellchecker used in TestWebViewDelegate::spellCheck(). MockSpellCheck mock_spellcheck_; -#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) scoped_ptr test_geolocation_service_; -#endif DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); }; -- cgit v1.1