summaryrefslogtreecommitdiff
path: root/chromium/content/renderer/geolocation_dispatcher.h
blob: 71766be04a0d912fc2196bfc483dae16c97cccf1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2012 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 CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_
#define CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_

#include "base/memory/scoped_ptr.h"
#include "content/public/renderer/render_frame_observer.h"
#include "third_party/WebKit/public/platform/modules/geolocation/geolocation.mojom.h"
#include "third_party/WebKit/public/platform/modules/permissions/permission.mojom.h"
#include "third_party/WebKit/public/web/WebGeolocationClient.h"
#include "third_party/WebKit/public/web/WebGeolocationController.h"

namespace blink {
class WebGeolocationController;
class WebGeolocationPermissionRequest;
class WebGeolocationPermissionRequestManager;
class WebGeolocationPosition;
}

namespace content {
struct Geoposition;

// GeolocationDispatcher is a delegate for Geolocation messages used by
// WebKit.
// It's the complement of GeolocationDispatcherHost.
class GeolocationDispatcher
    : public RenderFrameObserver,
      public blink::WebGeolocationClient {
 public:
  explicit GeolocationDispatcher(RenderFrame* render_frame);
  ~GeolocationDispatcher() override;

 private:
  // WebGeolocationClient
  void startUpdating() override;
  void stopUpdating() override;
  void setEnableHighAccuracy(bool enable_high_accuracy) override;
  void setController(blink::WebGeolocationController* controller) override;
  bool lastPosition(blink::WebGeolocationPosition& position) override;
  void requestPermission(
      const blink::WebGeolocationPermissionRequest& permissionRequest) override;
  void cancelPermissionRequest(
      const blink::WebGeolocationPermissionRequest& permissionRequest) override;

  void QueryNextPosition();
  void OnPositionUpdate(blink::mojom::GeopositionPtr geoposition);

  // Permission for using geolocation has been set.
  void OnPermissionSet(int permission_request_id,
                       blink::mojom::PermissionStatus status);

  scoped_ptr<blink::WebGeolocationController> controller_;

  scoped_ptr<blink::WebGeolocationPermissionRequestManager>
      pending_permissions_;
  blink::mojom::GeolocationServicePtr geolocation_service_;
  bool enable_high_accuracy_;
  blink::mojom::PermissionServicePtr permission_service_;
};

}  // namespace content

#endif  // CONTENT_RENDERER_GEOLOCATION_DISPATCHER_H_