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 <memory> |
7 #include <set> | 8 #include <set> |
8 | 9 |
9 #include "base/files/file_enumerator.h" | 10 #include "base/files/file_enumerator.h" |
10 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
11 #include "base/json/json_file_value_serializer.h" | 12 #include "base/json/json_file_value_serializer.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
19 #include "chrome/common/importer/firefox_importer_utils.h" | 19 #include "chrome/common/importer/firefox_importer_utils.h" |
20 #include "chrome/common/importer/imported_bookmark_entry.h" | 20 #include "chrome/common/importer/imported_bookmark_entry.h" |
21 #include "chrome/common/importer/importer_autofill_form_data_entry.h" | 21 #include "chrome/common/importer/importer_autofill_form_data_entry.h" |
22 #include "chrome/common/importer/importer_bridge.h" | 22 #include "chrome/common/importer/importer_bridge.h" |
23 #include "chrome/common/importer/importer_url_row.h" | 23 #include "chrome/common/importer/importer_url_row.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 } | 535 } |
536 } | 536 } |
537 | 537 |
538 void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( | 538 void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( |
539 std::vector<std::string>* search_engine_data) { | 539 std::vector<std::string>* search_engine_data) { |
540 // search-metadata.json contains keywords for search engines. This | 540 // search-metadata.json contains keywords for search engines. This |
541 // file exists only if the user has set keywords for search engines. | 541 // file exists only if the user has set keywords for search engines. |
542 base::FilePath search_metadata_json_file = | 542 base::FilePath search_metadata_json_file = |
543 source_path_.AppendASCII("search-metadata.json"); | 543 source_path_.AppendASCII("search-metadata.json"); |
544 JSONFileValueDeserializer metadata_deserializer(search_metadata_json_file); | 544 JSONFileValueDeserializer metadata_deserializer(search_metadata_json_file); |
545 scoped_ptr<base::Value> metadata_root = | 545 std::unique_ptr<base::Value> metadata_root = |
546 metadata_deserializer.Deserialize(NULL, NULL); | 546 metadata_deserializer.Deserialize(NULL, NULL); |
547 const base::DictionaryValue* search_metadata_root = NULL; | 547 const base::DictionaryValue* search_metadata_root = NULL; |
548 if (metadata_root) | 548 if (metadata_root) |
549 metadata_root->GetAsDictionary(&search_metadata_root); | 549 metadata_root->GetAsDictionary(&search_metadata_root); |
550 | 550 |
551 // search.json contains information about search engines to import. | 551 // search.json contains information about search engines to import. |
552 base::FilePath search_json_file = source_path_.AppendASCII("search.json"); | 552 base::FilePath search_json_file = source_path_.AppendASCII("search.json"); |
553 if (!base::PathExists(search_json_file)) | 553 if (!base::PathExists(search_json_file)) |
554 return; | 554 return; |
555 | 555 |
556 JSONFileValueDeserializer deserializer(search_json_file); | 556 JSONFileValueDeserializer deserializer(search_json_file); |
557 scoped_ptr<base::Value> root = deserializer.Deserialize(NULL, NULL); | 557 std::unique_ptr<base::Value> root = deserializer.Deserialize(NULL, NULL); |
558 const base::DictionaryValue* search_root = NULL; | 558 const base::DictionaryValue* search_root = NULL; |
559 if (!root || !root->GetAsDictionary(&search_root)) | 559 if (!root || !root->GetAsDictionary(&search_root)) |
560 return; | 560 return; |
561 | 561 |
562 const std::string kDirectories("directories"); | 562 const std::string kDirectories("directories"); |
563 const base::DictionaryValue* search_directories = NULL; | 563 const base::DictionaryValue* search_directories = NULL; |
564 if (!search_root->GetDictionary(kDirectories, &search_directories)) | 564 if (!search_root->GetDictionary(kDirectories, &search_directories)) |
565 return; | 565 return; |
566 | 566 |
567 // Dictionary |search_directories| contains a list of search engines | 567 // Dictionary |search_directories| contains a list of search engines |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 | 785 |
786 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 786 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
787 continue; // Unable to decode. | 787 continue; // Unable to decode. |
788 | 788 |
789 usage.urls = i->second; | 789 usage.urls = i->second; |
790 favicons->push_back(usage); | 790 favicons->push_back(usage); |
791 } | 791 } |
792 s.Reset(true); | 792 s.Reset(true); |
793 } | 793 } |
794 } | 794 } |
OLD | NEW |