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/files/file_enumerator.h" | 9 #include "base/files/file_enumerator.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 search_engine_data->push_back(file_data); | 532 search_engine_data->push_back(file_data); |
533 } | 533 } |
534 } | 534 } |
535 | 535 |
536 void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( | 536 void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( |
537 std::vector<std::string>* search_engine_data) { | 537 std::vector<std::string>* search_engine_data) { |
538 // search-metadata.json contains keywords for search engines. This | 538 // search-metadata.json contains keywords for search engines. This |
539 // file exists only if the user has set keywords for search engines. | 539 // file exists only if the user has set keywords for search engines. |
540 base::FilePath search_metadata_json_file = | 540 base::FilePath search_metadata_json_file = |
541 source_path_.AppendASCII("search-metadata.json"); | 541 source_path_.AppendASCII("search-metadata.json"); |
542 JSONFileValueSerializer metadata_serializer(search_metadata_json_file); | 542 JSONFileValueDeserializer metadata_deserializer(search_metadata_json_file); |
543 scoped_ptr<base::Value> metadata_root( | 543 scoped_ptr<base::Value> metadata_root( |
544 metadata_serializer.Deserialize(NULL, NULL)); | 544 metadata_deserializer.Deserialize(NULL, NULL)); |
545 const base::DictionaryValue* search_metadata_root = NULL; | 545 const base::DictionaryValue* search_metadata_root = NULL; |
546 if (metadata_root) | 546 if (metadata_root) |
547 metadata_root->GetAsDictionary(&search_metadata_root); | 547 metadata_root->GetAsDictionary(&search_metadata_root); |
548 | 548 |
549 // search.json contains information about search engines to import. | 549 // search.json contains information about search engines to import. |
550 base::FilePath search_json_file = source_path_.AppendASCII("search.json"); | 550 base::FilePath search_json_file = source_path_.AppendASCII("search.json"); |
551 if (!base::PathExists(search_json_file)) | 551 if (!base::PathExists(search_json_file)) |
552 return; | 552 return; |
553 | 553 |
554 JSONFileValueSerializer serializer(search_json_file); | 554 JSONFileValueDeserializer deserializer(search_json_file); |
555 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, NULL)); | 555 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL)); |
556 const base::DictionaryValue* search_root = NULL; | 556 const base::DictionaryValue* search_root = NULL; |
557 if (!root || !root->GetAsDictionary(&search_root)) | 557 if (!root || !root->GetAsDictionary(&search_root)) |
558 return; | 558 return; |
559 | 559 |
560 const std::string kDirectories("directories"); | 560 const std::string kDirectories("directories"); |
561 const base::DictionaryValue* search_directories = NULL; | 561 const base::DictionaryValue* search_directories = NULL; |
562 if (!search_root->GetDictionary(kDirectories, &search_directories)) | 562 if (!search_root->GetDictionary(kDirectories, &search_directories)) |
563 return; | 563 return; |
564 | 564 |
565 // Dictionary |search_directories| contains a list of search engines | 565 // Dictionary |search_directories| contains a list of search engines |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
783 | 783 |
784 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) | 784 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) |
785 continue; // Unable to decode. | 785 continue; // Unable to decode. |
786 | 786 |
787 usage.urls = i->second; | 787 usage.urls = i->second; |
788 favicons->push_back(usage); | 788 favicons->push_back(usage); |
789 } | 789 } |
790 s.Reset(true); | 790 s.Reset(true); |
791 } | 791 } |
792 } | 792 } |
OLD | NEW |