summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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.h62
-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.cc5
-rw-r--r--chrome/chrome_browser.gypi3
-rw-r--r--chrome/chrome_tests.gypi2
-rw-r--r--chrome/test/testing_profile.cc4
-rw-r--r--content/browser/content_browser_client.h8
-rw-r--r--content/browser/geolocation/geolocation_dispatcher_host.h5
-rw-r--r--content/browser/geolocation/geolocation_permission_context.cc23
-rw-r--r--content/browser/geolocation/geolocation_permission_context.h68
-rw-r--r--content/content_browser.gypi1
12 files changed, 150 insertions, 77 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();
}
diff --git a/content/browser/content_browser_client.h b/content/browser/content_browser_client.h
index 51a4d30..ddebd04 100644
--- a/content/browser/content_browser_client.h
+++ b/content/browser/content_browser_client.h
@@ -48,8 +48,14 @@ namespace content {
class ResourceContext;
class WebUIFactory;
-// Embedder API for participating in browser logic. The methods are assumed to
+// Embedder API (or SPI) for participating in browser logic, to be implemented
+// by the client of the content browser. See ChromeContentBrowserClient for the
+// principle implementation. The methods are assumed to
// be called on the UI thread unless otherwise specified.
+// Use this "escape hatch" sparingly, to avoid the embedder interface ballooning
+// and becoming very specific to Chrome. (Often, the call out to the client can
+// happen in a different part of the code that either already has a hook out to
+// the embedder, or calls out to one of the observer interfaces.)
class ContentBrowserClient {
public:
// Notifies that a new RenderHostView has been created.
diff --git a/content/browser/geolocation/geolocation_dispatcher_host.h b/content/browser/geolocation/geolocation_dispatcher_host.h
index 5a42272..c890043 100644
--- a/content/browser/geolocation/geolocation_dispatcher_host.h
+++ b/content/browser/geolocation/geolocation_dispatcher_host.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// 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.
@@ -12,15 +12,12 @@ 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() {}
diff --git a/content/browser/geolocation/geolocation_permission_context.cc b/content/browser/geolocation/geolocation_permission_context.cc
new file mode 100644
index 0000000..dd92515
--- /dev/null
+++ b/content/browser/geolocation/geolocation_permission_context.cc
@@ -0,0 +1,23 @@
+// 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.
+
+#include "content/browser/geolocation/geolocation_permission_context.h"
+
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/common/geolocation_messages.h"
+
+// static
+void GeolocationPermissionContext::SetGeolocationPermissionResponse(
+ int render_process_id, int render_view_id, int bridge_id, bool is_allowed) {
+ RenderViewHost* r = RenderViewHost::FromID(render_process_id, render_view_id);
+ if (r) {
+ r->Send(new GeolocationMsg_PermissionSet(render_view_id, bridge_id,
+ is_allowed));
+ }
+}
+
+GeolocationPermissionContext::GeolocationPermissionContext() {}
+
+GeolocationPermissionContext::~GeolocationPermissionContext() {}
+
diff --git a/content/browser/geolocation/geolocation_permission_context.h b/content/browser/geolocation/geolocation_permission_context.h
index 93a2eb6..ff6b7dc 100644
--- a/content/browser/geolocation/geolocation_permission_context.h
+++ b/content/browser/geolocation/geolocation_permission_context.h
@@ -8,58 +8,42 @@
#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-class GeolocationInfoBarQueueController;
-class GeolocationPermissionContext;
class GURL;
-class InfoBarDelegate;
-class Profile;
-class RenderViewHost;
-class TabContents;
-// GeolocationPermissionContext manages Geolocation permissions flow,
-// and delegates UI handling via GeolocationInfoBarQueueController.
-// It always notifies the requesting render_view asynchronously via
-// GeolocationMsg_PermissionSet.
+// GeolocationPermissionContext must be implemented by the embedder, to provide
+// the policy and logic for the Geolocation permissions flow.
+// This includes both prompting the user and persisting results, as required.
class GeolocationPermissionContext
: public base::RefCountedThreadSafe<GeolocationPermissionContext> {
public:
- explicit GeolocationPermissionContext(Profile* profile);
-
- // The render is requesting permission to use Geolocation.
- // Response will be sent asynchronously as GeolocationMsg_PermissionSet.
- void RequestGeolocationPermission(
- int render_process_id, int render_view_id, int bridge_id,
- const GURL& requesting_frame);
-
- // The render is cancelling a pending permission request.
- void CancelGeolocationPermissionRequest(
+ // The renderer is requesting permission to use Geolocation.
+ // When the answer to a permission request has been determined, the result
+ // should be forwarded to the renderer via SetGeolocationPermissionResponse().
+ virtual void RequestGeolocationPermission(int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ const GURL& requesting_frame) = 0;
+
+ // The renderer is cancelling a pending permission request.
+ virtual void CancelGeolocationPermissionRequest(
int render_process_id, int render_view_id, int bridge_id,
- const GURL& requesting_frame);
-
- // Notifies whether or not the corresponding bridge is allowed to use
- // geolocation via GeolocationMsg_PermissionSet.
- void NotifyPermissionSet(
- int render_process_id, int render_view_id, int bridge_id,
- const GURL& requesting_frame, bool allowed);
+ const GURL& requesting_frame) = 0;
+
+ // The embedder must callback to this method when the outcome of a previous
+ // geolocation request (indicated via RequestGeolocationPermission above) has
+ // been determined.
+ static void SetGeolocationPermissionResponse(int render_process_id,
+ int render_view_id,
+ int bridge_id,
+ bool is_allowed);
+
+ protected:
+ GeolocationPermissionContext();
+ virtual ~GeolocationPermissionContext();
private:
friend class base::RefCountedThreadSafe<GeolocationPermissionContext>;
- virtual ~GeolocationPermissionContext();
-
- // 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 should only be accessed from the UI thread.
- Profile* const profile_;
-
- scoped_ptr<GeolocationInfoBarQueueController>
- geolocation_infobar_queue_controller_;
DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContext);
};
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index 0d8566f..2bc241e 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -97,6 +97,7 @@
'browser/geolocation/geolocation_dispatcher_host.cc',
'browser/geolocation/geolocation_dispatcher_host.h',
'browser/geolocation/geolocation_observer.h',
+ 'browser/geolocation/geolocation_permission_context.cc',
'browser/geolocation/geolocation_permission_context.h',
'browser/geolocation/geolocation_provider.cc',
'browser/geolocation/geolocation_provider.h',