Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: chrome/utility/importer/firefox_importer.cc

Issue 117123002: Fixing Firefox 21+ password import (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tweaks in GetSearchEnginesXMLData Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 const base::FilePath searchplugins_path("searchplugins");
405 base::FilePath profile_path = source_path_.AppendASCII("searchplugins"); 408 // Search engine definitions are XMLs stored in two directories. Default
409 // engines are in the app directory (app_path_) and custom engines are
410 // in the profile directory (source_path_).
411
412 // Since Firefox 21, app_path_ engines are in 'browser' subdirectory:
413 base::FilePath app_path =
414 app_path_.AppendASCII("browser").Append(searchplugins_path);
415 if (!base::PathExists(app_path))
416 // This might be an older Firefox, try old location without the 'browser'
417 // path component:
418 app_path = app_path_.Append(searchplugins_path);
Ilya Sherman 2013/12/17 23:04:14 nit: Please add curly braces, since the body of th
419
420 base::FilePath profile_path = source_path_.Append(searchplugins_path);
406 421
407 // Firefox doesn't store a search engine in its sqlite database unless the 422 // 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 423 // user has added a engine. So we get search engines from sqlite db as well
409 // as from the file system. 424 // as from the file system.
410 if (s.Step()) { 425 if (s.Step()) {
411 const std::string kAppPrefix("[app]/"); 426 const std::string kAppPrefix("[app]/");
412 const std::string kProfilePrefix("[profile]/"); 427 const std::string kProfilePrefix("[profile]/");
413 do { 428 do {
414 base::FilePath file; 429 base::FilePath file;
415 std::string engine(s.ColumnString(0)); 430 std::string engine(s.ColumnString(0));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 610
596 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) 611 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data))
597 continue; // Unable to decode. 612 continue; // Unable to decode.
598 613
599 usage.urls = i->second; 614 usage.urls = i->second;
600 favicons->push_back(usage); 615 favicons->push_back(usage);
601 } 616 }
602 s.Reset(true); 617 s.Reset(true);
603 } 618 }
604 } 619 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698