OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 "base/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 }; | 60 }; |
61 | 61 |
62 const PasswordInfo kFirefoxPasswords[] = { | 62 const PasswordInfo kFirefoxPasswords[] = { |
63 {"http://localhost:8080/", "http://localhost:8080/", "http://localhost:8080/", | 63 {"http://localhost:8080/", "http://localhost:8080/", "http://localhost:8080/", |
64 L"loginuser", L"abc", L"loginpass", L"123", false}, | 64 L"loginuser", L"abc", L"loginpass", L"123", false}, |
65 {"http://localhost:8080/", "", "http://localhost:8080/localhost", | 65 {"http://localhost:8080/", "", "http://localhost:8080/localhost", |
66 L"", L"http", L"", L"Http1+1abcdefg", false}, | 66 L"", L"http", L"", L"Http1+1abcdefg", false}, |
67 }; | 67 }; |
68 | 68 |
69 const KeywordInfo kFirefoxKeywords[] = { | 69 const KeywordInfo kFirefoxKeywords[] = { |
70 { L"amazon.com", | 70 {L"amazon.com", |
71 "http://www.amazon.com/exec/obidos/external-search/?field-keywords=" | 71 "http://www.amazon.com/exec/obidos/external-search/?field-keywords=" |
72 "{searchTerms}&mode=blended" }, | 72 "{searchTerms}&mode=blended&tag=wwwcanoniccom-20"}, |
73 { L"answers.com", | 73 {L"bing.com", "http://www.bing.com/search?q={searchTerms}"}, |
74 "http://www.answers.com/main/ntquery?s={searchTerms}&gwp=13" }, | 74 {L"duckduckgo.com", "https://duckduckgo.com/?q={searchTerms}&t=canonical"}, |
75 { L"search.creativecommons.org", | 75 {L"rover.ebay.com", |
76 "http://search.creativecommons.org/?q={searchTerms}" }, | 76 "http://rover.ebay.com/rover/1/711-47294-18009-3/4?mpre=http://" |
77 { L"search.ebay.com", | 77 "shop.ebay.com/?_nkw={searchTerms}"}, |
78 "http://search.ebay.com/search/search.dll?query={searchTerms}&" | 78 {L"google.com", |
79 "MfcISAPICommand=GetResult&ht=1&ebaytag1=ebayreg&srchdesc=n&" | 79 "http://www.google.com/" |
80 "maxRecordsReturned=300&maxRecordsPerPage=50&SortProperty=MetaEndSort" }, | 80 "search?client=ubuntu&channel=fs&q={searchTerms}&ie=utf-8&oe=utf-8"}, |
81 { L"google.com", | 81 {L"en.wikipedia.org", |
82 "http://www.google.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t" }, | 82 "http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}"}, |
83 { L"en.wikipedia.org", | 83 {L"search.yahoo.com", |
84 "http://en.wikipedia.org/wiki/Special:Search?search={searchTerms}" }, | 84 "http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8"}, |
85 { L"search.yahoo.com", | 85 {L"twitter.com", |
86 "http://search.yahoo.com/search?p={searchTerms}&ei=UTF-8" }, | 86 "https://twitter.com/search?q={searchTerms}&source=desktop-search"}, |
87 { L"flickr.com", | 87 // Search keywords. |
88 "http://www.flickr.com/photos/tags/?q={searchTerms}" }, | 88 {L"\x4E2D\x6587", "http://www.google.com/"}, |
Ilya Sherman
2014/05/01 21:37:02
Hmm, it seems strange to need so many changes to t
| |
89 { L"imdb.com", | |
90 "http://www.imdb.com/find?q={searchTerms}" }, | |
91 { L"webster.com", | |
92 "http://www.webster.com/cgi-bin/dictionary?va={searchTerms}" }, | |
93 // Search keywords. | |
94 { L"\x4E2D\x6587", "http://www.google.com/" }, | |
95 }; | 89 }; |
96 | 90 |
97 class FirefoxObserver : public ProfileWriter, | 91 class FirefoxObserver : public ProfileWriter, |
98 public importer::ImporterProgressObserver { | 92 public importer::ImporterProgressObserver { |
99 public: | 93 public: |
100 FirefoxObserver() | 94 FirefoxObserver() |
101 : ProfileWriter(NULL), bookmark_count_(0), history_count_(0), | 95 : ProfileWriter(NULL), bookmark_count_(0), history_count_(0), |
102 password_count_(0), keyword_count_(0), import_search_engines_(true) { | 96 password_count_(0), keyword_count_(0), import_search_engines_(true) { |
103 } | 97 } |
104 | 98 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 | 235 |
242 base::FilePath search_engine_path = app_path_; | 236 base::FilePath search_engine_path = app_path_; |
243 search_engine_path = search_engine_path.AppendASCII("searchplugins"); | 237 search_engine_path = search_engine_path.AppendASCII("searchplugins"); |
244 base::CreateDirectory(search_engine_path); | 238 base::CreateDirectory(search_engine_path); |
245 if (import_search_plugins) { | 239 if (import_search_plugins) { |
246 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | 240 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); |
247 data_path = data_path.AppendASCII("firefox3_searchplugins"); | 241 data_path = data_path.AppendASCII("firefox3_searchplugins"); |
248 if (!base::PathExists(data_path)) { | 242 if (!base::PathExists(data_path)) { |
249 // TODO(maruel): Create search test data that we can open source! | 243 // TODO(maruel): Create search test data that we can open source! |
250 LOG(ERROR) << L"Missing internal test data"; | 244 LOG(ERROR) << L"Missing internal test data"; |
251 return; | |
252 } | 245 } |
Ilya Sherman
2014/05/01 21:37:02
Can we get rid of lines 242-245 entirely? Also po
| |
246 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_path)); | |
253 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false)); | 247 ASSERT_TRUE(base::CopyDirectory(data_path, search_engine_path, false)); |
254 } | 248 } |
255 | 249 |
256 importer::SourceProfile source_profile; | 250 importer::SourceProfile source_profile; |
257 source_profile.importer_type = importer::TYPE_FIREFOX; | 251 source_profile.importer_type = importer::TYPE_FIREFOX; |
258 source_profile.app_path = app_path_; | 252 source_profile.app_path = app_path_; |
259 source_profile.source_path = profile_path_; | 253 source_profile.source_path = profile_path_; |
260 source_profile.locale = "en-US"; | 254 source_profile.locale = "en-US"; |
261 | 255 |
262 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; | 256 int items = importer::HISTORY | importer::PASSWORDS | importer::FAVORITES; |
(...skipping 23 matching lines...) Expand all Loading... | |
286 } | 280 } |
287 | 281 |
288 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, | 282 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, |
289 MAYBE_IMPORTER(Firefox35Importer)) { | 283 MAYBE_IMPORTER(Firefox35Importer)) { |
290 bool import_search_engines = false; | 284 bool import_search_engines = false; |
291 scoped_refptr<FirefoxObserver> observer( | 285 scoped_refptr<FirefoxObserver> observer( |
292 new FirefoxObserver(import_search_engines)); | 286 new FirefoxObserver(import_search_engines)); |
293 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(), | 287 Firefox3xImporterBrowserTest("firefox35_profile", observer.get(), |
294 observer.get(), import_search_engines); | 288 observer.get(), import_search_engines); |
295 } | 289 } |
290 | |
291 IN_PROC_BROWSER_TEST_F(FirefoxProfileImporterBrowserTest, FirefoxImporter) { | |
292 scoped_refptr<FirefoxObserver> observer(new FirefoxObserver()); | |
293 Firefox3xImporterBrowserTest( | |
294 "firefox_profile", observer.get(), observer.get(), true); | |
295 } | |
Ilya Sherman
2014/05/01 21:37:02
Please include a README file in the new test direc
| |
OLD | NEW |