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