OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 #ifndef BLIMP_ENGINE_FEATURE_GEOLOCATION_ENGINE_GEOLOCATION_FEATURE_H_ |
| 6 #define BLIMP_ENGINE_FEATURE_GEOLOCATION_ENGINE_GEOLOCATION_FEATURE_H_ |
| 7 |
| 8 #include "base/memory/weak_ptr.h" |
| 9 #include "blimp/engine/feature/geolocation/blimp_location_provider.h" |
| 10 #include "blimp/net/blimp_message_processor.h" |
| 11 #include "content/public/browser/geolocation_delegate.h" |
| 12 #include "content/public/browser/location_provider.h" |
| 13 #include "content/public/common/geoposition.h" |
| 14 |
| 15 namespace blimp { |
| 16 namespace engine { |
| 17 |
| 18 // Handles all incoming and outgoing protobuf messages types tied to |
| 19 // geolocation. |
| 20 class EngineGeolocationFeature : public BlimpMessageProcessor, |
| 21 public BlimpLocationProvider::Delegate { |
| 22 public: |
| 23 EngineGeolocationFeature(); |
| 24 ~EngineGeolocationFeature() override; |
| 25 |
| 26 void set_outgoing_message_processor( |
| 27 std::unique_ptr<BlimpMessageProcessor> message_processor); |
| 28 |
| 29 std::unique_ptr<content::GeolocationDelegate> CreateGeolocationDelegate(); |
| 30 |
| 31 // BlimpMessageProcessor implementation. |
| 32 void ProcessMessage(std::unique_ptr<BlimpMessage> message, |
| 33 const net::CompletionCallback& callback) override; |
| 34 |
| 35 private: |
| 36 void NotifyCallback(const content::Geoposition& position); |
| 37 |
| 38 // BlimpLocationProvider::Delegate implementation. |
| 39 void RequestAccuracy( |
| 40 GeolocationSetInterestLevelMessage::Level level) override; |
| 41 void RequestRefresh() override; |
| 42 void SetUpdateCallback( |
| 43 const base::Callback<void(const content::Geoposition&)>& callback) |
| 44 override; |
| 45 |
| 46 std::unique_ptr<BlimpMessageProcessor> outgoing_message_processor_; |
| 47 base::Callback<void(const content::Geoposition&)> |
| 48 geoposition_received_callback_; |
| 49 base::WeakPtrFactory<EngineGeolocationFeature> weak_factory_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(EngineGeolocationFeature); |
| 52 }; |
| 53 |
| 54 } // namespace engine |
| 55 } // namespace blimp |
| 56 |
| 57 #endif // BLIMP_ENGINE_FEATURE_GEOLOCATION_ENGINE_GEOLOCATION_FEATURE_H_ |
OLD | NEW |