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" | |
13 #include "base/scoped_bstr_win.h" | 12 #include "base/scoped_bstr_win.h" |
14 #include "base/scoped_comptr_win.h" | 13 #include "base/scoped_comptr_win.h" |
15 #include "base/scoped_variant_win.h" | 14 #include "base/scoped_variant_win.h" |
16 #include "base/string_util.h" | 15 #include "base/string_util.h" |
17 #include "base/time.h" | 16 #include "base/time.h" |
18 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
| 18 #include "base/win/registry.h" |
19 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 // Instantiates a IChromeHistoryIndexer COM object. Takes a COM class id | 23 // Instantiates a IChromeHistoryIndexer COM object. Takes a COM class id |
24 // in |name| and returns the object in |indexer|. Returns false if the | 24 // in |name| and returns the object in |indexer|. Returns false if the |
25 // operation fails. | 25 // operation fails. |
26 bool CoCreateIndexerFromName(const wchar_t* name, | 26 bool CoCreateIndexerFromName(const wchar_t* name, |
27 IChromeHistoryIndexer** indexer) { | 27 IChromeHistoryIndexer** indexer) { |
28 CLSID clsid; | 28 CLSID clsid; |
29 HRESULT hr = CLSIDFromString(const_cast<wchar_t*>(name), &clsid); | 29 HRESULT hr = CLSIDFromString(const_cast<wchar_t*>(name), &clsid); |
30 if (FAILED(hr)) | 30 if (FAILED(hr)) |
31 return false; | 31 return false; |
32 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC, | 32 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC, |
33 __uuidof(IChromeHistoryIndexer), | 33 __uuidof(IChromeHistoryIndexer), |
34 reinterpret_cast<void**>(indexer)); | 34 reinterpret_cast<void**>(indexer)); |
35 if (FAILED(hr)) | 35 if (FAILED(hr)) |
36 return false; | 36 return false; |
37 return true; | 37 return true; |
38 } | 38 } |
39 | 39 |
40 // Instantiates the registered indexers from the registry |root| + |path| key | 40 // Instantiates the registered indexers from the registry |root| + |path| key |
41 // and adds them to the |indexers| list. | 41 // and adds them to the |indexers| list. |
42 void AddRegisteredIndexers(HKEY root, const wchar_t* path, | 42 void AddRegisteredIndexers(HKEY root, const wchar_t* path, |
43 std::vector< ScopedComPtr<IChromeHistoryIndexer> >* indexers) { | 43 std::vector< ScopedComPtr<IChromeHistoryIndexer> >* indexers) { |
44 IChromeHistoryIndexer* indexer; | 44 IChromeHistoryIndexer* indexer; |
45 RegistryKeyIterator r_iter(root, path); | 45 base::win::RegistryKeyIterator r_iter(root, path); |
46 while (r_iter.Valid()) { | 46 while (r_iter.Valid()) { |
47 if (CoCreateIndexerFromName(r_iter.Name(), &indexer)) { | 47 if (CoCreateIndexerFromName(r_iter.Name(), &indexer)) { |
48 indexers->push_back(ScopedComPtr<IChromeHistoryIndexer>(indexer)); | 48 indexers->push_back(ScopedComPtr<IChromeHistoryIndexer>(indexer)); |
49 indexer->Release(); | 49 indexer->Release(); |
50 } | 50 } |
51 ++r_iter; | 51 ++r_iter; |
52 } | 52 } |
53 } | 53 } |
54 | 54 |
55 } // namespace | 55 } // namespace |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 const base::Time& end_time) | 134 const base::Time& end_time) |
135 const { | 135 const { |
136 ScopedVariant var_begin_time(TimeToUTCVariantTime(begin_time), VT_DATE); | 136 ScopedVariant var_begin_time(TimeToUTCVariantTime(begin_time), VT_DATE); |
137 ScopedVariant var_end_time(TimeToUTCVariantTime(end_time), VT_DATE); | 137 ScopedVariant var_end_time(TimeToUTCVariantTime(end_time), VT_DATE); |
138 for (size_t i = 0; i < indexers_.size(); ++i) { | 138 for (size_t i = 0; i < indexers_.size(); ++i) { |
139 indexers_[i]->DeleteUserHistoryBetween(var_begin_time, var_end_time); | 139 indexers_[i]->DeleteUserHistoryBetween(var_begin_time, var_end_time); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 } // namespace history | 143 } // namespace history |
OLD | NEW |