DevTools: cut host and port from webSocketDebuggerUrl in addition to ws:// prefix
[chromium-blink-merge.git] / content / browser / geolocation / geolocation_service_context.cc
blob7a250237d872385bda09de3ac0a2f5221e011d65
1 // Copyright 2014 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.
5 #include "content/browser/geolocation/geolocation_service_context.h"
7 namespace content {
9 GeolocationServiceContext::GeolocationServiceContext() : paused_(false) {
12 GeolocationServiceContext::~GeolocationServiceContext() {
15 void GeolocationServiceContext::CreateService(
16 const base::Closure& update_callback,
17 mojo::InterfaceRequest<GeolocationService> request) {
18 GeolocationServiceImpl* service =
19 new GeolocationServiceImpl(request.Pass(), this, update_callback);
20 services_.push_back(service);
21 if (geoposition_override_)
22 service->SetOverride(*geoposition_override_.get());
23 else
24 service->StartListeningForUpdates();
27 void GeolocationServiceContext::ServiceHadConnectionError(
28 GeolocationServiceImpl* service) {
29 auto it = std::find(services_.begin(), services_.end(), service);
30 DCHECK(it != services_.end());
31 services_.erase(it);
34 void GeolocationServiceContext::PauseUpdates() {
35 paused_ = true;
36 for (auto* service : services_) {
37 service->PauseUpdates();
41 void GeolocationServiceContext::ResumeUpdates() {
42 paused_ = false;
43 for (auto* service : services_) {
44 service->ResumeUpdates();
48 void GeolocationServiceContext::SetOverride(
49 scoped_ptr<Geoposition> geoposition) {
50 geoposition_override_.swap(geoposition);
51 for (auto* service : services_) {
52 service->SetOverride(*geoposition_override_.get());
56 void GeolocationServiceContext::ClearOverride() {
57 for (auto* service : services_) {
58 service->ClearOverride();
62 } // namespace content