OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/utility/importer/firefox_importer.h" | 5 #include "chrome/utility/importer/firefox_importer.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 | 376 |
377 void FirefoxImporter::ImportHomepage() { | 377 void FirefoxImporter::ImportHomepage() { |
378 GURL home_page = GetHomepage(source_path_); | 378 GURL home_page = GetHomepage(source_path_); |
379 if (home_page.is_valid() && !IsDefaultHomepage(home_page, app_path_)) { | 379 if (home_page.is_valid() && !IsDefaultHomepage(home_page, app_path_)) { |
380 bridge_->AddHomePage(home_page); | 380 bridge_->AddHomePage(home_page); |
381 } | 381 } |
382 } | 382 } |
383 | 383 |
384 void FirefoxImporter::GetSearchEnginesXMLData( | 384 void FirefoxImporter::GetSearchEnginesXMLData( |
385 std::vector<std::string>* search_engine_data) { | 385 std::vector<std::string>* search_engine_data) { |
386 // TODO(mpawlowski): This may no longer work, search engines are stored in | |
387 // search.json since Firefox 3.5, not in search.sqlite. XML definitions are | |
388 // still necessary. http://crbug.com/329175 | |
386 base::FilePath file = source_path_.AppendASCII("search.sqlite"); | 389 base::FilePath file = source_path_.AppendASCII("search.sqlite"); |
387 if (!base::PathExists(file)) | 390 if (!base::PathExists(file)) |
388 return; | 391 return; |
389 | 392 |
390 sql::Connection db; | 393 sql::Connection db; |
391 if (!db.Open(file)) | 394 if (!db.Open(file)) |
392 return; | 395 return; |
393 | 396 |
394 const char* query = "SELECT engineid FROM engine_data " | 397 const char* query = "SELECT engineid FROM engine_data " |
395 "WHERE engineid NOT IN " | 398 "WHERE engineid NOT IN " |
396 "(SELECT engineid FROM engine_data " | 399 "(SELECT engineid FROM engine_data " |
397 "WHERE name='hidden') " | 400 "WHERE name='hidden') " |
398 "ORDER BY value ASC"; | 401 "ORDER BY value ASC"; |
399 | 402 |
400 sql::Statement s(db.GetUniqueStatement(query)); | 403 sql::Statement s(db.GetUniqueStatement(query)); |
401 if (!s.is_valid()) | 404 if (!s.is_valid()) |
402 return; | 405 return; |
403 | 406 |
404 base::FilePath app_path = app_path_.AppendASCII("searchplugins"); | 407 // Since Firefox 21, searchplugins are in 'browser' subdirectory: |
408 base::FilePath app_path = app_path_.AppendASCII("browser/searchplugins"); | |
jeremy
2013/12/17 11:48:09
I'm uncomfortable with the static initialization u
jeremy
2013/12/17 11:48:09
Consider splitting into a new searchplugins_path a
mpawlowski
2013/12/17 12:31:25
We seem to be using it all over the place in vario
| |
409 if (!base::PathExists(app_path)) | |
410 // This might be an older Firefox, try old location: | |
411 app_path = app_path_.AppendASCII("searchplugins"); | |
405 base::FilePath profile_path = source_path_.AppendASCII("searchplugins"); | 412 base::FilePath profile_path = source_path_.AppendASCII("searchplugins"); |
406 | 413 |
407 // Firefox doesn't store a search engine in its sqlite database unless the | 414 // Firefox doesn't store a search engine in its sqlite database unless the |
408 // user has added a engine. So we get search engines from sqlite db as well | 415 // user has added a engine. So we get search engines from sqlite db as well |
409 // as from the file system. | 416 // as from the file system. |
410 if (s.Step()) { | 417 if (s.Step()) { |
411 const std::string kAppPrefix("[app]/"); | 418 const std::string kAppPrefix("[app]/"); |
412 const std::string kProfilePrefix("[profile]/"); | 419 const std::string kProfilePrefix("[profile]/"); |
413 do { | 420 do { |
414 base::FilePath file; | 421 base::FilePath file; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 | 602 |
596 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 603 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
597 continue; // Unable to decode. | 604 continue; // Unable to decode. |
598 | 605 |
599 usage.urls = i->second; | 606 usage.urls = i->second; |
600 favicons->push_back(usage); | 607 favicons->push_back(usage); |
601 } | 608 } |
602 s.Reset(true); | 609 s.Reset(true); |
603 } | 610 } |
604 } | 611 } |
OLD | NEW |