| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/time.h" | 13 #include "base/time.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/win/registry.h" | 15 #include "base/win/registry.h" |
| 16 #include "base/win/scoped_bstr.h" | 16 #include "base/win/scoped_bstr.h" |
| 17 #include "base/win/scoped_comptr.h" | 17 #include "base/win/scoped_comptr.h" |
| 18 #include "base/win/scoped_variant.h" | 18 #include "base/win/scoped_variant.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 | |
| 24 // in |name| and returns the object in |indexer|. Returns false if the | |
| 25 // operation fails. | |
| 26 bool CoCreateIndexerFromName(const wchar_t* name, | |
| 27 IChromeHistoryIndexer** indexer) { | |
| 28 CLSID clsid; | |
| 29 HRESULT hr = CLSIDFromString(const_cast<wchar_t*>(name), &clsid); | |
| 30 if (FAILED(hr)) | |
| 31 return false; | |
| 32 hr = CoCreateInstance(clsid, NULL, CLSCTX_INPROC, | |
| 33 __uuidof(IChromeHistoryIndexer), | |
| 34 reinterpret_cast<void**>(indexer)); | |
| 35 if (FAILED(hr)) | |
| 36 return false; | |
| 37 return true; | |
| 38 } | |
| 39 | |
| 40 // Instantiates the registered indexers from the registry |root| + |path| key | 23 // Instantiates the registered indexers from the registry |root| + |path| key |
| 41 // and adds them to the |indexers| list. | 24 // and adds them to the |indexers| list. |
| 42 void AddRegisteredIndexers(HKEY root, const wchar_t* path, | 25 void AddRegisteredIndexers( |
| 26 HKEY root, |
| 27 const wchar_t* path, |
| 43 std::vector< base::win::ScopedComPtr<IChromeHistoryIndexer> >* indexers) { | 28 std::vector< base::win::ScopedComPtr<IChromeHistoryIndexer> >* indexers) { |
| 44 IChromeHistoryIndexer* indexer; | 29 for (base::win::RegistryKeyIterator r_iter(root, path); r_iter.Valid(); |
| 45 base::win::RegistryKeyIterator r_iter(root, path); | 30 ++r_iter) { |
| 46 while (r_iter.Valid()) { | 31 CLSID clsid; |
| 47 if (CoCreateIndexerFromName(r_iter.Name(), &indexer)) { | 32 if (FAILED(CLSIDFromString(const_cast<wchar_t*>(r_iter.Name()), &clsid))) |
| 48 indexers->push_back( | 33 continue; |
| 49 base::win::ScopedComPtr<IChromeHistoryIndexer>(indexer)); | 34 base::win::ScopedComPtr<IChromeHistoryIndexer> indexer; |
| 50 indexer->Release(); | 35 if (SUCCEEDED(indexer.CreateInstance(clsid, NULL, CLSCTX_INPROC))) { |
| 36 indexers->push_back(indexer); |
| 37 indexer.Release(); |
| 51 } | 38 } |
| 52 ++r_iter; | |
| 53 } | 39 } |
| 54 } | 40 } |
| 55 | 41 |
| 56 } // namespace | 42 } // namespace |
| 57 | 43 |
| 58 namespace history { | 44 namespace history { |
| 59 | 45 |
| 60 const wchar_t* const HistoryPublisher::kRegKeyRegisteredIndexersInfo = | 46 const wchar_t* const HistoryPublisher::kRegKeyRegisteredIndexersInfo = |
| 61 L"Software\\Google\\Google Chrome\\IndexerPlugins"; | 47 L"Software\\Google\\Google Chrome\\IndexerPlugins"; |
| 62 | 48 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 base::win::ScopedVariant var_begin_time(TimeToUTCVariantTime(begin_time), | 123 base::win::ScopedVariant var_begin_time(TimeToUTCVariantTime(begin_time), |
| 138 VT_DATE); | 124 VT_DATE); |
| 139 base::win::ScopedVariant var_end_time(TimeToUTCVariantTime(end_time), | 125 base::win::ScopedVariant var_end_time(TimeToUTCVariantTime(end_time), |
| 140 VT_DATE); | 126 VT_DATE); |
| 141 for (size_t i = 0; i < indexers_.size(); ++i) { | 127 for (size_t i = 0; i < indexers_.size(); ++i) { |
| 142 indexers_[i]->DeleteUserHistoryBetween(var_begin_time, var_end_time); | 128 indexers_[i]->DeleteUserHistoryBetween(var_begin_time, var_end_time); |
| 143 } | 129 } |
| 144 } | 130 } |
| 145 | 131 |
| 146 } // namespace history | 132 } // namespace history |
| OLD | NEW |