Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: chrome/utility/importer/firefox_importer.cc

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed cpplint warnings. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 search_engine_data->push_back(file_data); 531 search_engine_data->push_back(file_data);
532 } 532 }
533 } 533 }
534 534
535 void FirefoxImporter::GetSearchEnginesXMLDataFromJSON( 535 void FirefoxImporter::GetSearchEnginesXMLDataFromJSON(
536 std::vector<std::string>* search_engine_data) { 536 std::vector<std::string>* search_engine_data) {
537 // search-metadata.json contains keywords for search engines. This 537 // search-metadata.json contains keywords for search engines. This
538 // file exists only if the user has set keywords for search engines. 538 // file exists only if the user has set keywords for search engines.
539 base::FilePath search_metadata_json_file = 539 base::FilePath search_metadata_json_file =
540 source_path_.AppendASCII("search-metadata.json"); 540 source_path_.AppendASCII("search-metadata.json");
541 JSONFileValueSerializer metadata_serializer(search_metadata_json_file); 541 JSONFileValueDeserializer metadata_deserializer(search_metadata_json_file);
542 scoped_ptr<base::Value> metadata_root( 542 scoped_ptr<base::Value> metadata_root(
543 metadata_serializer.Deserialize(NULL, NULL)); 543 metadata_deserializer.Deserialize(NULL, NULL));
544 const base::DictionaryValue* search_metadata_root = NULL; 544 const base::DictionaryValue* search_metadata_root = NULL;
545 if (metadata_root) 545 if (metadata_root)
546 metadata_root->GetAsDictionary(&search_metadata_root); 546 metadata_root->GetAsDictionary(&search_metadata_root);
547 547
548 // search.json contains information about search engines to import. 548 // search.json contains information about search engines to import.
549 base::FilePath search_json_file = source_path_.AppendASCII("search.json"); 549 base::FilePath search_json_file = source_path_.AppendASCII("search.json");
550 if (!base::PathExists(search_json_file)) 550 if (!base::PathExists(search_json_file))
551 return; 551 return;
552 552
553 JSONFileValueSerializer serializer(search_json_file); 553 JSONFileValueDeserializer deserializer(search_json_file);
554 scoped_ptr<base::Value> root(serializer.Deserialize(NULL, NULL)); 554 scoped_ptr<base::Value> root(deserializer.Deserialize(NULL, NULL));
555 const base::DictionaryValue* search_root = NULL; 555 const base::DictionaryValue* search_root = NULL;
556 if (!root || !root->GetAsDictionary(&search_root)) 556 if (!root || !root->GetAsDictionary(&search_root))
557 return; 557 return;
558 558
559 const std::string kDirectories("directories"); 559 const std::string kDirectories("directories");
560 const base::DictionaryValue* search_directories = NULL; 560 const base::DictionaryValue* search_directories = NULL;
561 if (!search_root->GetDictionary(kDirectories, &search_directories)) 561 if (!search_root->GetDictionary(kDirectories, &search_directories))
562 return; 562 return;
563 563
564 // Dictionary |search_directories| contains a list of search engines 564 // Dictionary |search_directories| contains a list of search engines
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 782
783 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data)) 783 if (!importer::ReencodeFavicon(&data[0], data.size(), &usage.png_data))
784 continue; // Unable to decode. 784 continue; // Unable to decode.
785 785
786 usage.urls = i->second; 786 usage.urls = i->second;
787 favicons->push_back(usage); 787 favicons->push_back(usage);
788 } 788 }
789 s.Reset(true); 789 s.Reset(true);
790 } 790 }
791 } 791 }
OLDNEW
« no previous file with comments | « chrome/installer/util/uninstall_metrics_unittest.cc ('k') | chromeos/app_mode/kiosk_oem_manifest_parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698