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

Side by Side Diff: components/enhanced_bookmarks/enhanced_bookmark_model.cc

Issue 891873002: Add method for removing bookmark image data. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/enhanced_bookmarks/enhanced_bookmark_model.h" 5 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h"
6 6
7 #include <iomanip> 7 #include <iomanip>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 bool result = data.SerializePartialToString(&output); 219 bool result = data.SerializePartialToString(&output);
220 if (!result) 220 if (!result)
221 return false; 221 return false;
222 222
223 std::string encoded; 223 std::string encoded;
224 base::Base64Encode(output, &encoded); 224 base::Base64Encode(output, &encoded);
225 SetMetaInfo(node, kImageDataKey, encoded); 225 SetMetaInfo(node, kImageDataKey, encoded);
226 return true; 226 return true;
227 } 227 }
228 228
229 void EnhancedBookmarkModel::RemoveImageData(const BookmarkNode* node) {
230 DCHECK(node->is_url());
231 image::collections::ImageData data;
232 data.set_user_removed_image(true);
233
234 std::string encoded_data;
235 base::Base64Encode(data.SerializeAsString(), &encoded_data);
236 SetMetaInfo(node, kImageDataKey, encoded_data);
237 }
238
229 bool EnhancedBookmarkModel::GetOriginalImage(const BookmarkNode* node, 239 bool EnhancedBookmarkModel::GetOriginalImage(const BookmarkNode* node,
230 GURL* url, 240 GURL* url,
231 int* width, 241 int* width,
232 int* height) { 242 int* height) {
233 std::string decoded(DataForMetaInfoField(node, kImageDataKey)); 243 std::string decoded(DataForMetaInfoField(node, kImageDataKey));
234 if (decoded.empty()) 244 if (decoded.empty())
235 return false; 245 return false;
236 246
237 image::collections::ImageData data; 247 image::collections::ImageData data;
238 bool result = data.ParseFromString(decoded); 248 bool result = data.ParseFromString(decoded);
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 if (!result) 554 if (!result)
545 return false; 555 return false;
546 556
547 std::string encoded; 557 std::string encoded;
548 base::Base64Encode(output, &encoded); 558 base::Base64Encode(output, &encoded);
549 bookmark_model_->SetNodeMetaInfo(node, kImageDataKey, encoded); 559 bookmark_model_->SetNodeMetaInfo(node, kImageDataKey, encoded);
550 return true; 560 return true;
551 } 561 }
552 562
553 } // namespace enhanced_bookmarks 563 } // namespace enhanced_bookmarks
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698