OLD | NEW |
1 // Copyright (c) 2008-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2008-2009 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 #include "chrome/browser/history/history_publisher.h" | 5 #include "chrome/browser/history/history_publisher.h" |
6 | 6 |
7 #include <atlsafe.h> | 7 #include <atlsafe.h> |
8 #include <objbase.h> | 8 #include <objbase.h> |
9 #include <oleauto.h> | 9 #include <oleauto.h> |
10 #include <wtypes.h> | 10 #include <wtypes.h> |
11 | 11 |
12 #include "base/registry.h" | 12 #include "base/registry.h" |
| 13 #include "base/scoped_comptr_win.h" |
13 | 14 |
14 namespace history { | 15 namespace history { |
15 | 16 |
16 const wchar_t* HistoryPublisher::kRegKeyRegisteredIndexersInfo = | 17 const wchar_t* const HistoryPublisher::kRegKeyRegisteredIndexersInfo = |
17 L"Software\\Google\\Google Chrome\\IndexerPlugins"; | 18 L"Software\\Google\\Google Chrome\\IndexerPlugins"; |
18 | 19 |
19 // static | 20 // static |
20 double HistoryPublisher::TimeToUTCVariantTime(const base::Time& time) { | 21 double HistoryPublisher::TimeToUTCVariantTime(const base::Time& time) { |
21 double var_time = 0; | 22 double var_time = 0; |
22 if (!time.is_null()) { | 23 if (!time.is_null()) { |
23 base::Time::Exploded exploded; | 24 base::Time::Exploded exploded; |
24 time.UTCExplode(&exploded); | 25 time.UTCExplode(&exploded); |
25 | 26 |
26 // Create the system time struct representing our exploded time. | 27 // Create the system time struct representing our exploded time. |
(...skipping 26 matching lines...) Expand all Loading... |
53 | 54 |
54 bool HistoryPublisher::ReadRegisteredIndexersFromRegistry() { | 55 bool HistoryPublisher::ReadRegisteredIndexersFromRegistry() { |
55 RegistryKeyIterator iter(HKEY_CURRENT_USER, kRegKeyRegisteredIndexersInfo); | 56 RegistryKeyIterator iter(HKEY_CURRENT_USER, kRegKeyRegisteredIndexersInfo); |
56 while (iter.Valid()) { | 57 while (iter.Valid()) { |
57 // The subkey name is the GUID of the Indexer COM object which implements | 58 // The subkey name is the GUID of the Indexer COM object which implements |
58 // the IChromeHistoryIndexer interface. We shall store that and use it to | 59 // the IChromeHistoryIndexer interface. We shall store that and use it to |
59 // send historical data to the indexer. | 60 // send historical data to the indexer. |
60 CLSID clsid; | 61 CLSID clsid; |
61 CLSIDFromString(static_cast<LPOLESTR>( | 62 CLSIDFromString(static_cast<LPOLESTR>( |
62 const_cast<TCHAR*>(iter.Name())), &clsid); | 63 const_cast<TCHAR*>(iter.Name())), &clsid); |
63 CComPtr<IChromeHistoryIndexer> indexer; | 64 ScopedComPtr<IChromeHistoryIndexer> indexer; |
64 HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC, | 65 HRESULT hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC, |
65 __uuidof(IChromeHistoryIndexer), | 66 __uuidof(IChromeHistoryIndexer), |
66 reinterpret_cast<void**>(&indexer)); | 67 reinterpret_cast<void**>(&indexer)); |
67 if (SUCCEEDED(hr) && indexer != NULL) | 68 if (SUCCEEDED(hr) && indexer != NULL) |
68 indexers_.push_back(indexer); | 69 indexers_.push_back(indexer); |
69 ++iter; | 70 ++iter; |
70 } | 71 } |
71 return indexers_.size() > 0; | 72 return indexers_.size() > 0; |
72 } | 73 } |
73 | 74 |
(...skipping 24 matching lines...) Expand all Loading... |
98 const { | 99 const { |
99 double var_begin_time = TimeToUTCVariantTime(begin_time); | 100 double var_begin_time = TimeToUTCVariantTime(begin_time); |
100 double var_end_time = TimeToUTCVariantTime(end_time); | 101 double var_end_time = TimeToUTCVariantTime(end_time); |
101 for(size_t i = 0; i < indexers_.size(); ++i) { | 102 for(size_t i = 0; i < indexers_.size(); ++i) { |
102 indexers_[i]->DeleteUserHistoryBetween(CComVariant(var_begin_time, VT_DATE), | 103 indexers_[i]->DeleteUserHistoryBetween(CComVariant(var_begin_time, VT_DATE), |
103 CComVariant(var_end_time, VT_DATE)); | 104 CComVariant(var_end_time, VT_DATE)); |
104 } | 105 } |
105 } | 106 } |
106 | 107 |
107 } // namespace history | 108 } // namespace history |
OLD | NEW |