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

Side by Side Diff: content/browser/geolocation/geolocation_provider.cc

Issue 10107017: Remove requesting_frame parameters from Geolocation stack (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 8 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/geolocation/geolocation_provider.h" 5 #include "content/browser/geolocation/geolocation_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/threading/thread_restrictions.h" 10 #include "base/threading/thread_restrictions.h"
11 #include "content/browser/geolocation/location_arbitrator.h" 11 #include "content/browser/geolocation/location_arbitrator.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 DCHECK(OnClientThread()); 46 DCHECK(OnClientThread());
47 base::Closure task; 47 base::Closure task;
48 if (observers_.empty()) { 48 if (observers_.empty()) {
49 DCHECK(IsRunning()); 49 DCHECK(IsRunning());
50 task = base::Bind(&GeolocationProvider::StopProviders, 50 task = base::Bind(&GeolocationProvider::StopProviders,
51 base::Unretained(this)); 51 base::Unretained(this));
52 } else { 52 } else {
53 if (!IsRunning()) { 53 if (!IsRunning()) {
54 Start(); 54 Start();
55 if (HasPermissionBeenGranted()) 55 if (HasPermissionBeenGranted())
56 InformProvidersPermissionGranted(most_recent_authorized_frame_); 56 InformProvidersPermissionGranted();
57 } 57 }
58 58
59 // The high accuracy requirement may have changed. 59 // The high accuracy requirement may have changed.
60 task = base::Bind(&GeolocationProvider::StartProviders, 60 task = base::Bind(&GeolocationProvider::StartProviders,
61 base::Unretained(this), 61 base::Unretained(this),
62 GeolocationObserverOptions::Collapse(observers_)); 62 GeolocationObserverOptions::Collapse(observers_));
63 } 63 }
64 64
65 message_loop()->PostTask(FROM_HERE, task); 65 message_loop()->PostTask(FROM_HERE, task);
66 } 66 }
(...skipping 17 matching lines...) Expand all
84 DCHECK(arbitrator_); 84 DCHECK(arbitrator_);
85 arbitrator_->StartProviders(options); 85 arbitrator_->StartProviders(options);
86 } 86 }
87 87
88 void GeolocationProvider::StopProviders() { 88 void GeolocationProvider::StopProviders() {
89 DCHECK(OnGeolocationThread()); 89 DCHECK(OnGeolocationThread());
90 DCHECK(arbitrator_); 90 DCHECK(arbitrator_);
91 arbitrator_->StopProviders(); 91 arbitrator_->StopProviders();
92 } 92 }
93 93
94 void GeolocationProvider::OnPermissionGranted(const GURL& requesting_frame) { 94 void GeolocationProvider::OnPermissionGranted() {
95 DCHECK(OnClientThread()); 95 DCHECK(OnClientThread());
96 most_recent_authorized_frame_ = requesting_frame; 96 is_permission_granted_ = true;
John Knottenbelt 2012/04/20 09:40:37 is_permission_granted_ needs to be initialised to
bartfab (slow) 2012/04/20 09:44:29 Done.
97 if (IsRunning()) 97 if (IsRunning())
98 InformProvidersPermissionGranted(requesting_frame); 98 InformProvidersPermissionGranted();
99 } 99 }
100 100
101 void GeolocationProvider::InformProvidersPermissionGranted( 101 void GeolocationProvider::InformProvidersPermissionGranted() {
102 const GURL& requesting_frame) {
103 DCHECK(IsRunning()); 102 DCHECK(IsRunning());
104 DCHECK(requesting_frame.is_valid());
105 if (!OnGeolocationThread()) { 103 if (!OnGeolocationThread()) {
106 message_loop()->PostTask( 104 message_loop()->PostTask(
107 FROM_HERE, 105 FROM_HERE,
108 base::Bind(&GeolocationProvider::InformProvidersPermissionGranted, 106 base::Bind(&GeolocationProvider::InformProvidersPermissionGranted,
109 base::Unretained(this), requesting_frame)); 107 base::Unretained(this)));
110 return; 108 return;
111 } 109 }
112 DCHECK(OnGeolocationThread()); 110 DCHECK(OnGeolocationThread());
113 DCHECK(arbitrator_); 111 DCHECK(arbitrator_);
114 arbitrator_->OnPermissionGranted(requesting_frame); 112 arbitrator_->OnPermissionGranted();
115 } 113 }
116 114
117 void GeolocationProvider::Init() { 115 void GeolocationProvider::Init() {
118 DCHECK(OnGeolocationThread()); 116 DCHECK(OnGeolocationThread());
119 DCHECK(!arbitrator_); 117 DCHECK(!arbitrator_);
120 arbitrator_ = GeolocationArbitrator::Create(this); 118 arbitrator_ = GeolocationArbitrator::Create(this);
121 } 119 }
122 120
123 void GeolocationProvider::CleanUp() { 121 void GeolocationProvider::CleanUp() {
124 DCHECK(OnGeolocationThread()); 122 DCHECK(OnGeolocationThread());
125 delete arbitrator_; 123 delete arbitrator_;
126 arbitrator_ = NULL; 124 arbitrator_ = NULL;
127 } 125 }
128 126
129 void GeolocationProvider::OnLocationUpdate(const Geoposition& position) { 127 void GeolocationProvider::OnLocationUpdate(const Geoposition& position) {
130 DCHECK(OnGeolocationThread()); 128 DCHECK(OnGeolocationThread());
131 client_loop_->PostTask( 129 client_loop_->PostTask(
132 FROM_HERE, 130 FROM_HERE,
133 base::Bind(&GeolocationProvider::NotifyObservers, 131 base::Bind(&GeolocationProvider::NotifyObservers,
134 base::Unretained(this), position)); 132 base::Unretained(this), position));
135 } 133 }
136 134
137 bool GeolocationProvider::HasPermissionBeenGranted() const { 135 bool GeolocationProvider::HasPermissionBeenGranted() const {
138 DCHECK(OnClientThread()); 136 DCHECK(OnClientThread());
139 return most_recent_authorized_frame_.is_valid(); 137 return is_permission_granted_;
140 } 138 }
141 139
142 bool GeolocationProvider::OnClientThread() const { 140 bool GeolocationProvider::OnClientThread() const {
143 return client_loop_->BelongsToCurrentThread(); 141 return client_loop_->BelongsToCurrentThread();
144 } 142 }
145 143
146 bool GeolocationProvider::OnGeolocationThread() const { 144 bool GeolocationProvider::OnGeolocationThread() const {
147 return MessageLoop::current() == message_loop(); 145 return MessageLoop::current() == message_loop();
148 } 146 }
OLDNEW
« no previous file with comments | « content/browser/geolocation/geolocation_provider.h ('k') | content/browser/geolocation/geolocation_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698