| 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/importer/ie_importer.h" | 5 #include "chrome/browser/importer/ie_importer.h" |
| 6 | 6 |
| 7 #include <ole2.h> | 7 #include <ole2.h> |
| 8 #include <intshcut.h> | 8 #include <intshcut.h> |
| 9 #include <pstore.h> | 9 #include <pstore.h> |
| 10 #include <shlobj.h> | 10 #include <shlobj.h> |
| 11 #include <urlhist.h> | 11 #include <urlhist.h> |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <map> | 14 #include <map> |
| 15 #include <string> | 15 #include <string> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "app/win/scoped_co_mem.h" | 18 #include "app/win/scoped_co_mem.h" |
| 19 #include "app/win/scoped_com_initializer.h" | 19 #include "app/win/scoped_com_initializer.h" |
| 20 #include "base/file_path.h" | 20 #include "base/file_path.h" |
| 21 #include "base/file_util.h" | 21 #include "base/file_util.h" |
| 22 #include "base/scoped_comptr_win.h" | 22 #include "base/scoped_comptr_win.h" |
| 23 #include "base/string_split.h" | 23 #include "base/string_split.h" |
| 24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 25 #include "base/time.h" | 25 #include "base/time.h" |
| 26 #include "base/utf_string_conversions.h" |
| 26 #include "base/values.h" | 27 #include "base/values.h" |
| 27 #include "base/utf_string_conversions.h" | |
| 28 #include "base/win/registry.h" | 28 #include "base/win/registry.h" |
| 29 #include "base/win/scoped_handle.h" | 29 #include "base/win/scoped_handle.h" |
| 30 #include "base/win/windows_version.h" | 30 #include "base/win/windows_version.h" |
| 31 #include "chrome/browser/bookmarks/bookmark_model.h" | 31 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 32 #include "chrome/browser/importer/importer_bridge.h" | 32 #include "chrome/browser/importer/importer_bridge.h" |
| 33 #include "chrome/browser/importer/importer_data_types.h" | 33 #include "chrome/browser/importer/importer_data_types.h" |
| 34 #include "chrome/browser/password_manager/ie7_password.h" | 34 #include "chrome/browser/password_manager/ie7_password.h" |
| 35 #include "chrome/browser/search_engines/template_url.h" | 35 #include "chrome/browser/search_engines/template_url.h" |
| 36 #include "chrome/browser/search_engines/template_url_model.h" | 36 #include "chrome/browser/search_engines/template_url_model.h" |
| 37 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 37 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 38 #include "chrome/common/time_format.h" | 38 #include "chrome/common/time_format.h" |
| 39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
| 40 #include "googleurl/src/gurl.h" | 40 #include "googleurl/src/gurl.h" |
| 41 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
| 42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
| 43 #include "webkit/glue/password_form.h" | 43 #include "webkit/glue/password_form.h" |
| 44 | 44 |
| 45 using base::Time; | |
| 46 using webkit_glue::PasswordForm; | |
| 47 | |
| 48 namespace { | 45 namespace { |
| 49 | 46 |
| 50 // Gets the creation time of the given file or directory. | 47 // Gets the creation time of the given file or directory. |
| 51 static Time GetFileCreationTime(const std::wstring& file) { | 48 base::Time GetFileCreationTime(const std::wstring& file) { |
| 52 Time creation_time; | 49 base::Time creation_time; |
| 53 base::win::ScopedHandle file_handle( | 50 base::win::ScopedHandle file_handle( |
| 54 CreateFile(file.c_str(), GENERIC_READ, | 51 CreateFile(file.c_str(), GENERIC_READ, |
| 55 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, | 52 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, |
| 56 NULL, OPEN_EXISTING, | 53 NULL, OPEN_EXISTING, |
| 57 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL)); | 54 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL)); |
| 58 FILETIME creation_filetime; | 55 FILETIME creation_filetime; |
| 59 if (GetFileTime(file_handle, &creation_filetime, NULL, NULL)) | 56 if (GetFileTime(file_handle, &creation_filetime, NULL, NULL)) |
| 60 creation_time = Time::FromFileTime(creation_filetime); | 57 creation_time = base::Time::FromFileTime(creation_filetime); |
| 61 return creation_time; | 58 return creation_time; |
| 62 } | 59 } |
| 63 | 60 |
| 64 } // namespace | 61 } // namespace |
| 65 | 62 |
| 66 // static | 63 // static |
| 67 // {E161255A-37C3-11D2-BCAA-00C04fD929DB} | 64 // {E161255A-37C3-11D2-BCAA-00C04fD929DB} |
| 68 const GUID IEImporter::kPStoreAutocompleteGUID = {0xe161255a, 0x37c3, 0x11d2, | 65 const GUID IEImporter::kPStoreAutocompleteGUID = {0xe161255a, 0x37c3, 0x11d2, |
| 69 {0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb}}; | 66 {0xbc, 0xaa, 0x00, 0xc0, 0x4f, 0xd9, 0x29, 0xdb}}; |
| 70 // {A79029D6-753E-4e27-B807-3D46AB1545DF} | 67 // {A79029D6-753E-4e27-B807-3D46AB1545DF} |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 for (i = 0; i < ac_list.size(); i++) { | 211 for (i = 0; i < ac_list.size(); i++) { |
| 215 if (!ac_list[i].is_url || ac_list[i].data.size() < 2) | 212 if (!ac_list[i].is_url || ac_list[i].data.size() < 2) |
| 216 continue; | 213 continue; |
| 217 | 214 |
| 218 GURL url(ac_list[i].key.c_str()); | 215 GURL url(ac_list[i].key.c_str()); |
| 219 if (!(LowerCaseEqualsASCII(url.scheme(), chrome::kHttpScheme) || | 216 if (!(LowerCaseEqualsASCII(url.scheme(), chrome::kHttpScheme) || |
| 220 LowerCaseEqualsASCII(url.scheme(), chrome::kHttpsScheme))) { | 217 LowerCaseEqualsASCII(url.scheme(), chrome::kHttpsScheme))) { |
| 221 continue; | 218 continue; |
| 222 } | 219 } |
| 223 | 220 |
| 224 PasswordForm form; | 221 webkit_glue::PasswordForm form; |
| 225 GURL::Replacements rp; | 222 GURL::Replacements rp; |
| 226 rp.ClearUsername(); | 223 rp.ClearUsername(); |
| 227 rp.ClearPassword(); | 224 rp.ClearPassword(); |
| 228 rp.ClearQuery(); | 225 rp.ClearQuery(); |
| 229 rp.ClearRef(); | 226 rp.ClearRef(); |
| 230 form.origin = url.ReplaceComponents(rp); | 227 form.origin = url.ReplaceComponents(rp); |
| 231 form.username_value = ac_list[i].data[0]; | 228 form.username_value = ac_list[i].data[0]; |
| 232 form.password_value = ac_list[i].data[1]; | 229 form.password_value = ac_list[i].data[1]; |
| 233 form.signon_realm = url.GetOrigin().spec(); | 230 form.signon_realm = url.GetOrigin().spec(); |
| 234 | 231 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 // Get the size of the encrypted data. | 271 // Get the size of the encrypted data. |
| 275 DWORD value_len = 0; | 272 DWORD value_len = 0; |
| 276 key.ReadValue(reg_iterator.Name(), NULL, &value_len, NULL); | 273 key.ReadValue(reg_iterator.Name(), NULL, &value_len, NULL); |
| 277 if (value_len) { | 274 if (value_len) { |
| 278 // Query the encrypted data. | 275 // Query the encrypted data. |
| 279 password_info.encrypted_data.resize(value_len); | 276 password_info.encrypted_data.resize(value_len); |
| 280 if (key.ReadValue(reg_iterator.Name(), | 277 if (key.ReadValue(reg_iterator.Name(), |
| 281 &password_info.encrypted_data.front(), | 278 &password_info.encrypted_data.front(), |
| 282 &value_len, NULL) == ERROR_SUCCESS) { | 279 &value_len, NULL) == ERROR_SUCCESS) { |
| 283 password_info.url_hash = reg_iterator.Name(); | 280 password_info.url_hash = reg_iterator.Name(); |
| 284 password_info.date_created = Time::Now(); | 281 password_info.date_created = base::Time::Now(); |
| 285 | 282 |
| 286 bridge_->AddIE7PasswordInfo(password_info); | 283 bridge_->AddIE7PasswordInfo(password_info); |
| 287 } | 284 } |
| 288 } | 285 } |
| 289 | 286 |
| 290 ++reg_iterator; | 287 ++reg_iterator; |
| 291 } | 288 } |
| 292 } | 289 } |
| 293 | 290 |
| 294 // Reads history information from COM interface. | 291 // Reads history information from COM interface. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 325 | 322 |
| 326 GURL url(url_string); | 323 GURL url(url_string); |
| 327 // Skips the URLs that are invalid or have other schemes. | 324 // Skips the URLs that are invalid or have other schemes. |
| 328 if (!url.is_valid() || | 325 if (!url.is_valid() || |
| 329 (std::find(kSchemes, kSchemes + total_schemes, url.scheme()) == | 326 (std::find(kSchemes, kSchemes + total_schemes, url.scheme()) == |
| 330 kSchemes + total_schemes)) | 327 kSchemes + total_schemes)) |
| 331 continue; | 328 continue; |
| 332 | 329 |
| 333 history::URLRow row(url); | 330 history::URLRow row(url); |
| 334 row.set_title(title_string); | 331 row.set_title(title_string); |
| 335 row.set_last_visit(Time::FromFileTime(stat_url.ftLastVisited)); | 332 row.set_last_visit(base::Time::FromFileTime(stat_url.ftLastVisited)); |
| 336 if (stat_url.dwFlags == STATURL_QUERYFLAG_TOPLEVEL) { | 333 if (stat_url.dwFlags == STATURL_QUERYFLAG_TOPLEVEL) { |
| 337 row.set_visit_count(1); | 334 row.set_visit_count(1); |
| 338 row.set_hidden(false); | 335 row.set_hidden(false); |
| 339 } else { | 336 } else { |
| 340 row.set_hidden(true); | 337 row.set_hidden(true); |
| 341 } | 338 } |
| 342 | 339 |
| 343 rows.push_back(row); | 340 rows.push_back(row); |
| 344 } | 341 } |
| 345 | 342 |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 if (version < 0) { | 591 if (version < 0) { |
| 595 wchar_t buffer[128]; | 592 wchar_t buffer[128]; |
| 596 DWORD buffer_length = sizeof(buffer); | 593 DWORD buffer_length = sizeof(buffer); |
| 597 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, | 594 base::win::RegKey reg_key(HKEY_LOCAL_MACHINE, |
| 598 L"Software\\Microsoft\\Internet Explorer", KEY_READ); | 595 L"Software\\Microsoft\\Internet Explorer", KEY_READ); |
| 599 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); | 596 LONG result = reg_key.ReadValue(L"Version", buffer, &buffer_length, NULL); |
| 600 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); | 597 version = ((result == ERROR_SUCCESS)? _wtoi(buffer) : 0); |
| 601 } | 598 } |
| 602 return version; | 599 return version; |
| 603 } | 600 } |
| OLD | NEW |