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

Side by Side Diff: chrome/browser/bookmarks/bookmark_html_writer.cc

Issue 2539363004: Make base::Value::TYPE a scoped enum. (Closed)
Patch Set: Rebase Created 4 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bookmarks/bookmark_html_writer.h" 5 #include "chrome/browser/bookmarks/bookmark_html_writer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 observer_(observer) { 106 observer_(observer) {
107 } 107 }
108 108
109 // Writing bookmarks and favicons data to file. 109 // Writing bookmarks and favicons data to file.
110 void DoWrite() { 110 void DoWrite() {
111 if (!OpenFile()) 111 if (!OpenFile())
112 return; 112 return;
113 113
114 base::Value* roots = NULL; 114 base::Value* roots = NULL;
115 if (!Write(kHeader) || 115 if (!Write(kHeader) ||
116 bookmarks_->GetType() != base::Value::TYPE_DICTIONARY || 116 bookmarks_->GetType() != base::Value::Type::DICTIONARY ||
117 !static_cast<base::DictionaryValue*>(bookmarks_.get())->Get( 117 !static_cast<base::DictionaryValue*>(bookmarks_.get())->Get(
118 BookmarkCodec::kRootsKey, &roots) || 118 BookmarkCodec::kRootsKey, &roots) ||
119 roots->GetType() != base::Value::TYPE_DICTIONARY) { 119 roots->GetType() != base::Value::Type::DICTIONARY) {
120 NOTREACHED(); 120 NOTREACHED();
121 return; 121 return;
122 } 122 }
123 123
124 base::DictionaryValue* roots_d_value = 124 base::DictionaryValue* roots_d_value =
125 static_cast<base::DictionaryValue*>(roots); 125 static_cast<base::DictionaryValue*>(roots);
126 base::Value* root_folder_value; 126 base::Value* root_folder_value;
127 base::Value* other_folder_value = NULL; 127 base::Value* other_folder_value = NULL;
128 base::Value* mobile_folder_value = NULL; 128 base::Value* mobile_folder_value = NULL;
129 if (!roots_d_value->Get(BookmarkCodec::kRootFolderNameKey, 129 if (!roots_d_value->Get(BookmarkCodec::kRootFolderNameKey,
130 &root_folder_value) || 130 &root_folder_value) ||
131 root_folder_value->GetType() != base::Value::TYPE_DICTIONARY || 131 root_folder_value->GetType() != base::Value::Type::DICTIONARY ||
132 !roots_d_value->Get(BookmarkCodec::kOtherBookmarkFolderNameKey, 132 !roots_d_value->Get(BookmarkCodec::kOtherBookmarkFolderNameKey,
133 &other_folder_value) || 133 &other_folder_value) ||
134 other_folder_value->GetType() != base::Value::TYPE_DICTIONARY || 134 other_folder_value->GetType() != base::Value::Type::DICTIONARY ||
135 !roots_d_value->Get(BookmarkCodec::kMobileBookmarkFolderNameKey, 135 !roots_d_value->Get(BookmarkCodec::kMobileBookmarkFolderNameKey,
136 &mobile_folder_value) || 136 &mobile_folder_value) ||
137 mobile_folder_value->GetType() != base::Value::TYPE_DICTIONARY) { 137 mobile_folder_value->GetType() != base::Value::Type::DICTIONARY) {
138 NOTREACHED(); 138 NOTREACHED();
139 return; // Invalid type for root folder and/or other folder. 139 return; // Invalid type for root folder and/or other folder.
140 } 140 }
141 141
142 IncrementIndent(); 142 IncrementIndent();
143 143
144 if (!WriteNode(*static_cast<base::DictionaryValue*>(root_folder_value), 144 if (!WriteNode(*static_cast<base::DictionaryValue*>(root_folder_value),
145 BookmarkNode::BOOKMARK_BAR) || 145 BookmarkNode::BOOKMARK_BAR) ||
146 !WriteNode(*static_cast<base::DictionaryValue*>(other_folder_value), 146 !WriteNode(*static_cast<base::DictionaryValue*>(other_folder_value),
147 BookmarkNode::OTHER_NODE) || 147 BookmarkNode::OTHER_NODE) ||
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 } 299 }
300 return true; 300 return true;
301 } 301 }
302 302
303 // Folder. 303 // Folder.
304 std::string last_modified_date; 304 std::string last_modified_date;
305 const base::Value* child_values = NULL; 305 const base::Value* child_values = NULL;
306 if (!value.GetString(BookmarkCodec::kDateModifiedKey, 306 if (!value.GetString(BookmarkCodec::kDateModifiedKey,
307 &last_modified_date) || 307 &last_modified_date) ||
308 !value.Get(BookmarkCodec::kChildrenKey, &child_values) || 308 !value.Get(BookmarkCodec::kChildrenKey, &child_values) ||
309 child_values->GetType() != base::Value::TYPE_LIST) { 309 child_values->GetType() != base::Value::Type::LIST) {
310 NOTREACHED(); 310 NOTREACHED();
311 return false; 311 return false;
312 } 312 }
313 if (folder_type != BookmarkNode::OTHER_NODE && 313 if (folder_type != BookmarkNode::OTHER_NODE &&
314 folder_type != BookmarkNode::MOBILE) { 314 folder_type != BookmarkNode::MOBILE) {
315 // The other/mobile folder name are not written out. This gives the effect 315 // The other/mobile folder name are not written out. This gives the effect
316 // of making the contents of the 'other folder' be a sibling to the 316 // of making the contents of the 'other folder' be a sibling to the
317 // bookmark bar folder. 317 // bookmark bar folder.
318 if (!WriteIndent() || 318 if (!WriteIndent() ||
319 !Write(kFolderStart) || 319 !Write(kFolderStart) ||
(...skipping 19 matching lines...) Expand all
339 } 339 }
340 IncrementIndent(); 340 IncrementIndent();
341 } 341 }
342 342
343 // Write the children. 343 // Write the children.
344 const base::ListValue* children = 344 const base::ListValue* children =
345 static_cast<const base::ListValue*>(child_values); 345 static_cast<const base::ListValue*>(child_values);
346 for (size_t i = 0; i < children->GetSize(); ++i) { 346 for (size_t i = 0; i < children->GetSize(); ++i) {
347 const base::Value* child_value; 347 const base::Value* child_value;
348 if (!children->Get(i, &child_value) || 348 if (!children->Get(i, &child_value) ||
349 child_value->GetType() != base::Value::TYPE_DICTIONARY) { 349 child_value->GetType() != base::Value::Type::DICTIONARY) {
350 NOTREACHED(); 350 NOTREACHED();
351 return false; 351 return false;
352 } 352 }
353 if (!WriteNode(*static_cast<const base::DictionaryValue*>(child_value), 353 if (!WriteNode(*static_cast<const base::DictionaryValue*>(child_value),
354 BookmarkNode::FOLDER)) { 354 BookmarkNode::FOLDER)) {
355 return false; 355 return false;
356 } 356 }
357 } 357 }
358 if (folder_type != BookmarkNode::OTHER_NODE && 358 if (folder_type != BookmarkNode::OTHER_NODE &&
359 folder_type != BookmarkNode::MOBILE) { 359 folder_type != BookmarkNode::MOBILE) {
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 // BookmarkModel isn't thread safe (nor would we want to lock it down 515 // BookmarkModel isn't thread safe (nor would we want to lock it down
516 // for the duration of the write), as such we make a copy of the 516 // for the duration of the write), as such we make a copy of the
517 // BookmarkModel using BookmarkCodec then write from that. 517 // BookmarkModel using BookmarkCodec then write from that.
518 if (!g_fetcher) { 518 if (!g_fetcher) {
519 g_fetcher = new BookmarkFaviconFetcher(profile, path, observer); 519 g_fetcher = new BookmarkFaviconFetcher(profile, path, observer);
520 g_fetcher->ExportBookmarks(); 520 g_fetcher->ExportBookmarks();
521 } 521 }
522 } 522 }
523 523
524 } // namespace bookmark_html_writer 524 } // namespace bookmark_html_writer
OLDNEW
« no previous file with comments | « chrome/browser/banners/app_banner_settings_helper.cc ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698