diff options
author | jknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 16:18:06 +0000 |
---|---|---|
committer | jknotten@chromium.org <jknotten@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-14 16:18:06 +0000 |
commit | 3263fe62569d29312a2891ab1edaaf2ad2095d47 (patch) | |
tree | 196fd3b7db403e3bd889d16e3b39cc2c5c762271 | |
parent | 31c8dec2cc0fa87d8a492c22e2d38ab8b11bd683 (diff) | |
download | chromium_src-3263fe62569d29312a2891ab1edaaf2ad2095d47.zip chromium_src-3263fe62569d29312a2891ab1edaaf2ad2095d47.tar.gz chromium_src-3263fe62569d29312a2891ab1edaaf2ad2095d47.tar.bz2 |
Merge branch 'GeolocationClientChange1' of ../../chromium-ro/src into issue-5612005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69137 0039d316-1c4b-4281-b951-d872f2087c98
24 files changed, 456 insertions, 102 deletions
diff --git a/build/features_override.gypi b/build/features_override.gypi index 5c069ea..dc59950 100644 --- a/build/features_override.gypi +++ b/build/features_override.gypi @@ -15,6 +15,7 @@ '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_old.cc b/chrome/browser/geolocation/geolocation_dispatcher_host.cc index ca5298d..4f4020b3 100644 --- a/chrome/browser/geolocation/geolocation_dispatcher_host_old.cc +++ b/chrome/browser/geolocation/geolocation_dispatcher_host.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_old.h" +#include "chrome/browser/geolocation/geolocation_dispatcher_host.h" #include <map> #include <set> @@ -19,24 +19,21 @@ #include "ipc/ipc_message.h" namespace { -class GeolocationDispatcherHostOldImpl : public GeolocationDispatcherHostOld, - public GeolocationObserver { +class GeolocationDispatcherHostImpl : public GeolocationDispatcherHost, + public GeolocationObserver { public: - GeolocationDispatcherHostOldImpl( - int resource_message_filter_process_id, + GeolocationDispatcherHostImpl( + int render_process_id, GeolocationPermissionContext* geolocation_permission_context); - // GeolocationDispatcherHostOld - // Called to possibly handle the incoming IPC message. Returns true if - // handled. Called in the browser process. + // GeolocationDispatcherHost virtual bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok); - // GeolocationArbitrator::Delegate + // GeolocationObserver virtual void OnLocationUpdate(const Geoposition& position); private: - friend class base::RefCountedThreadSafe<GeolocationDispatcherHostOldImpl>; - virtual ~GeolocationDispatcherHostOldImpl(); + virtual ~GeolocationDispatcherHostImpl(); void OnRegisterDispatcher(int render_view_id); void OnUnregisterDispatcher(int render_view_id); @@ -55,7 +52,7 @@ class GeolocationDispatcherHostOldImpl : public GeolocationDispatcherHostOld, // options, based on |bridge_update_options_|. void RefreshGeolocationObserverOptions(); - int resource_message_filter_process_id_; + int render_process_id_; scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; // Iterated when sending location updates to renderer processes. The fan out @@ -70,13 +67,13 @@ class GeolocationDispatcherHostOldImpl : public GeolocationDispatcherHostOld, // Only set whilst we are registered with the arbitrator. GeolocationProvider* location_provider_; - DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostOldImpl); + DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHostImpl); }; -GeolocationDispatcherHostOldImpl::GeolocationDispatcherHostOldImpl( - int resource_message_filter_process_id, +GeolocationDispatcherHostImpl::GeolocationDispatcherHostImpl( + int render_process_id, GeolocationPermissionContext* geolocation_permission_context) - : resource_message_filter_process_id_(resource_message_filter_process_id), + : 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 @@ -84,17 +81,17 @@ GeolocationDispatcherHostOldImpl::GeolocationDispatcherHostOldImpl( // a javascript geolocation object is actually initialized. } -GeolocationDispatcherHostOldImpl::~GeolocationDispatcherHostOldImpl() { +GeolocationDispatcherHostImpl::~GeolocationDispatcherHostImpl() { if (location_provider_) location_provider_->RemoveObserver(this); } -bool GeolocationDispatcherHostOldImpl::OnMessageReceived( +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(GeolocationDispatcherHostOldImpl, msg, *msg_was_ok) + IPC_BEGIN_MESSAGE_MAP_EX(GeolocationDispatcherHostImpl, msg, *msg_was_ok) IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_RegisterDispatcher, OnRegisterDispatcher) IPC_MESSAGE_HANDLER(ViewHostMsg_Geolocation_UnregisterDispatcher, @@ -116,103 +113,112 @@ bool GeolocationDispatcherHostOldImpl::OnMessageReceived( return handled; } -void GeolocationDispatcherHostOldImpl::OnLocationUpdate( +void GeolocationDispatcherHostImpl::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(resource_message_filter_process_id_, *it, + CallRenderViewHost(render_process_id_, *it, &RenderViewHost::Send, message); } } -void GeolocationDispatcherHostOldImpl::OnRegisterDispatcher( +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 GeolocationDispatcherHostOldImpl::OnUnregisterDispatcher( +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 GeolocationDispatcherHostOldImpl::OnRequestPermission( +void GeolocationDispatcherHostImpl::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_ << ":" + DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" << render_view_id << ":" << bridge_id; geolocation_permission_context_->RequestGeolocationPermission( - resource_message_filter_process_id_, render_view_id, bridge_id, + render_process_id_, render_view_id, bridge_id, requesting_frame); } -void GeolocationDispatcherHostOldImpl::OnCancelPermissionRequest( +void GeolocationDispatcherHostImpl::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_ << ":" + DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" << render_view_id << ":" << bridge_id; geolocation_permission_context_->CancelGeolocationPermissionRequest( - resource_message_filter_process_id_, render_view_id, bridge_id, + render_process_id_, render_view_id, bridge_id, requesting_frame); } -void GeolocationDispatcherHostOldImpl::OnStartUpdating( +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__ << " " << resource_message_filter_process_id_ << ":" + 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( - resource_message_filter_process_id_, render_view_id, bridge_id, + render_process_id_, render_view_id, bridge_id, requesting_frame); RefreshGeolocationObserverOptions(); } -void GeolocationDispatcherHostOldImpl::OnStopUpdating(int render_view_id, +void GeolocationDispatcherHostImpl::OnStopUpdating(int render_view_id, int bridge_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" + 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( - resource_message_filter_process_id_, render_view_id, bridge_id); + render_process_id_, render_view_id, bridge_id); +#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) + OnUnregisterDispatcher(render_view_id); +#endif } -void GeolocationDispatcherHostOldImpl::OnSuspend(int render_view_id, +void GeolocationDispatcherHostImpl::OnSuspend(int render_view_id, int bridge_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" + DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" << render_view_id << ":" << bridge_id; // TODO(bulach): connect this with GeolocationArbitrator. } -void GeolocationDispatcherHostOldImpl::OnResume(int render_view_id, +void GeolocationDispatcherHostImpl::OnResume(int render_view_id, int bridge_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - DVLOG(1) << __FUNCTION__ << " " << resource_message_filter_process_id_ << ":" + DVLOG(1) << __FUNCTION__ << " " << render_process_id_ << ":" << render_view_id << ":" << bridge_id; // TODO(bulach): connect this with GeolocationArbitrator. } -void GeolocationDispatcherHostOldImpl::RefreshGeolocationObserverOptions() { +void GeolocationDispatcherHostImpl::RefreshGeolocationObserverOptions() { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); if (bridge_update_options_.empty()) { if (location_provider_) { @@ -230,10 +236,10 @@ void GeolocationDispatcherHostOldImpl::RefreshGeolocationObserverOptions() { } } // namespace -GeolocationDispatcherHostOld* GeolocationDispatcherHostOld::New( - int resource_message_filter_process_id, +GeolocationDispatcherHost* GeolocationDispatcherHost::New( + int render_process_id, GeolocationPermissionContext* geolocation_permission_context) { - return new GeolocationDispatcherHostOldImpl( - resource_message_filter_process_id, + 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 new file mode 100644 index 0000000..293cb33 --- /dev/null +++ b/chrome/browser/geolocation/geolocation_dispatcher_host.h @@ -0,0 +1,31 @@ +// 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.h b/chrome/browser/geolocation/geolocation_dispatcher_host_old.h deleted file mode 100644 index 655049a..0000000 --- a/chrome/browser/geolocation/geolocation_dispatcher_host_old.h +++ /dev/null @@ -1,39 +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_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 2a8e542..1f8160d 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.cc +++ b/chrome/browser/geolocation/geolocation_permission_context.cc @@ -10,7 +10,6 @@ #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" @@ -440,6 +439,12 @@ 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 @@ -449,11 +454,14 @@ 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 432c9a2..c2a08e7 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 - // enbaled at a given time (e.g. prior to the user agreeing to any geolocation + // enabled 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 689ab9c..e3575f0 100644 --- a/chrome/browser/geolocation/mock_location_provider.cc +++ b/chrome/browser/geolocation/mock_location_provider.cc @@ -78,7 +78,9 @@ class AutoMockLocationProvider : public MockLocationProvider { position_.accuracy = 3; position_.latitude = 4.3; position_.longitude = -7.8; - position_.timestamp = base::Time::FromDoubleT(4567.8); + // Webkit compares the timestamp to wall clock time, so we need it to be + // contemporary. + position_.timestamp = base::Time::Now(); } 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 cb3eb82..61849ec 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.cc +++ b/chrome/browser/renderer_host/browser_render_process_host.cc @@ -37,6 +37,7 @@ #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" @@ -400,6 +401,9 @@ 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 6f12cdd..5fa92ec 100644 --- a/chrome/browser/renderer_host/render_message_filter.cc +++ b/chrome/browser/renderer_host/render_message_filter.cc @@ -21,8 +21,7 @@ #include "chrome/browser/clipboard_dispatcher.h" #include "chrome/browser/download/download_types.h" #include "chrome/browser/extensions/extension_message_service.h" -#include "chrome/browser/geolocation/geolocation_dispatcher_host_old.h" -#include "chrome/browser/geolocation/geolocation_permission_context.h" +#include "chrome/browser/file_system/file_system_dispatcher_host.h" #include "chrome/browser/gpu_process_host.h" #include "chrome/browser/host_zoom_map.h" #include "chrome/browser/metrics/histogram_synchronizer.h" @@ -251,9 +250,6 @@ 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_); @@ -324,8 +320,7 @@ 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) || - geolocation_dispatcher_host_->OnMessageReceived(msg, &msg_is_ok); + msg, this, next_route_id_callback(), &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 69bc8f7..e912aaa 100644 --- a/chrome/browser/renderer_host/render_message_filter.h +++ b/chrome/browser/renderer_host/render_message_filter.h @@ -34,7 +34,6 @@ class ChromeURLRequestContext; struct FontDescriptor; -class GeolocationDispatcherHostOld; class HostZoomMap; class NotificationsPrefsCache; class PpapiPluginProcessHost; @@ -449,8 +448,6 @@ class RenderMessageFilter : public IPC::ChannelProxy::MessageFilter, // A callback to create a routing id for the associated renderer process. scoped_ptr<CallbackWithReturnValue<int>::Type> next_route_id_callback_; - // Used to handle geolocation-related messages. - scoped_refptr<GeolocationDispatcherHostOld> geolocation_dispatcher_host_; scoped_refptr<WebKitContext> webkit_context_; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index bca8996..c02ea1e 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1258,8 +1258,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_old.cc', - 'browser/geolocation/geolocation_dispatcher_host_old.h', + 'browser/geolocation/geolocation_dispatcher_host.cc', + 'browser/geolocation/geolocation_dispatcher_host.h', 'browser/geolocation/geolocation_exceptions_table_model.cc', 'browser/geolocation/geolocation_exceptions_table_model.h', 'browser/geolocation/geolocation_observer.h', @@ -4343,6 +4343,14 @@ '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 87889aa..2a69cd7 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -112,6 +112,8 @@ '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', @@ -312,6 +314,14 @@ '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 new file mode 100644 index 0000000..39596af --- /dev/null +++ b/chrome/renderer/geolocation_dispatcher.cc @@ -0,0 +1,155 @@ +// 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<int64>(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 new file mode 100644 index 0000000..91c92a8 --- /dev/null +++ b/chrome/renderer/geolocation_dispatcher.h @@ -0,0 +1,75 @@ +// 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<WebKit::WebGeolocationPermissionRequestManager> + 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 a6eff8b..4a235c7 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,3 +113,4 @@ 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 57f7d8a..51567ef 100644 --- a/chrome/renderer/geolocation_dispatcher_old.h +++ b/chrome/renderer/geolocation_dispatcher_old.h @@ -6,6 +6,10 @@ #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" @@ -21,8 +25,6 @@ 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); @@ -61,4 +63,6 @@ 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 b639dd0..ca0c0e5 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -63,7 +63,11 @@ #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" @@ -5619,11 +5623,20 @@ 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 cdd2102..8b0fb5b 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -64,6 +64,7 @@ class DomAutomationController; class DOMUIBindings; class ExternalHostBindings; class FilePath; +class GeolocationDispatcher; class GeolocationDispatcherOld; class GURL; class ListValue; @@ -120,6 +121,7 @@ class WebDataSource; class WebDocument; class WebDragData; class WebFrame; +class WebGeolocationClient; class WebGeolocationServiceInterface; class WebImage; class WebInputElement; @@ -482,7 +484,11 @@ 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(); @@ -1374,7 +1380,11 @@ class RenderView : public RenderWidget, scoped_refptr<AudioMessageFilter> audio_message_filter_; // The geolocation dispatcher attached to this view, lazily initialized. +#if ENABLE_CLIENT_BASED_GEOLOCATION + scoped_ptr<GeolocationDispatcher> geolocation_dispatcher_; +#else scoped_ptr<GeolocationDispatcherOld> 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 d344dfa..1918106 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -26,7 +26,11 @@ #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" @@ -52,13 +56,16 @@ 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. @@ -1493,7 +1500,12 @@ 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( @@ -1501,16 +1513,26 @@ 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 aaa6d37..fc4c7e7 100644 --- a/webkit/tools/test_shell/test_shell.cc +++ b/webkit/tools/test_shell/test_shell.cc @@ -34,6 +34,9 @@ #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" @@ -647,6 +650,10 @@ 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) { @@ -786,6 +793,16 @@ 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 d265a69..088773f 100644 --- a/webkit/tools/test_shell/test_shell.gypi +++ b/webkit/tools/test_shell/test_shell.gypi @@ -160,6 +160,9 @@ '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 b35bb59..61b7ff2 100644 --- a/webkit/tools/test_shell/test_shell.h +++ b/webkit/tools/test_shell/test_shell.h @@ -67,6 +67,7 @@ class StringPiece; namespace WebKit { class WebDeviceOrientationClientMock; +class WebGeolocationClientMock; class WebSpeechInputControllerMock; class WebSpeechInputListener; } @@ -372,6 +373,10 @@ 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); @@ -456,6 +461,9 @@ private: scoped_ptr<WebKit::WebSpeechInputControllerMock> speech_input_controller_mock_; +#if defined(ENABLE_CLIENT_BASED_GEOLOCATION) + scoped_ptr<WebKit::WebGeolocationClientMock> 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 cd95bad..b791cf2 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -33,6 +33,9 @@ #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" @@ -654,9 +657,15 @@ 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() { @@ -1207,9 +1216,11 @@ 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 ----------------------------------------------------------- @@ -1331,11 +1342,13 @@ 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 3c7f38d..f5d81ad 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -141,7 +141,11 @@ 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*); @@ -323,7 +327,9 @@ class TestWebViewDelegate : public WebKit::WebViewClient, edit_command_value_.clear(); } +#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) void SetGeolocationPermission(bool allowed); +#endif void ClearContextMenuData(); @@ -379,8 +385,10 @@ 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 @@ -459,7 +467,9 @@ class TestWebViewDelegate : public WebKit::WebViewClient, // The mock spellchecker used in TestWebViewDelegate::spellCheck(). MockSpellCheck mock_spellcheck_; +#if !defined(ENABLE_CLIENT_BASED_GEOLOCATION) scoped_ptr<TestGeolocationService> test_geolocation_service_; +#endif DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); }; |