OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ | 5 #ifndef CHROME_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ |
6 #define CHROME_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ | 6 #define CHROME_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ |
7 | 7 |
8 #include <atlbase.h> | 8 #include <atlbase.h> |
9 #include <atlcom.h> | 9 #include <atlcom.h> |
10 #include <locationapi.h> | 10 #include <locationapi.h> |
11 #include <sensors.h> | 11 #include <sensors.h> |
12 #include <Windows.h> | 12 #include <Windows.h> |
13 | 13 |
14 #include "app/win/scoped_com_initializer.h" | |
14 #include "base/time.h" | 15 #include "base/time.h" |
15 | 16 |
16 struct Geoposition; | 17 struct Geoposition; |
17 | 18 |
18 // PropVariantToDouble | 19 // PropVariantToDouble |
19 typedef HRESULT (WINAPI* PropVariantToDoubleFunction) | 20 typedef HRESULT (WINAPI* PropVariantToDoubleFunction) |
20 (REFPROPVARIANT propvarIn, DOUBLE *pdblRet); | 21 (REFPROPVARIANT propvarIn, DOUBLE *pdblRet); |
21 | 22 |
22 class Win7LocationApi { | 23 class Win7LocationApi { |
23 public: | 24 public: |
24 // Public for testing. See Create() below for normal usage. | 25 // Public for testing. See Create() above for normal usage. |
bulach
2011/01/11 16:46:49
should I rotate my monitor? :)
John Knottenbelt
2011/01/12 11:16:13
Done.
| |
25 Win7LocationApi(HINSTANCE prop_library, | 26 Win7LocationApi(); |
26 PropVariantToDoubleFunction PropVariantToDouble_function, | 27 void Init(HINSTANCE prop_library, |
bulach
2011/01/11 16:46:49
actually, perhaps make both the ctor and init priv
John Knottenbelt
2011/01/12 11:16:13
Done.
| |
27 ILocation* locator); | 28 PropVariantToDoubleFunction PropVariantToDouble_function, |
29 ILocation* locator); | |
28 virtual ~Win7LocationApi(); | 30 virtual ~Win7LocationApi(); |
29 | |
30 // Attempts to load propsys.dll, initialise |location_| and requests the user | 31 // Attempts to load propsys.dll, initialise |location_| and requests the user |
31 // for access to location information. Creates and returns ownership of an | 32 // for access to location information. Creates and returns ownership of an |
32 // instance of Win7LocationApi if all succeed. | 33 // instance of Win7LocationApi if all succeed. |
33 static Win7LocationApi* Create(); | 34 static Win7LocationApi* Create(); |
34 // Gives the best available position. | 35 // Gives the best available position. |
35 // Returns false if no valid position is available. | 36 // Returns false if no valid position is available. |
36 virtual void GetPosition(Geoposition* position); | 37 virtual void GetPosition(Geoposition* position); |
37 // Changes the "accuracy" needed. Affects power levels of devices. | 38 // Changes the "accuracy" needed. Affects power levels of devices. |
38 virtual bool SetHighAccuracy(bool acc); | 39 virtual bool SetHighAccuracy(bool acc); |
39 | 40 |
40 private: | 41 private: |
41 // Provides the best position fix if one is available. | 42 // Provides the best position fix if one is available. |
42 // Does this by requesting a location report and querying it to obtain | 43 // Does this by requesting a location report and querying it to obtain |
43 // location information. | 44 // location information. |
44 virtual bool GetPositionIfFixed(Geoposition* position); | 45 virtual bool GetPositionIfFixed(Geoposition* position); |
45 | 46 |
46 // ILocation object that lets us communicate with the Location and | 47 // ILocation object that lets us communicate with the Location and |
47 // Sensors platform. | 48 // Sensors platform. |
48 CComPtr<ILocation> locator_; | 49 CComPtr<ILocation> locator_; |
49 // Holds the opened propsys.dll library that is passed on construction. | 50 // Holds the opened propsys.dll library that is passed on construction. |
50 // This class is responsible for closing it. | 51 // This class is responsible for closing it. |
51 HINSTANCE prop_lib_; | 52 HINSTANCE prop_lib_; |
52 PropVariantToDoubleFunction PropVariantToDouble_function_; | 53 PropVariantToDoubleFunction PropVariantToDouble_function_; |
54 // Ensure that COM has been initialised when we use the class. | |
bulach
2011/01/11 16:46:49
s/has been initialized/has been initialized for th
John Knottenbelt
2011/01/12 11:16:13
Done.
| |
55 app::win::ScopedCOMInitializer com_initializer_; | |
bulach
2011/01/11 16:46:49
make this as the first member of this class.
John Knottenbelt
2011/01/12 11:16:13
Done.
John Knottenbelt
2011/01/12 11:16:13
Done.
| |
53 | 56 |
54 DISALLOW_COPY_AND_ASSIGN(Win7LocationApi); | 57 DISALLOW_COPY_AND_ASSIGN(Win7LocationApi); |
55 }; | 58 }; |
56 | 59 |
57 #endif // CHROME_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ | 60 #endif // CHROME_BROWSER_GEOLOCATION_WIN7_LOCATION_API_WIN_H_ |
OLD | NEW |