summaryrefslogtreecommitdiffstats
path: root/chrome/browser/geolocation/geolocation_dispatcher_host.h
diff options
context:
space:
mode:
authorbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-19 12:11:28 +0000
committerbulach@chromium.org <bulach@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-19 12:11:28 +0000
commit58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74 (patch)
treecdd273a38ba1b449952d5701e6ceb6f46142c073 /chrome/browser/geolocation/geolocation_dispatcher_host.h
parent2375d294b30e5d0b0bc63d26a417203959ef32af (diff)
downloadchromium_src-58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74.zip
chromium_src-58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74.tar.gz
chromium_src-58c321dd57a1fc00c2c51b0a8b6e547fdf32aa74.tar.bz2
Second try for:
http://src.chromium.org/viewvc/chrome?view=rev&revision=39374 Initial Geolocation implementation Adds IPC plumbing. Adds Infobar buttons for requesting permission This change specifically: ui_test_utils::WaitForAppModalDialog registers for listening to notifications too late, i.e., after the dialog had been triggered. Exposes AppModalDialogObserver so that we can register, trigger the dialog, then wait for it. Review URL: http://codereview.chromium.org/647048 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39435 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/geolocation/geolocation_dispatcher_host.h')
-rw-r--r--chrome/browser/geolocation/geolocation_dispatcher_host.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/chrome/browser/geolocation/geolocation_dispatcher_host.h b/chrome/browser/geolocation/geolocation_dispatcher_host.h
new file mode 100644
index 0000000..8bd7eaf
--- /dev/null
+++ b/chrome/browser/geolocation/geolocation_dispatcher_host.h
@@ -0,0 +1,77 @@
+// 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_
+
+#include <set>
+
+#include "base/basictypes.h"
+#include "base/ref_counted.h"
+#include "ipc/ipc_message.h"
+
+class GeolocationPermissionContext;
+struct Geoposition;
+class GURL;
+class ResourceMessageFilter;
+
+// GeolocationDispatcherHost is a delegate for Geolocation messages used by
+// ResourceMessageFilter.
+// It's the complement of GeolocationDispatcher (owned by RenderView).
+class GeolocationDispatcherHost
+ : public base::RefCountedThreadSafe<GeolocationDispatcherHost> {
+ public:
+ GeolocationDispatcherHost(
+ 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.
+ bool OnMessageReceived(const IPC::Message& msg, bool* msg_was_ok);
+
+ // Tells the render view that a new geolocation position is available.
+ void NotifyPositionUpdated(const Geoposition& geoposition);
+
+ private:
+ friend class base::RefCountedThreadSafe<GeolocationDispatcherHost>;
+ ~GeolocationDispatcherHost();
+
+ void OnRegisterDispatcher(int route_id);
+ void OnUnregisterDispatcher(int route_id);
+ void OnRequestPermission(int route_id, int bridge_id, const GURL& origin);
+ void OnStartUpdating(int route_id, int bridge_id, bool high_accuracy);
+ void OnStopUpdating(int route_id, int bridge_id);
+ void OnSuspend(int route_id, int bridge_id);
+ void OnResume(int route_id, int bridge_id);
+
+ // Registers the bridge created in the renderer side. They'll delegate to the
+ // UI thread if not already in there.
+ void RegisterDispatcher(int process_id, int route_id);
+ void UnregisterDispatcher(int process_id, int route_id);
+
+ int resource_message_filter_process_id_;
+ scoped_refptr<GeolocationPermissionContext> geolocation_permission_context_;
+
+ struct GeolocationServiceRenderId {
+ int process_id;
+ int route_id;
+ GeolocationServiceRenderId(int process_id, int route_id)
+ : process_id(process_id), route_id(route_id) {
+ }
+ bool operator==(const GeolocationServiceRenderId& rhs) const {
+ return process_id == rhs.route_id &&
+ route_id == rhs.route_id;
+ }
+ bool operator<(const GeolocationServiceRenderId& rhs) const {
+ return process_id < rhs.route_id &&
+ route_id < rhs.route_id;
+ }
+ };
+ // Only used on the UI thread.
+ std::set<GeolocationServiceRenderId> geolocation_renderers_;
+
+ DISALLOW_COPY_AND_ASSIGN(GeolocationDispatcherHost);
+};
+
+#endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_DISPATCHER_HOST_H_