Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: webkit/tools/test_shell/test_geolocation_service.cc

Issue 5938002: Remove legacy non-client-based geolocation code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove non-client-based geolocation code. Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "webkit/tools/test_shell/test_geolocation_service.h"
6
7 #include "third_party/WebKit/WebKit/chromium/public/WebGeolocationServiceBridge. h"
8
9 TestGeolocationService::TestGeolocationService()
10 : allowed_(false),
11 permission_set_(false) {
12 }
13
14 TestGeolocationService::~TestGeolocationService() {
15 for (IDMap<WebKit::WebGeolocationServiceBridge>::iterator it(&bridges_map_);
16 !it.IsAtEnd(); it.Advance()) {
17 it.GetCurrentValue()->onWebGeolocationServiceDestroyed();
18 }
19 }
20
21 void TestGeolocationService::SetGeolocationPermission(bool allowed) {
22 allowed_ = allowed;
23 permission_set_ = true;
24 TryToSendPermissions();
25 }
26
27 void TestGeolocationService::requestPermissionForFrame(
28 int bridgeId, const WebKit::WebURL& url) {
29 DCHECK(bridges_map_.Lookup(bridgeId)) << "Unknown bridge " << bridgeId;
30 pending_permissions_.push_back(bridgeId);
31 TryToSendPermissions();
32 }
33
34 int TestGeolocationService::attachBridge(
35 WebKit::WebGeolocationServiceBridge* bridge) {
36 return bridges_map_.Add(bridge);
37 }
38
39 void TestGeolocationService::detachBridge(int bridgeId) {
40 bridges_map_.Remove(bridgeId);
41 std::vector<int>::iterator i = pending_permissions_.begin();
42 while (i != pending_permissions_.end()) {
43 if (*i == bridgeId)
44 pending_permissions_.erase(i);
45 else
46 ++i;
47 }
48 }
49
50 void TestGeolocationService::TryToSendPermissions() {
51 if (permission_set_ && !permission_timer_.IsRunning())
52 permission_timer_.Start(base::TimeDelta::FromMilliseconds(0),
53 this, &TestGeolocationService::SendPermission);
54 }
55
56 void TestGeolocationService::SendPermission() {
57 DCHECK(permission_set_);
58 std::vector<int> pending_permissions;
59 pending_permissions.swap(pending_permissions_);
60 for (std::vector<int>::const_iterator i = pending_permissions.begin();
61 i != pending_permissions.end(); ++i) {
62 WebKit::WebGeolocationServiceBridge* bridge =
63 bridges_map_.Lookup(*i);
64 DCHECK(bridge);
65 bridge->setIsAllowed(allowed_);
66 }
67 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698