Chromium Code Reviews| 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 <ole2.h> | 7 #include <ole2.h> |
| 8 #include <intshcut.h> | 8 #include <intshcut.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 #include <urlhist.h> | 10 #include <urlhist.h> |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 470 } | 470 } |
| 471 | 471 |
| 472 void IEImporter::ImportHistory() { | 472 void IEImporter::ImportHistory() { |
| 473 const std::string kSchemes[] = {url::kHttpScheme, | 473 const std::string kSchemes[] = {url::kHttpScheme, |
| 474 url::kHttpsScheme, | 474 url::kHttpsScheme, |
| 475 url::kFtpScheme, | 475 url::kFtpScheme, |
| 476 url::kFileScheme}; | 476 url::kFileScheme}; |
| 477 int total_schemes = arraysize(kSchemes); | 477 int total_schemes = arraysize(kSchemes); |
| 478 | 478 |
| 479 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; | 479 base::win::ScopedComPtr<IUrlHistoryStg2> url_history_stg2; |
| 480 HRESULT result; | 480 if (FAILED(url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, |
| 481 result = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, | 481 CLSCTX_INPROC_SERVER))) |
| 482 CLSCTX_INPROC_SERVER); | |
| 483 if (FAILED(result)) | |
| 484 return; | 482 return; |
|
gab
2014/12/12 14:58:31
nit: Wrap in {} since conditional is multi-line.
Alexey Seren
2014/12/15 14:00:23
Acknowledged.
| |
| 485 base::win::ScopedComPtr<IEnumSTATURL> enum_url; | 483 base::win::ScopedComPtr<IEnumSTATURL> enum_url; |
| 486 if (SUCCEEDED(result = url_history_stg2->EnumUrls(enum_url.Receive()))) { | 484 if (SUCCEEDED(url_history_stg2->EnumUrls(enum_url.Receive()))) { |
| 487 std::vector<ImporterURLRow> rows; | 485 std::vector<ImporterURLRow> rows; |
| 488 STATURL stat_url; | 486 STATURL stat_url; |
| 489 ULONG fetched; | 487 |
| 488 // Fill STATURL::dwFlags attribute for top-level items. | |
| 489 enum_url->SetFilter(NULL, STATURL_QUERYFLAG_TOPLEVEL); | |
| 490 while (!cancelled() && | 490 while (!cancelled() && |
| 491 (result = enum_url->Next(1, &stat_url, &fetched)) == S_OK) { | 491 enum_url->Next(1, &stat_url, NULL) == S_OK) { |
| 492 base::string16 url_string; | 492 base::string16 url_string; |
| 493 if (stat_url.pwcsUrl) { | 493 if (stat_url.pwcsUrl) { |
| 494 url_string = stat_url.pwcsUrl; | 494 url_string = stat_url.pwcsUrl; |
| 495 CoTaskMemFree(stat_url.pwcsUrl); | 495 CoTaskMemFree(stat_url.pwcsUrl); |
| 496 } | 496 } |
| 497 base::string16 title_string; | 497 base::string16 title_string; |
| 498 if (stat_url.pwcsTitle) { | 498 if (stat_url.pwcsTitle) { |
| 499 title_string = stat_url.pwcsTitle; | 499 title_string = stat_url.pwcsTitle; |
| 500 CoTaskMemFree(stat_url.pwcsTitle); | 500 CoTaskMemFree(stat_url.pwcsTitle); |
| 501 } | 501 } |
| 502 | 502 |
| 503 GURL url(url_string); | 503 GURL url(url_string); |
| 504 // Skips the URLs that are invalid or have other schemes. | 504 // Skips the URLs that are invalid or have other schemes. |
| 505 if (!url.is_valid() || | 505 if (!url.is_valid() || |
| 506 (std::find(kSchemes, kSchemes + total_schemes, url.scheme()) == | 506 (std::find(kSchemes, kSchemes + total_schemes, url.scheme()) == |
| 507 kSchemes + total_schemes)) | 507 kSchemes + total_schemes)) |
| 508 continue; | 508 continue; |
| 509 | 509 |
| 510 ImporterURLRow row(url); | 510 ImporterURLRow row(url); |
| 511 row.title = title_string; | 511 row.title = title_string; |
| 512 row.last_visit = base::Time::FromFileTime(stat_url.ftLastVisited); | 512 row.last_visit = base::Time::FromFileTime(stat_url.ftLastVisited); |
| 513 if (stat_url.dwFlags == STATURL_QUERYFLAG_TOPLEVEL) { | 513 if (stat_url.dwFlags & STATURLFLAG_ISTOPLEVEL) { |
| 514 row.visit_count = 1; | 514 row.visit_count = 1; |
| 515 row.hidden = false; | 515 row.hidden = false; |
| 516 } else { | 516 } else { |
| 517 row.hidden = true; | 517 row.hidden = true; |
| 518 } | 518 } |
| 519 | 519 |
| 520 rows.push_back(row); | 520 rows.push_back(row); |
| 521 } | 521 } |
| 522 | 522 |
| 523 if (!rows.empty() && !cancelled()) { | 523 if (!rows.empty() && !cancelled()) { |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 static int version = -1; | 874 static int version = -1; |
| 875 if (version < 0) { | 875 if (version < 0) { |
| 876 wchar_t buffer[128]; | 876 wchar_t buffer[128]; |
| 877 DWORD buffer_length = sizeof(buffer); | 877 DWORD buffer_length = sizeof(buffer); |
| 878 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 878 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
| 879 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 879 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
| 880 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 880 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
| 881 } | 881 } |
| 882 return version; | 882 return version; |
| 883 } | 883 } |
| OLD | NEW |