Commit 26171c8a authored by Vaclav Brozek's avatar Vaclav Brozek Committed by Commit Bot

Reformat chrome/utility/importer/ie_importer_win.cc

This CL runs clang-format on
chrome/utility/importer/ie_importer_win.cc, to separate the
behaviour-affecting changes of https://crrev.com/c/1174711 from style
changes enforced by presubmit checks.

This CL does not introduce any functional changes.

Bug: 456119
Change-Id: I27a52f047c95a16648c550c045a2699fa1b40c61
Reviewed-on: https://chromium-review.googlesource.com/1193223
Commit-Queue: Ilya Sherman <isherman@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#586788}
parent 4c09b15b
......@@ -6,7 +6,7 @@
#include <objbase.h>
#include <ole2.h>
#include <intshcut.h>
#include <intshcut.h> // Needs to come after ole2.h
#include <shlobj.h>
#include <stddef.h>
#include <urlhist.h>
......@@ -49,9 +49,8 @@ namespace {
// Registry key paths from which we import IE settings.
const base::char16 kSearchScopePath[] =
L"Software\\Microsoft\\Internet Explorer\\SearchScopes";
const base::char16 kIEVersionKey[] =
L"Software\\Microsoft\\Internet Explorer";
L"Software\\Microsoft\\Internet Explorer\\SearchScopes";
const base::char16 kIEVersionKey[] = L"Software\\Microsoft\\Internet Explorer";
// NTFS stream name of favicon image data.
const base::char16 kFaviconStreamName[] = L":favicon:$DATA";
......@@ -66,11 +65,10 @@ struct AutoCompleteInfo {
// Gets the creation time of the given file or directory.
base::Time GetFileCreationTime(const base::string16& file) {
base::Time creation_time;
base::win::ScopedHandle file_handle(
CreateFile(file.c_str(), GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL));
base::win::ScopedHandle file_handle(CreateFile(
file.c_str(), GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL));
FILETIME creation_filetime;
if (!file_handle.IsValid())
return creation_time;
......@@ -120,9 +118,9 @@ struct IEOrderBookmarkComparator {
base::FilePath rhs_prefix;
for (size_t i = 0; i <= lhs.path.size() && i <= rhs.path.size(); ++i) {
const base::FilePath::StringType lhs_i =
(i < lhs.path.size() ? lhs.path[i] : lhs.title + L".url");
(i < lhs.path.size() ? lhs.path[i] : lhs.title + L".url");
const base::FilePath::StringType rhs_i =
(i < rhs.path.size() ? rhs.path[i] : rhs.title + L".url");
(i < rhs.path.size() ? rhs.path[i] : rhs.title + L".url");
lhs_prefix = lhs_prefix.Append(lhs_i);
rhs_prefix = rhs_prefix.Append(rhs_i);
if (lhs_i == rhs_i)
......@@ -206,12 +204,12 @@ bool ParseFavoritesOrderBlob(const Importer* importer,
// Read the file name from the ITEMIDLIST structure.
LPCITEMIDLIST idlist = BinaryReadItemIDList(
base_offset + kItemIDListOffset, item_size - kItemIDListOffset, blob);
base_offset + kItemIDListOffset, item_size - kItemIDListOffset, blob);
TCHAR item_filename[MAX_PATH];
if (!idlist || !SHGetPathFromIDList(idlist, item_filename))
return false;
base::FilePath item_relative_path =
path.Append(base::FilePath(item_filename).BaseName());
path.Append(base::FilePath(item_filename).BaseName());
// Record the retrieved information and go to the next item.
sort_index->insert(std::make_pair(item_relative_path, item_sort_index));
......@@ -244,8 +242,7 @@ bool ParseFavoritesOrderRegistryTree(
// Recursively parse subfolders.
for (base::win::RegistryKeyIterator child(key.Handle(), L"");
child.Valid() && !importer->cancelled();
++child) {
child.Valid() && !importer->cancelled(); ++child) {
base::win::RegKey subkey(key.Handle(), child.Name(), KEY_READ);
if (subkey.Valid()) {
base::FilePath subpath(path.Append(child.Name()));
......@@ -273,9 +270,8 @@ bool ParseFavoritesOrderInfo(const Importer* importer,
// Reads the sort order from registry. If failed, we don't touch the list
// and use the default (alphabetical) order.
void SortBookmarksInIEOrder(
const Importer* importer,
std::vector<ImportedBookmarkEntry>* bookmarks) {
void SortBookmarksInIEOrder(const Importer* importer,
std::vector<ImportedBookmarkEntry>* bookmarks) {
std::map<base::FilePath, uint32_t> sort_index;
if (!ParseFavoritesOrderInfo(importer, &sort_index))
return;
......@@ -310,8 +306,7 @@ bool LoadInternetShortcut(
GURL ReadURLFromInternetShortcut(IUniformResourceLocator* url_locator) {
base::win::ScopedCoMem<wchar_t> url;
// GetURL can return S_FALSE (FAILED(S_FALSE) is false) when url == NULL.
return (FAILED(url_locator->GetURL(&url)) || !url) ?
GURL() : GURL(url.get());
return (FAILED(url_locator->GetURL(&url)) || !url) ? GURL() : GURL(url.get());
}
// Reads the URL of the favicon of the internet shortcut.
......@@ -343,8 +338,8 @@ GURL ReadFaviconURLFromInternetShortcut(IUniformResourceLocator* url_locator) {
// IE7 and above store the data.
bool ReadFaviconDataFromInternetShortcut(const base::string16& file,
std::string* data) {
return base::ReadFileToString(
base::FilePath(file + kFaviconStreamName), data);
return base::ReadFileToString(base::FilePath(file + kFaviconStreamName),
data);
}
// Reads the favicon imaga data in the Internet cache. IE6 doesn't hold the data
......@@ -415,14 +410,16 @@ void UpdateFaviconMap(
// static
// {E161255A-37C3-11D2-BCAA-00C04fD929DB}
const GUID IEImporter::kPStoreAutocompleteGUID = {
0xe161255a, 0x37c3, 0x11d2,
{ 0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb }
};
0xe161255a,
0x37c3,
0x11d2,
{0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb}};
// {A79029D6-753E-4e27-B807-3D46AB1545DF}
const GUID IEImporter::kUnittestGUID = {
0xa79029d6, 0x753e, 0x4e27,
{ 0xb8, 0x7, 0x3d, 0x46, 0xab, 0x15, 0x45, 0xdf }
};
0xa79029d6,
0x753e,
0x4e27,
{0xb8, 0x7, 0x3d, 0x46, 0xab, 0x15, 0x45, 0xdf}};
IEImporter::IEImporter() : edge_import_mode_(false) {}
......@@ -475,8 +472,7 @@ void IEImporter::StartImport(const importer::SourceProfile& source_profile,
bridge_->NotifyEnded();
}
IEImporter::~IEImporter() {
}
IEImporter::~IEImporter() {}
void IEImporter::ImportFavorites() {
FavoritesInfo info;
......@@ -500,10 +496,8 @@ void IEImporter::ImportFavorites() {
}
void IEImporter::ImportHistory() {
const std::string kSchemes[] = {url::kHttpScheme,
url::kHttpsScheme,
url::kFtpScheme,
url::kFileScheme};
const std::string kSchemes[] = {url::kHttpScheme, url::kHttpsScheme,
url::kFtpScheme, url::kFileScheme};
int total_schemes = arraysize(kSchemes);
Microsoft::WRL::ComPtr<IUrlHistoryStg2> url_history_stg2;
......@@ -523,8 +517,7 @@ void IEImporter::ImportHistory() {
// that is used by IEnumSTATURL::Next() for filtering items by URL.
// So need to pass an empty string here to get all history items.
enum_url->SetFilter(L"", STATURL_QUERYFLAG_TOPLEVEL);
while (!cancelled() &&
enum_url->Next(1, &stat_url, NULL) == S_OK) {
while (!cancelled() && enum_url->Next(1, &stat_url, NULL) == S_OK) {
base::string16 url_string;
if (stat_url.pwcsUrl) {
url_string = stat_url.pwcsUrl;
......@@ -576,7 +569,7 @@ void IEImporter::ImportPasswordsIE6() {
// to a storage provider. But this function has no associated import
// library or header file, we must call it using the LoadLibrary()
// and GetProcAddress() functions.
typedef HRESULT (WINAPI *PStoreCreateFunc)(IPStore**, DWORD, DWORD, DWORD);
typedef HRESULT(WINAPI * PStoreCreateFunc)(IPStore**, DWORD, DWORD, DWORD);
HMODULE pstorec_dll = LoadLibrary(L"pstorec.dll");
if (!pstorec_dll)
return;
......@@ -693,8 +686,8 @@ void IEImporter::ImportPasswordsIE7() {
// Query the encrypted data.
password_info.encrypted_data.resize(value_len);
if (key.ReadValue(reg_iterator.Name(),
&password_info.encrypted_data.front(),
&value_len, NULL) == ERROR_SUCCESS) {
&password_info.encrypted_data.front(), &value_len,
NULL) == ERROR_SUCCESS) {
password_info.url_hash = reg_iterator.Name();
password_info.date_created = base::Time::Now();
......@@ -714,7 +707,8 @@ void IEImporter::ImportSearchEngines() {
typedef std::map<std::string, base::string16> SearchEnginesMap;
SearchEnginesMap search_engines_map;
for (base::win::RegistryKeyIterator key_iter(HKEY_CURRENT_USER,
kSearchScopePath); key_iter.Valid(); ++key_iter) {
kSearchScopePath);
key_iter.Valid(); ++key_iter) {
base::string16 sub_key_name = kSearchScopePath;
sub_key_name.append(L"\\").append(key_iter.Name());
base::win::RegKey sub_key(HKEY_CURRENT_USER, sub_key_name.c_str(),
......@@ -823,8 +817,8 @@ void IEImporter::ParseFavoritesFolder(
// Favorites path length. Make sure it doesn't include the trailing \.
size_t favorites_path_len =
favorites_path.StripTrailingSeparators().value().size();
base::FileEnumerator file_enumerator(
favorites_path, true, base::FileEnumerator::FILES);
base::FileEnumerator file_enumerator(favorites_path, true,
base::FileEnumerator::FILES);
while (!(file = file_enumerator.Next()).value().empty() && !cancelled())
file_list.push_back(file.value());
......@@ -904,7 +898,7 @@ int IEImporter::CurrentIEVersion() const {
DWORD buffer_length = sizeof(buffer);
base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, kIEVersionKey, KEY_READ);
LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL);
version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0);
version = ((result == ERROR_SUCCESS) ? _wtoi(buffer) : 0);
}
return version;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment