diff options
author | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-29 20:06:41 +0000 |
---|---|---|
committer | mirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-29 20:06:41 +0000 |
commit | e0262c9d5341eee36dbe30b376fb7d68c5485228 (patch) | |
tree | 86b7fa5902a0b4bb67ecb678e1f34156ff7564eb /chrome | |
parent | b6946352771f2ef4a97f7d47ec8db62fcd29bc01 (diff) | |
download | chromium_src-e0262c9d5341eee36dbe30b376fb7d68c5485228.zip chromium_src-e0262c9d5341eee36dbe30b376fb7d68c5485228.tar.gz chromium_src-e0262c9d5341eee36dbe30b376fb7d68c5485228.tar.bz2 |
Ensure that Firefox search engines are imported correctly.
It also makes sure that engines which have been removed from Firefox
are not imported into Chrome.
BUG= http://crbug.com/12245
TEST= Install firefox, and do not change the default search engines.
Start Chrome, and import search engines from Firefox. Default Firefox
engines should now be part of Chrome.
Review URL: http://codereview.chromium.org/115895
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/importer/firefox3_importer.cc | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/chrome/browser/importer/firefox3_importer.cc b/chrome/browser/importer/firefox3_importer.cc index 28ea6bd..60be97c 100644 --- a/chrome/browser/importer/firefox3_importer.cc +++ b/chrome/browser/importer/firefox3_importer.cc @@ -325,7 +325,11 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( scoped_ptr_malloc<sqlite3, DBClose> db(sqlite); SQLStatement s; - const char* stmt = "SELECT engineid FROM engine_data ORDER BY value ASC"; + const char* stmt = "SELECT engineid FROM engine_data " + "WHERE engineid NOT IN " + "(SELECT engineid FROM engine_data " + "WHERE name='hidden') " + "ORDER BY value ASC"; if (s.prepare(db.get(), stmt) != SQLITE_OK) return; @@ -335,31 +339,48 @@ void Firefox3Importer::GetSearchEnginesXMLFiles( std::wstring profile_path = source_path_; file_util::AppendToPath(&profile_path, L"searchplugins"); - const std::wstring kAppPrefix = L"[app]/"; - const std::wstring kProfilePrefix = L"[profile]/"; - while (s.step() == SQLITE_ROW && !cancelled()) { - std::wstring file; - std::wstring engine = UTF8ToWide(s.column_string(0)); - // The string contains [app]/<name>.xml or [profile]/<name>.xml where the - // [app] and [profile] need to be replaced with the actual app or profile - // path. - size_t index = engine.find(kAppPrefix); - if (index != std::wstring::npos) { - file = app_path; - file_util::AppendToPath( - &file, - engine.substr(index + kAppPrefix.length())); // Remove '[app]/'. - } else if ((index = engine.find(kProfilePrefix)) != std::wstring::npos) { - file = profile_path; - file_util::AppendToPath( - &file, - engine.substr(index + kProfilePrefix.length())); // Remove - // '[profile]/'. - } else { - NOTREACHED() << "Unexpected Firefox 3 search engine id"; - continue; + // Firefox doesn't store any search engines in its sqlite database unless + // the user has changed the standard set of engines. If we find that the + // database is empty, get the standard Firefox set from the app folder. + if (s.step() != SQLITE_ROW) { + file_util::FileEnumerator engines(FilePath::FromWStringHack(app_path), + false, + file_util::FileEnumerator::FILES); + for (FilePath engine_path = engines.Next(); !engine_path.value().empty(); + engine_path = engines.Next()) { + std::wstring enginew = engine_path.ToWStringHack(); + files->push_back(enginew); } - files->push_back(file); + } else { + const std::wstring kAppPrefix = L"[app]/"; + const std::wstring kProfilePrefix = L"[profile]/"; + do { + std::wstring file; + std::wstring engine = UTF8ToWide(s.column_string(0)); + + // The string contains [app]/<name>.xml or [profile]/<name>.xml where + // the [app] and [profile] need to be replaced with the actual app or + // profile path. + size_t index = engine.find(kAppPrefix); + if (index != std::wstring::npos) { + // Remove '[app]/'. + file = app_path; + file_util::AppendToPath( + &file, + engine.substr(index + kAppPrefix.length())); + } else if ((index = engine.find(kProfilePrefix)) != + std::wstring::npos) { + // Remove '[profile]/'. + file = profile_path; + file_util::AppendToPath( + &file, + engine.substr(index + kProfilePrefix.length())); + } else { + NOTREACHED() << "Unexpected Firefox 3 search engine id"; + continue; + } + files->push_back(file); + } while (s.step() == SQLITE_ROW && !cancelled()); } } |