OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/importer/firefox3_importer.h" | 5 #include "chrome/browser/importer/firefox3_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/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 if (!s) | 373 if (!s) |
374 return; | 374 return; |
375 | 375 |
376 FilePath app_path = app_path_.AppendASCII("searchplugins"); | 376 FilePath app_path = app_path_.AppendASCII("searchplugins"); |
377 FilePath profile_path = source_path_.AppendASCII("searchplugins"); | 377 FilePath profile_path = source_path_.AppendASCII("searchplugins"); |
378 | 378 |
379 // Firefox doesn't store a search engine in its sqlite database unless the | 379 // Firefox doesn't store a search engine in its sqlite database unless the |
380 // user has added a engine. So we get search engines from sqlite db as well | 380 // user has added a engine. So we get search engines from sqlite db as well |
381 // as from the file system. | 381 // as from the file system. |
382 if (s.Step()) { | 382 if (s.Step()) { |
383 const std::wstring kAppPrefix = L"[app]/"; | 383 const std::string kAppPrefix("[app]/"); |
384 const std::wstring kProfilePrefix = L"[profile]/"; | 384 const std::string kProfilePrefix("[profile]/"); |
385 do { | 385 do { |
386 FilePath file; | 386 FilePath file; |
387 std::wstring engine = UTF8ToWide(s.ColumnString(0)); | 387 std::string engine(s.ColumnString(0)); |
388 | 388 |
389 // The string contains [app]/<name>.xml or [profile]/<name>.xml where | 389 // The string contains [app]/<name>.xml or [profile]/<name>.xml where |
390 // the [app] and [profile] need to be replaced with the actual app or | 390 // the [app] and [profile] need to be replaced with the actual app or |
391 // profile path. | 391 // profile path. |
392 size_t index = engine.find(kAppPrefix); | 392 size_t index = engine.find(kAppPrefix); |
393 if (index != std::wstring::npos) { | 393 if (index != std::string::npos) { |
394 // Remove '[app]/'. | 394 // Remove '[app]/'. |
395 file = app_path.Append(FilePath::FromWStringHack( | 395 file = app_path.AppendASCII(engine.substr(index + kAppPrefix.length())); |
396 engine.substr(index + kAppPrefix.length()))); | 396 } else if ((index = engine.find(kProfilePrefix)) != std::string::npos) { |
397 } else if ((index = engine.find(kProfilePrefix)) != std::wstring::npos) { | |
398 // Remove '[profile]/'. | 397 // Remove '[profile]/'. |
399 file = profile_path.Append( | 398 file = profile_path.AppendASCII( |
400 FilePath::FromWStringHack( | 399 engine.substr(index + kProfilePrefix.length())); |
401 engine.substr(index + kProfilePrefix.length()))); | |
402 } else { | 400 } else { |
403 // Looks like absolute path to the file. | 401 // Looks like absolute path to the file. |
404 file = FilePath::FromWStringHack(engine); | 402 #if defined(OS_WIN) |
| 403 file = FilePath(UTF8ToWide(engine)); |
| 404 #else |
| 405 file = FilePath(engine); |
| 406 #endif |
405 } | 407 } |
406 files->push_back(file); | 408 files->push_back(file); |
407 } while (s.Step() && !cancelled()); | 409 } while (s.Step() && !cancelled()); |
408 } | 410 } |
409 | 411 |
410 #if defined(OS_POSIX) && !defined(OS_MACOSX) | 412 #if defined(OS_POSIX) && !defined(OS_MACOSX) |
411 // Ubuntu-flavored Firefox3 supports locale-specific search engines via | 413 // Ubuntu-flavored Firefox3 supports locale-specific search engines via |
412 // locale-named subdirectories. They fall back to en-US. | 414 // locale-named subdirectories. They fall back to en-US. |
413 // See http://crbug.com/53899 | 415 // See http://crbug.com/53899 |
414 // TODO(jshin): we need to make sure our locale code matches that of | 416 // TODO(jshin): we need to make sure our locale code matches that of |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 | 574 |
573 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 575 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
574 continue; // Unable to decode. | 576 continue; // Unable to decode. |
575 | 577 |
576 usage.urls = i->second; | 578 usage.urls = i->second; |
577 favicons->push_back(usage); | 579 favicons->push_back(usage); |
578 } | 580 } |
579 s.Reset(); | 581 s.Reset(); |
580 } | 582 } |
581 } | 583 } |
OLD | NEW |