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