diff options
author | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 11:18:04 +0000 |
---|---|---|
committer | joth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 11:18:04 +0000 |
commit | c476e6316a406234898bd0af07bd0a02ffb40f51 (patch) | |
tree | c6534cc82b467a399c58cb9c1b9b7c4d27f08e7d /chrome | |
parent | 2e0c83f3ac2082c6b7db028bf80b77434823db10 (diff) | |
download | chromium_src-c476e6316a406234898bd0af07bd0a02ffb40f51.zip chromium_src-c476e6316a406234898bd0af07bd0a02ffb40f51.tar.gz chromium_src-c476e6316a406234898bd0af07bd0a02ffb40f51.tar.bz2 |
Split out abstract interface from GeolocationPermissionContext
This allows clear separation of chrome from content without requiring a link-time dependency from content onto the embedder to provide the permission context implementaiton.
BUG=None
TEST=No new tests.
Review URL: http://codereview.chromium.org/7037005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90196 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/geolocation/chrome_geolocation_permission_context.cc (renamed from chrome/browser/geolocation/geolocation_permission_context.cc) | 38 | ||||
-rw-r--r-- | chrome/browser/geolocation/chrome_geolocation_permission_context.h | 62 | ||||
-rw-r--r-- | chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc (renamed from chrome/browser/geolocation/geolocation_permission_context_unittest.cc) | 8 | ||||
-rw-r--r-- | chrome/browser/profiles/profile_impl.cc | 5 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 3 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 2 | ||||
-rw-r--r-- | chrome/test/testing_profile.cc | 4 |
7 files changed, 92 insertions, 30 deletions
diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context.cc index 54ed24d..9b3bd60 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context.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 "content/browser/geolocation/geolocation_permission_context.h" +#include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" #include <functional> #include <string> @@ -23,8 +23,6 @@ #include "content/browser/browser_thread.h" #include "content/browser/geolocation/geolocation_provider.h" #include "content/browser/renderer_host/render_process_host.h" -#include "content/browser/renderer_host/render_view_host.h" -#include "content/common/geolocation_messages.h" #include "content/common/notification_registrar.h" #include "content/common/notification_source.h" #include "content/common/notification_type.h" @@ -48,7 +46,7 @@ class GeolocationInfoBarQueueController : NotificationObserver { public: GeolocationInfoBarQueueController( - GeolocationPermissionContext* geolocation_permission_context, + ChromeGeolocationPermissionContext* geolocation_permission_context, Profile* profile); ~GeolocationInfoBarQueueController(); @@ -101,7 +99,7 @@ class GeolocationInfoBarQueueController : NotificationObserver { NotificationRegistrar registrar_; - GeolocationPermissionContext* const geolocation_permission_context_; + ChromeGeolocationPermissionContext* const geolocation_permission_context_; Profile* const profile_; PendingInfoBarRequests pending_infobar_requests_; }; @@ -320,7 +318,7 @@ bool GeolocationInfoBarQueueController::RequestEquals::operator()( // GeolocationInfoBarQueueController ------------------------------------------ GeolocationInfoBarQueueController::GeolocationInfoBarQueueController( - GeolocationPermissionContext* geolocation_permission_context, + ChromeGeolocationPermissionContext* geolocation_permission_context, Profile* profile) : geolocation_permission_context_(geolocation_permission_context), profile_(profile) { @@ -493,22 +491,22 @@ GeolocationInfoBarQueueController::PendingInfoBarRequests::iterator // GeolocationPermissionContext ----------------------------------------------- -GeolocationPermissionContext::GeolocationPermissionContext( +ChromeGeolocationPermissionContext::ChromeGeolocationPermissionContext( Profile* profile) : profile_(profile), ALLOW_THIS_IN_INITIALIZER_LIST(geolocation_infobar_queue_controller_( new GeolocationInfoBarQueueController(this, profile))) { } -GeolocationPermissionContext::~GeolocationPermissionContext() { +ChromeGeolocationPermissionContext::~ChromeGeolocationPermissionContext() { } -void GeolocationPermissionContext::RequestGeolocationPermission( +void ChromeGeolocationPermissionContext::RequestGeolocationPermission( int render_process_id, int render_view_id, int bridge_id, const GURL& requesting_frame) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( - this, &GeolocationPermissionContext::RequestGeolocationPermission, + this, &ChromeGeolocationPermissionContext::RequestGeolocationPermission, render_process_id, render_view_id, bridge_id, requesting_frame)); return; } @@ -568,7 +566,7 @@ void GeolocationPermissionContext::RequestGeolocationPermission( } } -void GeolocationPermissionContext::CancelGeolocationPermissionRequest( +void ChromeGeolocationPermissionContext::CancelGeolocationPermissionRequest( int render_process_id, int render_view_id, int bridge_id, @@ -576,7 +574,7 @@ void GeolocationPermissionContext::CancelGeolocationPermissionRequest( CancelPendingInfoBarRequest(render_process_id, render_view_id, bridge_id); } -void GeolocationPermissionContext::NotifyPermissionSet( +void ChromeGeolocationPermissionContext::NotifyPermissionSet( int render_process_id, int render_view_id, int bridge_id, @@ -592,32 +590,30 @@ void GeolocationPermissionContext::NotifyPermissionSet( allowed); } - RenderViewHost* r = RenderViewHost::FromID(render_process_id, render_view_id); - if (r) { - r->Send(new GeolocationMsg_PermissionSet( - render_view_id, bridge_id, allowed)); - } + GeolocationPermissionContext::SetGeolocationPermissionResponse( + render_process_id, render_view_id, bridge_id, allowed); if (allowed) { BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableMethod( - this, &GeolocationPermissionContext::NotifyArbitratorPermissionGranted, + this, + &ChromeGeolocationPermissionContext::NotifyArbitratorPermissionGranted, requesting_frame)); } } -void GeolocationPermissionContext::NotifyArbitratorPermissionGranted( +void ChromeGeolocationPermissionContext::NotifyArbitratorPermissionGranted( const GURL& requesting_frame) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); GeolocationProvider::GetInstance()->OnPermissionGranted(requesting_frame); } -void GeolocationPermissionContext::CancelPendingInfoBarRequest( +void ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest( int render_process_id, int render_view_id, int bridge_id) { if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, NewRunnableMethod( - this, &GeolocationPermissionContext::CancelPendingInfoBarRequest, + this, &ChromeGeolocationPermissionContext::CancelPendingInfoBarRequest, render_process_id, render_view_id, bridge_id)); return; } diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context.h b/chrome/browser/geolocation/chrome_geolocation_permission_context.h new file mode 100644 index 0000000..2195362 --- /dev/null +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context.h @@ -0,0 +1,62 @@ +// Copyright (c) 2011 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_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ +#define CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ +#pragma once + +#include "base/memory/scoped_ptr.h" +#include "content/browser/geolocation/geolocation_permission_context.h" + +class GeolocationInfoBarQueueController; +class Profile; + +// Chrome specific implementation of GeolocationPermissionContext; manages +// Geolocation permissions flow, and delegates UI handling via +// GeolocationInfoBarQueueController. +class ChromeGeolocationPermissionContext : public GeolocationPermissionContext { + public: + explicit ChromeGeolocationPermissionContext(Profile* profile); + + // Notifies whether or not the corresponding bridge is allowed to use + // geolocation via + // GeolocationPermissionContext::SetGeolocationPermissionResponse(). + void NotifyPermissionSet(int render_process_id, + int render_view_id, + int bridge_id, + const GURL& requesting_frame, + bool allowed); + + // GeolocationPermissionContext + virtual void RequestGeolocationPermission(int render_process_id, + int render_view_id, + int bridge_id, + const GURL& requesting_frame); + + virtual void CancelGeolocationPermissionRequest(int render_process_id, + int render_view_id, + int bridge_id, + const GURL& requesting_frame); + + private: + virtual ~ChromeGeolocationPermissionContext(); + + // Calls GeolocationArbitrator::OnPermissionGranted. + void NotifyArbitratorPermissionGranted(const GURL& requesting_frame); + + // Removes any pending InfoBar request. + void CancelPendingInfoBarRequest(int render_process_id, + int render_view_id, + int bridge_id); + + // This must only be accessed from the UI thread. + Profile* const profile_; + + scoped_ptr<GeolocationInfoBarQueueController> + geolocation_infobar_queue_controller_; + + DISALLOW_COPY_AND_ASSIGN(ChromeGeolocationPermissionContext); +}; + +#endif // CHROME_BROWSER_GEOLOCATION_CHROME_GEOLOCATION_PERMISSION_CONTEXT_H_ diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc index 7d7ac53..3d86695 100644 --- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" + #include <set> #include "base/memory/scoped_vector.h" @@ -13,7 +15,6 @@ #include "chrome/test/testing_profile.h" #include "content/browser/browser_thread.h" #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h" -#include "content/browser/geolocation/geolocation_permission_context.h" #include "content/browser/geolocation/location_arbitrator.h" #include "content/browser/geolocation/location_provider.h" #include "content/browser/geolocation/mock_location_provider.h" @@ -108,7 +109,8 @@ class GeolocationPermissionContextTests : public TabContentsWrapperTestHarness { void CheckTabContentsState(const GURL& requesting_frame, ContentSetting expected_content_setting); - scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_; + scoped_refptr<ChromeGeolocationPermissionContext> + geolocation_permission_context_; ClosedDelegateTracker closed_delegate_tracker_; ScopedVector<TabContentsWrapper> extra_tabs_; @@ -193,7 +195,7 @@ void GeolocationPermissionContextTests::SetUp() { GeolocationArbitrator::SetDependencyFactoryForTest( dependency_factory_.get()); geolocation_permission_context_ = - new GeolocationPermissionContext(profile()); + new ChromeGeolocationPermissionContext(profile()); } void GeolocationPermissionContextTests::TearDown() { diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index 179ec61..8718711 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -37,6 +37,7 @@ #include "chrome/browser/extensions/extension_special_storage_policy.h" #include "chrome/browser/extensions/user_script_master.h" #include "chrome/browser/favicon/favicon_service.h" +#include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/top_sites.h" @@ -89,7 +90,6 @@ #include "content/browser/browser_thread.h" #include "content/browser/chrome_blob_storage_context.h" #include "content/browser/file_system/browser_file_system_helper.h" -#include "content/browser/geolocation/geolocation_permission_context.h" #include "content/browser/host_zoom_map.h" #include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/renderer_host/render_process_host.h" @@ -990,7 +990,8 @@ GeolocationContentSettingsMap* ProfileImpl::GetGeolocationContentSettingsMap() { GeolocationPermissionContext* ProfileImpl::GetGeolocationPermissionContext() { if (!geolocation_permission_context_.get()) - geolocation_permission_context_ = new GeolocationPermissionContext(this); + geolocation_permission_context_ = + new ChromeGeolocationPermissionContext(this); return geolocation_permission_context_.get(); } diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 5c6cec9..b76b461 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1147,7 +1147,8 @@ 'browser/geolocation/geolocation_content_settings_map.h', 'browser/geolocation/geolocation_exceptions_table_model.cc', 'browser/geolocation/geolocation_exceptions_table_model.h', - 'browser/geolocation/geolocation_permission_context.cc', + 'browser/geolocation/chrome_geolocation_permission_context.cc', + 'browser/geolocation/chrome_geolocation_permission_contexth', 'browser/geolocation/geolocation_prefs.cc', 'browser/geolocation/geolocation_prefs.h', 'browser/geolocation/geolocation_settings_state.cc', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 2c0a9c9..a3630f1 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -1419,7 +1419,7 @@ 'browser/first_run/first_run_unittest.cc', 'browser/geolocation/geolocation_content_settings_map_unittest.cc', 'browser/geolocation/geolocation_exceptions_table_model_unittest.cc', - 'browser/geolocation/geolocation_permission_context_unittest.cc', + 'browser/geolocation/chrome_geolocation_permission_context_unittest.cc', 'browser/geolocation/geolocation_settings_state_unittest.cc', 'browser/geolocation/wifi_data_provider_unittest_chromeos.cc', 'browser/global_keyboard_shortcuts_mac_unittest.mm', diff --git a/chrome/test/testing_profile.cc b/chrome/test/testing_profile.cc index 08dd691..d2249e6 100644 --- a/chrome/test/testing_profile.cc +++ b/chrome/test/testing_profile.cc @@ -22,6 +22,7 @@ #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/extension_special_storage_policy.h" #include "chrome/browser/favicon/favicon_service.h" +#include "chrome/browser/geolocation/chrome_geolocation_permission_context.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" #include "chrome/browser/history/history.h" #include "chrome/browser/history/history_backend.h" @@ -50,7 +51,6 @@ #include "chrome/test/testing_pref_service.h" #include "chrome/test/ui_test_utils.h" #include "content/browser/browser_thread.h" -#include "content/browser/geolocation/geolocation_permission_context.h" #include "content/browser/in_process_webkit/webkit_context.h" #include "content/browser/mock_resource_context.h" #include "content/common/notification_service.h" @@ -628,7 +628,7 @@ GeolocationPermissionContext* TestingProfile::GetGeolocationPermissionContext() { if (!geolocation_permission_context_.get()) { geolocation_permission_context_ = - new GeolocationPermissionContext(this); + new ChromeGeolocationPermissionContext(this); } return geolocation_permission_context_.get(); } |