summaryrefslogtreecommitdiffstats
path: root/android_webview/native/aw_geolocation_permission_context.cc
blob: 959c4647c54dfeeb6fe5201466b3f1057f59fb63 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// 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.

#include "android_webview/native/aw_geolocation_permission_context.h"

#include "android_webview/native/aw_contents.h"
#include "base/bind.h"
#include "base/callback.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h"
#include "googleurl/src/gurl.h"

namespace android_webview {

AwGeolocationPermissionContext::~AwGeolocationPermissionContext() {
}

void
AwGeolocationPermissionContext::RequestGeolocationPermissionOnUIThread(
    int render_process_id,
    int render_view_id,
    int bridge_id,
    const GURL& requesting_frame,
    base::Callback<void(bool)> callback) {
  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
  const content::RenderViewHost* host =
      content::RenderViewHost::FromID(render_process_id, render_view_id);
  content::WebContents* web_contents =
      content::WebContents::FromRenderViewHost(host);
  AwContents* aw_contents = AwContents::FromWebContents(web_contents);
  aw_contents->OnGeolocationShowPrompt(
      render_process_id,
      render_view_id,
      bridge_id,
      requesting_frame);
}

void
AwGeolocationPermissionContext::RequestGeolocationPermission(
    int render_process_id,
    int render_view_id,
    int bridge_id,
    const GURL& requesting_frame,
    base::Callback<void(bool)> callback) {
  content::BrowserThread::PostTask(
      content::BrowserThread::UI, FROM_HERE,
      base::Bind(
          &AwGeolocationPermissionContext::
              RequestGeolocationPermissionOnUIThread,
          this,
          render_process_id,
          render_view_id,
          bridge_id,
          requesting_frame,
          callback));
}

// static
content::GeolocationPermissionContext*
AwGeolocationPermissionContext::Create() {
  return new AwGeolocationPermissionContext();
}

void
AwGeolocationPermissionContext::CancelGeolocationPermissionRequestOnUIThread(
    int render_process_id,
    int render_view_id,
    int bridge_id,
    const GURL& requesting_frame) {
  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
  // TODO(kristianm): Implement this
}

void
AwGeolocationPermissionContext::CancelGeolocationPermissionRequest(
    int render_process_id,
    int render_view_id,
    int bridge_id,
    const GURL& requesting_frame) {
  content::BrowserThread::PostTask(
      content::BrowserThread::UI, FROM_HERE,
      base::Bind(
          &AwGeolocationPermissionContext::
              CancelGeolocationPermissionRequestOnUIThread,
          this,
          render_process_id,
          render_view_id,
          bridge_id,
          requesting_frame));
}

void InvokeCallback(
    int render_process_id,
    int render_view_id,
    int bridge_id,
    const GURL& requesting_frame,
    bool value) {
  // TODO(kristianm): Implement this
}

}  // namespace android_webview