| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ | |
| 6 #define CONTENT_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ | |
| 7 | |
| 8 #include <windows.h> | |
| 9 #include <atlbase.h> | |
| 10 #include <atlcom.h> | |
| 11 #include <locationapi.h> | |
| 12 #include <sensors.h> | |
| 13 | |
| 14 #include "base/basictypes.h" | |
| 15 #include "content/common/content_export.h" | |
| 16 | |
| 17 namespace content { | |
| 18 struct Geoposition; | |
| 19 | |
| 20 // PropVariantToDouble | |
| 21 typedef HRESULT (WINAPI* PropVariantToDoubleFunction) | |
| 22 (REFPROPVARIANT propvarIn, DOUBLE *pdblRet); | |
| 23 | |
| 24 class CONTENT_EXPORT Win7LocationApi { | |
| 25 public: | |
| 26 virtual ~Win7LocationApi(); | |
| 27 // Attempts to load propsys.dll, initialise |location_| and requests the user | |
| 28 // for access to location information. Creates and returns ownership of an | |
| 29 // instance of Win7LocationApi if all succeed. | |
| 30 static Win7LocationApi* Create(); | |
| 31 static Win7LocationApi* CreateForTesting( | |
| 32 PropVariantToDoubleFunction PropVariantToDouble_function, | |
| 33 ILocation* locator); | |
| 34 // Gives the best available position. | |
| 35 // Returns false if no valid position is available. | |
| 36 virtual void GetPosition(Geoposition* position); | |
| 37 // Changes the "accuracy" needed. Affects power levels of devices. | |
| 38 virtual bool SetHighAccuracy(bool acc); | |
| 39 | |
| 40 protected: | |
| 41 Win7LocationApi(); | |
| 42 | |
| 43 private: | |
| 44 void Init(HINSTANCE prop_library, | |
| 45 PropVariantToDoubleFunction PropVariantToDouble_function, | |
| 46 ILocation* locator); | |
| 47 | |
| 48 // Provides the best position fix if one is available. | |
| 49 // Does this by requesting a location report and querying it to obtain | |
| 50 // location information. | |
| 51 virtual bool GetPositionIfFixed(Geoposition* position); | |
| 52 | |
| 53 // ILocation object that lets us communicate with the Location and | |
| 54 // Sensors platform. | |
| 55 CComPtr<ILocation> locator_; | |
| 56 // Holds the opened propsys.dll library that is passed on construction. | |
| 57 // This class is responsible for closing it. | |
| 58 HINSTANCE prop_lib_; | |
| 59 PropVariantToDoubleFunction PropVariantToDouble_function_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(Win7LocationApi); | |
| 62 }; | |
| 63 | |
| 64 } // namespace content | |
| 65 | |
| 66 #endif // CONTENT_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ | |
| OLD | NEW |