1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // The order of these includes is important.
9 #include <propvarutil.h>
17 #include "base/bind.h"
18 #include "base/compiler_specific.h"
19 #include "base/files/file_util.h"
20 #include "base/files/scoped_temp_dir.h"
21 #include "base/message_loop/message_loop.h"
22 #include "base/stl_util.h"
23 #include "base/strings/string16.h"
24 #include "base/strings/string_util.h"
25 #include "base/strings/utf_string_conversions.h"
26 #include "base/win/registry.h"
27 #include "base/win/scoped_comptr.h"
28 #include "base/win/scoped_propvariant.h"
29 #include "base/win/windows_version.h"
30 #include "chrome/browser/importer/external_process_importer_host.h"
31 #include "chrome/browser/importer/importer_progress_observer.h"
32 #include "chrome/browser/importer/importer_unittest_utils.h"
33 #include "chrome/browser/ui/browser.h"
34 #include "chrome/common/chrome_paths.h"
35 #include "chrome/common/importer/ie_importer_test_registry_overrider_win.h"
36 #include "chrome/common/importer/ie_importer_utils_win.h"
37 #include "chrome/common/importer/imported_bookmark_entry.h"
38 #include "chrome/common/importer/importer_bridge.h"
39 #include "chrome/common/importer/importer_data_types.h"
40 #include "chrome/test/base/in_process_browser_test.h"
41 #include "chrome/test/base/testing_profile.h"
42 #include "components/autofill/core/common/password_form.h"
43 #include "components/favicon_base/favicon_usage_data.h"
44 #include "components/os_crypt/ie7_password_win.h"
45 #include "components/search_engines/template_url.h"
46 #include "testing/gtest/include/gtest/gtest.h"
50 const BookmarkInfo kIEBookmarks
[] = {
51 {true, 2, {"Links", "SubFolderOfLinks"},
53 "http://www.links-sublink.com/"},
56 "http://www.links-thelink.com/"},
59 "http://www.google.com/"},
62 "http://www.links-thelink.com/"},
63 {false, 1, {"SubFolder"},
65 "http://www.link.com/"},
68 "http://host:8080/cgi?q=query"},
71 "http://chinese-title-favorite/"},
74 "http://www.subfolder.com/"},
77 const BookmarkInfo kIESortedBookmarks
[] = {
78 {false, 0, {}, L
"a", "http://www.google.com/0"},
79 {false, 1, {"b"}, L
"a", "http://www.google.com/1"},
80 {false, 1, {"b"}, L
"b", "http://www.google.com/2"},
81 {false, 0, {}, L
"c", "http://www.google.com/3"},
84 const base::char16 kIEIdentifyUrl
[] =
85 L
"http://A79029D6-753E-4e27-B807-3D46AB1545DF.com:8080/path?key=value";
86 const base::char16 kIEIdentifyTitle
[] =
88 const base::char16 kIECacheItemUrl
[] =
89 L
"http://B2EF40C8-2569-4D7E-97EA-BAD9DF468D9C.com";
90 const base::char16 kIECacheItemTitle
[] =
91 L
"Unittest Cache Item GUID";
93 const base::char16 kFaviconStreamSuffix
[] = L
"url:favicon:$DATA";
94 const char kDummyFaviconImageData
[] =
95 "\x42\x4D" // Magic signature 'BM'
96 "\x1E\x00\x00\x00" // File size
97 "\x00\x00\x00\x00" // Reserved
98 "\x1A\x00\x00\x00" // Offset of the pixel data
99 "\x0C\x00\x00\x00" // Header Size
100 "\x01\x00\x01\x00" // Size: 1x1
101 "\x01\x00" // Reserved
102 "\x18\x00" // 24-bits
103 "\x00\xFF\x00\x00"; // The pixel
105 struct FaviconGroup
{
106 const base::char16
* favicon_url
;
107 const base::char16
* site_url
[2];
110 const FaviconGroup kIEFaviconGroup
[2] = {
111 {L
"http://www.google.com/favicon.ico",
112 {L
"http://www.google.com/",
113 L
"http://www.subfolder.com/"}},
114 {L
"http://example.com/favicon.ico",
115 {L
"http://host:8080/cgi?q=query",
116 L
"http://chinese-title-favorite/"}},
119 bool CreateOrderBlob(const base::FilePath
& favorites_folder
,
120 const base::string16
& path
,
121 const std::vector
<base::string16
>& entries
) {
122 if (entries
.size() > 255)
125 // Create a binary sequence for setting a specific order of favorites.
126 // The format depends on the version of Shell32.dll, so we cannot embed
127 // a binary constant here.
128 std::vector
<uint8
> blob(20, 0);
129 blob
[16] = static_cast<uint8
>(entries
.size());
131 for (size_t i
= 0; i
< entries
.size(); ++i
) {
132 PIDLIST_ABSOLUTE id_list_full
= ILCreateFromPath(
133 favorites_folder
.Append(path
).Append(entries
[i
]).value().c_str());
134 PUITEMID_CHILD id_list
= ILFindLastID(id_list_full
);
135 // Include the trailing zero-length item id. Don't include the single
137 size_t id_list_size
= id_list
->mkid
.cb
+ sizeof(id_list
->mkid
.cb
);
139 blob
.resize(blob
.size() + 8);
140 uint32 total_size
= id_list_size
+ 8;
141 memcpy(&blob
[blob
.size() - 8], &total_size
, 4);
142 uint32 sort_index
= i
;
143 memcpy(&blob
[blob
.size() - 4], &sort_index
, 4);
144 blob
.resize(blob
.size() + id_list_size
);
145 memcpy(&blob
[blob
.size() - id_list_size
], id_list
, id_list_size
);
146 ILFree(id_list_full
);
149 base::string16
key_path(importer::GetIEFavoritesOrderKey());
151 key_path
+= L
"\\" + path
;
152 base::win::RegKey key
;
153 if (key
.Create(HKEY_CURRENT_USER
, key_path
.c_str(), KEY_WRITE
) !=
157 if (key
.WriteValue(L
"Order", &blob
[0], blob
.size(), REG_BINARY
) !=
164 bool CreateUrlFileWithFavicon(const base::FilePath
& file
,
165 const base::string16
& url
,
166 const base::string16
& favicon_url
) {
167 base::win::ScopedComPtr
<IUniformResourceLocator
> locator
;
168 HRESULT result
= locator
.CreateInstance(CLSID_InternetShortcut
, NULL
,
169 CLSCTX_INPROC_SERVER
);
172 base::win::ScopedComPtr
<IPersistFile
> persist_file
;
173 result
= persist_file
.QueryFrom(locator
.get());
176 result
= locator
->SetURL(url
.c_str(), 0);
180 // Write favicon url if specified.
181 if (!favicon_url
.empty()) {
182 base::win::ScopedComPtr
<IPropertySetStorage
> property_set_storage
;
183 if (FAILED(property_set_storage
.QueryFrom(locator
.get())))
185 base::win::ScopedComPtr
<IPropertyStorage
> property_storage
;
186 if (FAILED(property_set_storage
->Open(FMTID_Intshcut
,
188 property_storage
.Receive()))) {
191 PROPSPEC properties
[] = {{PRSPEC_PROPID
, PID_IS_ICONFILE
}};
192 // WriteMultiple takes an array of PROPVARIANTs, but since this code only
193 // needs an array of size 1: a pointer to |pv_icon| is equivalent.
194 base::win::ScopedPropVariant pv_icon
;
195 if (FAILED(InitPropVariantFromString(favicon_url
.c_str(),
196 pv_icon
.Receive())) ||
198 property_storage
->WriteMultiple(1, properties
, pv_icon
.ptr(), 0))) {
203 // Save the .url file.
204 result
= persist_file
->Save(file
.value().c_str(), TRUE
);
208 // Write dummy favicon image data in NTFS alternate data stream.
209 return favicon_url
.empty() || (base::WriteFile(
210 file
.ReplaceExtension(kFaviconStreamSuffix
), kDummyFaviconImageData
,
211 sizeof kDummyFaviconImageData
) != -1);
214 bool CreateUrlFile(const base::FilePath
& file
, const base::string16
& url
) {
215 return CreateUrlFileWithFavicon(file
, url
, base::string16());
218 class TestObserver
: public ProfileWriter
,
219 public importer::ImporterProgressObserver
{
226 explicit TestObserver(uint16 importer_items
, TestIEVersion ie_version
)
227 : ProfileWriter(NULL
),
233 ie7_password_count_(0),
234 importer_items_(importer_items
),
235 ie_version_(ie_version
) {
238 // importer::ImporterProgressObserver:
239 virtual void ImportStarted() override
{}
240 virtual void ImportItemStarted(importer::ImportItem item
) override
{}
241 virtual void ImportItemEnded(importer::ImportItem item
) override
{}
242 virtual void ImportEnded() override
{
243 base::MessageLoop::current()->Quit();
244 if (importer_items_
& importer::FAVORITES
) {
245 EXPECT_EQ(arraysize(kIEBookmarks
), bookmark_count_
);
246 EXPECT_EQ(arraysize(kIEFaviconGroup
), favicon_count_
);
248 if (importer_items_
& importer::HISTORY
)
249 EXPECT_EQ(2, history_count_
);
250 if (importer_items_
& importer::HOME_PAGE
)
251 EXPECT_EQ(1, homepage_count_
);
252 if ((importer_items_
& importer::PASSWORDS
) && (ie_version_
== IE7
))
253 EXPECT_EQ(1, ie7_password_count_
);
254 // We need to test the IE6 password importer code.
255 // https://crbug.com/257100
256 // EXPECT_EQ(1, password_count_);
259 virtual bool BookmarkModelIsLoaded() const {
260 // Profile is ready for writing.
264 virtual bool TemplateURLServiceIsLoaded() const {
268 virtual void AddPasswordForm(const autofill::PasswordForm
& form
) {
269 // Importer should obtain this password form only.
270 EXPECT_EQ(GURL("http://localhost:8080/security/index.htm"), form
.origin
);
271 EXPECT_EQ("http://localhost:8080/", form
.signon_realm
);
272 EXPECT_EQ(L
"user", form
.username_element
);
273 EXPECT_EQ(L
"1", form
.username_value
);
274 EXPECT_EQ(L
"", form
.password_element
);
275 EXPECT_EQ(L
"2", form
.password_value
);
276 EXPECT_EQ("", form
.action
.spec());
280 virtual void AddHistoryPage(const history::URLRows
& page
,
281 history::VisitSource visit_source
) {
282 bool cache_item_found
= false;
283 bool history_item_found
= false;
284 // Importer should read the specified URL.
285 for (size_t i
= 0; i
< page
.size(); ++i
) {
286 if (page
[i
].title() == kIEIdentifyTitle
&&
287 page
[i
].url() == GURL(kIEIdentifyUrl
)) {
288 EXPECT_FALSE(page
[i
].hidden());
289 history_item_found
= true;
292 if (page
[i
].title() == kIECacheItemTitle
&&
293 page
[i
].url() == GURL(kIECacheItemUrl
)) {
294 EXPECT_TRUE(page
[i
].hidden());
295 cache_item_found
= true;
299 EXPECT_TRUE(history_item_found
);
300 EXPECT_TRUE(cache_item_found
);
301 EXPECT_EQ(history::SOURCE_IE_IMPORTED
, visit_source
);
304 virtual void AddBookmarks(
305 const std::vector
<ImportedBookmarkEntry
>& bookmarks
,
306 const base::string16
& top_level_folder_name
) override
{
307 ASSERT_LE(bookmark_count_
+ bookmarks
.size(), arraysize(kIEBookmarks
));
308 // Importer should import the IE Favorites folder the same as the list,
309 // in the same order.
310 for (size_t i
= 0; i
< bookmarks
.size(); ++i
) {
311 EXPECT_NO_FATAL_FAILURE(
312 TestEqualBookmarkEntry(bookmarks
[i
],
313 kIEBookmarks
[bookmark_count_
])) << i
;
318 virtual void AddKeyword(std::vector
<TemplateURL
*> template_url
,
319 int default_keyword_index
) {
320 // TODO(jcampan): bug 1169230: we should test keyword importing for IE.
321 // In order to do that we'll probably need to mock the Windows registry.
323 STLDeleteContainerPointers(template_url
.begin(), template_url
.end());
326 virtual void AddFavicons(
327 const favicon_base::FaviconUsageDataList
& usage
) override
{
328 // Importer should group the favicon information for each favicon URL.
329 for (size_t i
= 0; i
< arraysize(kIEFaviconGroup
); ++i
) {
330 GURL
favicon_url(kIEFaviconGroup
[i
].favicon_url
);
332 for (size_t j
= 0; j
< arraysize(kIEFaviconGroup
[i
].site_url
); ++j
)
333 urls
.insert(GURL(kIEFaviconGroup
[i
].site_url
[j
]));
335 SCOPED_TRACE(testing::Message() << "Expected Favicon: " << favicon_url
);
337 bool expected_favicon_url_found
= false;
338 for (size_t j
= 0; j
< usage
.size(); ++j
) {
339 if (usage
[j
].favicon_url
== favicon_url
) {
340 EXPECT_EQ(urls
, usage
[j
].urls
);
341 expected_favicon_url_found
= true;
345 EXPECT_TRUE(expected_favicon_url_found
);
348 favicon_count_
+= usage
.size();
351 virtual void AddIE7PasswordInfo(const IE7PasswordInfo
& info
) {
352 // This function also gets called for the IEImporter test. Ignore.
353 if (ie_version_
== IE7
) {
354 EXPECT_EQ(L
"Test1", info
.url_hash
);
355 EXPECT_EQ(1, info
.encrypted_data
[0]);
356 EXPECT_EQ(4, info
.encrypted_data
.size());
357 ++ie7_password_count_
;
361 virtual void AddHomepage(const GURL
& homepage
) {
362 EXPECT_EQ(homepage
.spec(), "http://www.test.com/");
369 size_t bookmark_count_
;
370 size_t history_count_
;
371 size_t password_count_
;
372 size_t favicon_count_
;
373 size_t homepage_count_
;
374 size_t ie7_password_count_
;
375 uint16 importer_items_
;
376 TestIEVersion ie_version_
;
379 class MalformedFavoritesRegistryTestObserver
380 : public ProfileWriter
,
381 public importer::ImporterProgressObserver
{
383 MalformedFavoritesRegistryTestObserver() : ProfileWriter(NULL
) {
387 // importer::ImporterProgressObserver:
388 virtual void ImportStarted() override
{}
389 virtual void ImportItemStarted(importer::ImportItem item
) override
{}
390 virtual void ImportItemEnded(importer::ImportItem item
) override
{}
391 virtual void ImportEnded() override
{
392 base::MessageLoop::current()->Quit();
393 EXPECT_EQ(arraysize(kIESortedBookmarks
), bookmark_count_
);
396 virtual bool BookmarkModelIsLoaded() const { return true; }
397 virtual bool TemplateURLServiceIsLoaded() const { return true; }
399 virtual void AddPasswordForm(const autofill::PasswordForm
& form
) {}
400 virtual void AddHistoryPage(const history::URLRows
& page
,
401 history::VisitSource visit_source
) {}
402 virtual void AddKeyword(std::vector
<TemplateURL
*> template_url
,
403 int default_keyword_index
) {}
404 virtual void AddBookmarks(
405 const std::vector
<ImportedBookmarkEntry
>& bookmarks
,
406 const base::string16
& top_level_folder_name
) override
{
407 ASSERT_LE(bookmark_count_
+ bookmarks
.size(),
408 arraysize(kIESortedBookmarks
));
409 for (size_t i
= 0; i
< bookmarks
.size(); ++i
) {
410 EXPECT_NO_FATAL_FAILURE(
411 TestEqualBookmarkEntry(bookmarks
[i
],
412 kIESortedBookmarks
[bookmark_count_
])) << i
;
418 ~MalformedFavoritesRegistryTestObserver() {}
420 size_t bookmark_count_
;
425 // These tests need to be browser tests in order to be able to run the OOP
426 // import (via ExternalProcessImporterHost) which launches a utility process.
427 class IEImporterBrowserTest
: public InProcessBrowserTest
{
429 virtual void SetUp() override
{
430 ASSERT_TRUE(temp_dir_
.CreateUniqueTempDir());
432 // This will launch the browser test and thus needs to happen last.
433 InProcessBrowserTest::SetUp();
436 base::ScopedTempDir temp_dir_
;
438 // Overrides the default registry key for IE registry keys like favorites,
439 // settings, password store, etc.
440 IEImporterTestRegistryOverrider test_registry_overrider_
;
443 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest
, IEImporter
) {
444 // Sets up a favorites folder.
445 base::FilePath path
= temp_dir_
.path().AppendASCII("Favorites");
446 CreateDirectory(path
.value().c_str(), NULL
);
447 CreateDirectory(path
.AppendASCII("SubFolder").value().c_str(), NULL
);
448 base::FilePath links_path
= path
.AppendASCII("Links");
449 CreateDirectory(links_path
.value().c_str(), NULL
);
450 CreateDirectory(links_path
.AppendASCII("SubFolderOfLinks").value().c_str(),
452 CreateDirectory(path
.AppendASCII("\x0061").value().c_str(), NULL
);
453 ASSERT_TRUE(CreateUrlFileWithFavicon(path
.AppendASCII("Google Home Page.url"),
454 L
"http://www.google.com/",
455 L
"http://www.google.com/favicon.ico"));
456 ASSERT_TRUE(CreateUrlFile(path
.AppendASCII("SubFolder\\Title.url"),
457 L
"http://www.link.com/"));
458 ASSERT_TRUE(CreateUrlFileWithFavicon(path
.AppendASCII("SubFolder.url"),
459 L
"http://www.subfolder.com/",
460 L
"http://www.google.com/favicon.ico"));
461 ASSERT_TRUE(CreateUrlFile(path
.AppendASCII("TheLink.url"),
462 L
"http://www.links-thelink.com/"));
463 ASSERT_TRUE(CreateUrlFileWithFavicon(path
.AppendASCII("WithPortAndQuery.url"),
464 L
"http://host:8080/cgi?q=query",
465 L
"http://example.com/favicon.ico"));
466 ASSERT_TRUE(CreateUrlFileWithFavicon(
467 path
.AppendASCII("\x0061").Append(L
"\x4E2D\x6587.url"),
468 L
"http://chinese-title-favorite/",
469 L
"http://example.com/favicon.ico"));
470 ASSERT_TRUE(CreateUrlFile(links_path
.AppendASCII("TheLink.url"),
471 L
"http://www.links-thelink.com/"));
472 ASSERT_TRUE(CreateUrlFile(
473 links_path
.AppendASCII("SubFolderOfLinks").AppendASCII("SubLink.url"),
474 L
"http://www.links-sublink.com/"));
475 ASSERT_TRUE(CreateUrlFile(path
.AppendASCII("IEDefaultLink.url"),
476 L
"http://go.microsoft.com/fwlink/?linkid=140813"));
477 base::WriteFile(path
.AppendASCII("InvalidUrlFile.url"), "x", 1);
478 base::WriteFile(path
.AppendASCII("PlainTextFile.txt"), "x", 1);
480 const base::char16
* root_links
[] = {
482 L
"Google Home Page.url",
485 L
"WithPortAndQuery.url",
489 ASSERT_TRUE(CreateOrderBlob(
490 base::FilePath(path
), L
"",
491 std::vector
<base::string16
>(root_links
,
492 root_links
+ arraysize(root_links
))));
494 // Sets up a special history link.
495 base::win::ScopedComPtr
<IUrlHistoryStg2
> url_history_stg2
;
496 ASSERT_EQ(S_OK
, url_history_stg2
.CreateInstance(CLSID_CUrlHistory
, NULL
,
497 CLSCTX_INPROC_SERVER
));
498 // Usage of ADDURL_ADDTOHISTORYANDCACHE and ADDURL_ADDTOCACHE flags
499 // is explained in the article:
500 // http://msdn.microsoft.com/ru-ru/aa767730
501 ASSERT_EQ(S_OK
, url_history_stg2
->AddUrl(kIEIdentifyUrl
, kIEIdentifyTitle
,
502 ADDURL_ADDTOHISTORYANDCACHE
));
503 ASSERT_EQ(S_OK
, url_history_stg2
->AddUrl(kIECacheItemUrl
, kIECacheItemTitle
,
506 // Starts to import the above settings.
508 ExternalProcessImporterHost
* host
= new ExternalProcessImporterHost
;
509 TestObserver
* observer
= new TestObserver(
510 importer::HISTORY
| importer::PASSWORDS
| importer::FAVORITES
,
512 host
->set_observer(observer
);
514 importer::SourceProfile source_profile
;
515 source_profile
.importer_type
= importer::TYPE_IE
;
516 source_profile
.source_path
= temp_dir_
.path();
518 host
->StartImportSettings(
520 browser()->profile(),
521 importer::HISTORY
| importer::PASSWORDS
| importer::FAVORITES
,
523 base::MessageLoop::current()->Run();
526 url_history_stg2
->DeleteUrl(kIEIdentifyUrl
, 0);
527 url_history_stg2
->DeleteUrl(kIECacheItemUrl
, 0);
528 url_history_stg2
.Release();
531 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest
,
532 IEImporterMalformedFavoritesRegistry
) {
533 // Sets up a favorites folder.
534 base::FilePath path
= temp_dir_
.path().AppendASCII("Favorites");
535 CreateDirectory(path
.value().c_str(), NULL
);
536 CreateDirectory(path
.AppendASCII("b").value().c_str(), NULL
);
537 ASSERT_TRUE(CreateUrlFile(path
.AppendASCII("a.url"),
538 L
"http://www.google.com/0"));
539 ASSERT_TRUE(CreateUrlFile(path
.AppendASCII("b").AppendASCII("a.url"),
540 L
"http://www.google.com/1"));
541 ASSERT_TRUE(CreateUrlFile(path
.AppendASCII("b").AppendASCII("b.url"),
542 L
"http://www.google.com/2"));
543 ASSERT_TRUE(CreateUrlFile(path
.AppendASCII("c.url"),
544 L
"http://www.google.com/3"));
546 struct BadBinaryData
{
550 static const BadBinaryData kBadBinary
[] = {
551 // number_of_items field is truncated
552 {"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
553 "\x00\xff\xff\xff", 17},
554 // number_of_items = 0xffff, but the byte sequence is too short.
555 {"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
556 "\xff\xff\x00\x00", 20},
557 // number_of_items = 1, size_of_item is too big.
558 {"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
560 "\xff\xff\x00\x00\x00\x00\x00\x00"
561 "\x00\x00\x00\x00", 32},
562 // number_of_items = 1, size_of_item = 16, size_of_shid is too big.
563 {"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
565 "\x10\x00\x00\x00\x00\x00\x00\x00"
566 "\xff\x7f\x00\x00" "\x00\x00\x00\x00", 36},
567 // number_of_items = 1, size_of_item = 16, size_of_shid is too big.
568 {"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
570 "\x10\x00\x00\x00\x00\x00\x00\x00"
571 "\x06\x00\x00\x00" "\x00\x00\x00\x00", 36},
574 // Verify malformed registry data are safely ignored and alphabetical
575 // sort is performed.
576 for (size_t i
= 0; i
< arraysize(kBadBinary
); ++i
) {
577 base::string16
key_path(importer::GetIEFavoritesOrderKey());
578 base::win::RegKey key
;
579 ASSERT_EQ(ERROR_SUCCESS
,
580 key
.Create(HKEY_CURRENT_USER
, key_path
.c_str(), KEY_WRITE
));
581 ASSERT_EQ(ERROR_SUCCESS
,
582 key
.WriteValue(L
"Order", kBadBinary
[i
].data
, kBadBinary
[i
].length
,
585 // Starts to import the above settings.
587 ExternalProcessImporterHost
* host
= new ExternalProcessImporterHost
;
588 MalformedFavoritesRegistryTestObserver
* observer
=
589 new MalformedFavoritesRegistryTestObserver();
590 host
->set_observer(observer
);
592 importer::SourceProfile source_profile
;
593 source_profile
.importer_type
= importer::TYPE_IE
;
594 source_profile
.source_path
= temp_dir_
.path();
596 host
->StartImportSettings(
598 browser()->profile(),
601 base::MessageLoop::current()->Run();
605 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest
, IE7ImporterPasswordsTest
) {
606 // Starts to import the IE7 passwords.
608 ExternalProcessImporterHost
* host
= new ExternalProcessImporterHost
;
609 TestObserver
* observer
= new TestObserver(importer::PASSWORDS
,
611 host
->set_observer(observer
);
613 base::string16
key_path(importer::GetIE7PasswordsKey());
614 base::win::RegKey key
;
615 ASSERT_EQ(ERROR_SUCCESS
,
616 key
.Create(HKEY_CURRENT_USER
, key_path
.c_str(), KEY_WRITE
));
617 key
.WriteValue(L
"Test1", 1);
619 importer::SourceProfile source_profile
;
620 source_profile
.importer_type
= importer::TYPE_IE
;
621 source_profile
.source_path
= temp_dir_
.path();
623 host
->StartImportSettings(
625 browser()->profile(),
628 base::MessageLoop::current()->Run();
631 IN_PROC_BROWSER_TEST_F(IEImporterBrowserTest
, IEImporterHomePageTest
) {
632 // Starts to import the IE home page.
634 ExternalProcessImporterHost
* host
= new ExternalProcessImporterHost
;
635 TestObserver
* observer
= new TestObserver(importer::HOME_PAGE
,
637 host
->set_observer(observer
);
639 base::string16
key_path(importer::GetIESettingsKey());
640 base::win::RegKey key
;
641 ASSERT_EQ(ERROR_SUCCESS
,
642 key
.Create(HKEY_CURRENT_USER
, key_path
.c_str(), KEY_WRITE
));
643 key
.WriteValue(L
"Start Page", L
"http://www.test.com/");
645 importer::SourceProfile source_profile
;
646 source_profile
.importer_type
= importer::TYPE_IE
;
647 source_profile
.source_path
= temp_dir_
.path();
649 host
->StartImportSettings(
651 browser()->profile(),
654 base::MessageLoop::current()->Run();