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 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 HRESULT result; |
| 481 result = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, | 481 result = url_history_stg2.CreateInstance(CLSID_CUrlHistory, NULL, |
| 482 CLSCTX_INPROC_SERVER); | 482 CLSCTX_INPROC_SERVER); |
| 483 if (FAILED(result)) | 483 if (FAILED(result)) |
| 484 return; | 484 return; |
| 485 base::win::ScopedComPtr<IEnumSTATURL> enum_url; | 485 base::win::ScopedComPtr<IEnumSTATURL> enum_url; |
| 486 if (SUCCEEDED(result = url_history_stg2->EnumUrls(enum_url.Receive()))) { | 486 if (SUCCEEDED(result = url_history_stg2->EnumUrls(enum_url.Receive()))) { |
|
gab
2014/12/11 16:29:49
Small cleanup while you're here, I'm seeing all th
Alexey Seren
2014/12/12 10:07:08
Acknowledged.
| |
| 487 std::vector<ImporterURLRow> rows; | 487 std::vector<ImporterURLRow> rows; |
| 488 STATURL stat_url; | 488 STATURL stat_url; |
| 489 ULONG fetched; | 489 ULONG fetched; |
| 490 | |
| 491 // Fill STATURL::dwFlags attribute for top-level items. | |
| 492 enum_url->SetFilter(NULL, STATURL_QUERYFLAG_TOPLEVEL); | |
|
gab
2014/12/11 16:29:49
Gosh this API is confusing..!
So you need to set
Alexey Seren
2014/12/12 10:07:08
By passing NULL here I've missed an OPTIONAL poszF
gab
2014/12/12 14:58:31
Right, but in this case poszFilter is documented a
Alexey Seren
2014/12/15 14:00:23
Basing on documentation SetFilter() can be used to
gab
2014/12/15 15:50:01
I see, hadn't realized filling those was off by de
Alexey Seren
2014/12/17 11:45:45
Acknowledged.
| |
| 490 while (!cancelled() && | 493 while (!cancelled() && |
| 491 (result = enum_url->Next(1, &stat_url, &fetched)) == S_OK) { | 494 (result = enum_url->Next(1, &stat_url, &fetched)) == S_OK) { |
|
gab
2014/12/11 16:29:49
Looks like |fetched| is an optional parameter [1]
Alexey Seren
2014/12/12 10:07:08
Acknowledged.
| |
| 492 base::string16 url_string; | 495 base::string16 url_string; |
| 493 if (stat_url.pwcsUrl) { | 496 if (stat_url.pwcsUrl) { |
| 494 url_string = stat_url.pwcsUrl; | 497 url_string = stat_url.pwcsUrl; |
| 495 CoTaskMemFree(stat_url.pwcsUrl); | 498 CoTaskMemFree(stat_url.pwcsUrl); |
| 496 } | 499 } |
| 497 base::string16 title_string; | 500 base::string16 title_string; |
| 498 if (stat_url.pwcsTitle) { | 501 if (stat_url.pwcsTitle) { |
| 499 title_string = stat_url.pwcsTitle; | 502 title_string = stat_url.pwcsTitle; |
| 500 CoTaskMemFree(stat_url.pwcsTitle); | 503 CoTaskMemFree(stat_url.pwcsTitle); |
| 501 } | 504 } |
| 502 | 505 |
| 503 GURL url(url_string); | 506 GURL url(url_string); |
| 504 // Skips the URLs that are invalid or have other schemes. | 507 // Skips the URLs that are invalid or have other schemes. |
| 505 if (!url.is_valid() || | 508 if (!url.is_valid() || |
| 506 (std::find(kSchemes, kSchemes + total_schemes, url.scheme()) == | 509 (std::find(kSchemes, kSchemes + total_schemes, url.scheme()) == |
| 507 kSchemes + total_schemes)) | 510 kSchemes + total_schemes)) |
| 508 continue; | 511 continue; |
| 509 | 512 |
| 510 ImporterURLRow row(url); | 513 ImporterURLRow row(url); |
| 511 row.title = title_string; | 514 row.title = title_string; |
| 512 row.last_visit = base::Time::FromFileTime(stat_url.ftLastVisited); | 515 row.last_visit = base::Time::FromFileTime(stat_url.ftLastVisited); |
| 513 if (stat_url.dwFlags == STATURL_QUERYFLAG_TOPLEVEL) { | 516 if (stat_url.dwFlags & STATURLFLAG_ISTOPLEVEL) { |
|
gab
2014/12/11 16:29:49
As you mentioned in the CL description, the defini
Alexey Seren
2014/12/12 10:07:08
No we cannot do equality comparing here because fl
gab
2014/12/12 14:58:31
I see, so the "either or" documentation for dwFlag
| |
| 514 row.visit_count = 1; | 517 row.visit_count = 1; |
| 515 row.hidden = false; | 518 row.hidden = false; |
| 516 } else { | 519 } else { |
| 517 row.hidden = true; | 520 row.hidden = true; |
|
gab
2014/12/11 16:29:49
In this scenario are we guaranteed that dwFlags is
Alexey Seren
2014/12/12 10:07:08
Yes, it is a good idea!
On 2014/12/11 16:29:49, g
Alexey Seren
2014/12/12 10:38:40
I'm sorry, I've fogotten to mention that to do thi
gab
2014/12/12 14:58:31
If we need to call SetFilter() to have a non-zero
Alexey Seren
2014/12/15 14:00:23
Ok, requesting the flag STATURLFLAG_ISCACHED will
gab
2014/12/15 15:50:02
SG.
| |
| 518 } | 521 } |
| 519 | 522 |
| 520 rows.push_back(row); | 523 rows.push_back(row); |
| 521 } | 524 } |
| 522 | 525 |
| 523 if (!rows.empty() && !cancelled()) { | 526 if (!rows.empty() && !cancelled()) { |
| 524 bridge_->SetHistoryItems(rows, importer::VISIT_SOURCE_IE_IMPORTED); | 527 bridge_->SetHistoryItems(rows, importer::VISIT_SOURCE_IE_IMPORTED); |
| 525 } | 528 } |
| 526 } | 529 } |
| 527 } | 530 } |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 static int version = -1; | 877 static int version = -1; |
| 875 if (version < 0) { | 878 if (version < 0) { |
| 876 wchar_t buffer[128]; | 879 wchar_t buffer[128]; |
| 877 DWORD buffer_length = sizeof(buffer); | 880 DWORD buffer_length = sizeof(buffer); |
| 878 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); | 881 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ); |
| 879 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 882 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
| 880 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 883 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
| 881 } | 884 } |
| 882 return version; | 885 return version; |
| 883 } | 886 } |
| OLD | NEW |