OLD | NEW |
1 // Copyright (c) 2012 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 #include "chrome/utility/importer/ie_importer_win.h" | 5 #include "chrome/utility/importer/ie_importer_win.h" |
6 | 6 |
7 #include <objbase.h> | 7 #include <objbase.h> |
8 #include <ole2.h> | 8 #include <ole2.h> |
9 #include <intshcut.h> | 9 #include <intshcut.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 IEOrderBookmarkComparator compare = {&sort_index}; | 285 IEOrderBookmarkComparator compare = {&sort_index}; |
286 std::sort(bookmarks->begin(), bookmarks->end(), compare); | 286 std::sort(bookmarks->begin(), bookmarks->end(), compare); |
287 } | 287 } |
288 | 288 |
289 // Reads an internet shortcut (*.url) |file| and returns a COM object | 289 // Reads an internet shortcut (*.url) |file| and returns a COM object |
290 // representing it. | 290 // representing it. |
291 bool LoadInternetShortcut( | 291 bool LoadInternetShortcut( |
292 const base::string16& file, | 292 const base::string16& file, |
293 base::win::ScopedComPtr<IUniformResourceLocator>* shortcut) { | 293 base::win::ScopedComPtr<IUniformResourceLocator>* shortcut) { |
294 base::win::ScopedComPtr<IUniformResourceLocator> url_locator; | 294 base::win::ScopedComPtr<IUniformResourceLocator> url_locator; |
295 if (FAILED(url_locator.CreateInstance(CLSID_InternetShortcut, NULL, | 295 if (FAILED(::CoCreateInstance(CLSID_InternetShortcut, NULL, |
296 CLSCTX_INPROC_SERVER))) | 296 CLSCTX_INPROC_SERVER, |
| 297 IID_PPV_ARGS(&url_locator)))) |
297 return false; | 298 return false; |
298 | 299 |
299 base::win::ScopedComPtr<IPersistFile> persist_file; | 300 base::win::ScopedComPtr<IPersistFile> persist_file; |
300 if (FAILED(url_locator.CopyTo(persist_file.GetAddressOf()))) | 301 if (FAILED(url_locator.CopyTo(persist_file.GetAddressOf()))) |
301 return false; | 302 return false; |
302 | 303 |
303 // Loads the Internet Shortcut from persistent storage. | 304 // Loads the Internet Shortcut from persistent storage. |
304 if (FAILED(persist_file->Load(file.c_str(), STGM_READ))) | 305 if (FAILED(persist_file->Load(file.c_str(), STGM_READ))) |
305 return false; | 306 return false; |
306 | 307 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 503 } |
503 | 504 |
504 void IEImporter::ImportHistory() { | 505 void IEImporter::ImportHistory() { |
505 const std::string kSchemes[] = {url::kHttpScheme, | 506 const std::string kSchemes[] = {url::kHttpScheme, |
506 url::kHttpsScheme, | 507 url::kHttpsScheme, |
507 url::kFtpScheme, | 508 url::kFtpScheme, |
508 url::kFileScheme}; | 509 url::kFileScheme}; |
509 int total_schemes = arraysize(kSchemes); | 510 int total_schemes = arraysize(kSchemes); |
510 | 511 |
511 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; | 512 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; |
512 if (FAILED(url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, | 513 if (FAILED(::CoCreateInstance(CLSID_CUrlHistory, NULL, CLSCTX_INPROC_SERVER, |
513 CLSCTX_INPROC_SERVER))) { | 514 IID_PPV_ARGS(&url_history_stg2)))) { |
514 return; | 515 return; |
515 } | 516 } |
516 base::win::ScopedComPtr<IEnumSTATURL> enum_url; | 517 base::win::ScopedComPtr<IEnumSTATURL> enum_url; |
517 if (SUCCEEDED(url_history_stg2->EnumUrls(enum_url.GetAddressOf()))) { | 518 if (SUCCEEDED(url_history_stg2->EnumUrls(enum_url.GetAddressOf()))) { |
518 std::vector<ImporterURLRow> rows; | 519 std::vector<ImporterURLRow> rows; |
519 STATURL stat_url; | 520 STATURL stat_url; |
520 | 521 |
521 // IEnumSTATURL::Next() doesn't fill STATURL::dwFlags by default. Need to | 522 // IEnumSTATURL::Next() doesn't fill STATURL::dwFlags by default. Need to |
522 // call IEnumSTATURL::SetFilter() with STATURL_QUERYFLAG_TOPLEVEL flag to | 523 // call IEnumSTATURL::SetFilter() with STATURL_QUERYFLAG_TOPLEVEL flag to |
523 // specify how STATURL structure will be filled. | 524 // specify how STATURL structure will be filled. |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
912 static int version = -1; | 913 static int version = -1; |
913 if (version < 0) { | 914 if (version < 0) { |
914 wchar_t buffer[128]; | 915 wchar_t buffer[128]; |
915 DWORD buffer_length = sizeof(buffer); | 916 DWORD buffer_length = sizeof(buffer); |
916 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 917 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
917 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 918 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
918 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 919 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
919 } | 920 } |
920 return version; | 921 return version; |
921 } | 922 } |
OLD | NEW |