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

Side by Side Diff: chrome/browser/sync/glue/bookmark_change_processor.cc

Issue 7612015: sync: Make BaseNode::GetTitle() return std::string. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix syncapi_unittest Created 9 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sync/glue/bookmark_change_processor.h" 5 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
6 6
7 #include <stack> 7 #include <stack>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 } else { 467 } else {
468 // URL and is_folder are not expected to change. 468 // URL and is_folder are not expected to change.
469 // TODO(ncarter): Determine if such changes should be legal or not. 469 // TODO(ncarter): Determine if such changes should be legal or not.
470 DCHECK_EQ(src->GetIsFolder(), dst->is_folder()); 470 DCHECK_EQ(src->GetIsFolder(), dst->is_folder());
471 471
472 // Handle reparenting and/or repositioning. 472 // Handle reparenting and/or repositioning.
473 model->Move(dst, parent, index); 473 model->Move(dst, parent, index);
474 474
475 if (!src->GetIsFolder()) 475 if (!src->GetIsFolder())
476 model->SetURL(dst, src->GetURL()); 476 model->SetURL(dst, src->GetURL());
477 model->SetTitle(dst, WideToUTF16Hack(src->GetTitle())); 477 model->SetTitle(dst, UTF8ToUTF16(src->GetTitle()));
478 478
479 SetBookmarkFavicon(src, dst, model); 479 SetBookmarkFavicon(src, dst, model);
480 } 480 }
481 481
482 return dst; 482 return dst;
483 } 483 }
484 484
485 // static 485 // static
486 // Creates a bookmark node under the given parent node from the given sync 486 // Creates a bookmark node under the given parent node from the given sync
487 // node. Returns the newly created node. 487 // node. Returns the newly created node.
488 const BookmarkNode* BookmarkChangeProcessor::CreateBookmarkNode( 488 const BookmarkNode* BookmarkChangeProcessor::CreateBookmarkNode(
489 sync_api::BaseNode* sync_node, 489 sync_api::BaseNode* sync_node,
490 const BookmarkNode* parent, 490 const BookmarkNode* parent,
491 BookmarkModel* model, 491 BookmarkModel* model,
492 int index) { 492 int index) {
493 DCHECK(parent); 493 DCHECK(parent);
494 DCHECK(index >= 0 && index <= parent->child_count()); 494 DCHECK(index >= 0 && index <= parent->child_count());
495 495
496 const BookmarkNode* node; 496 const BookmarkNode* node;
497 if (sync_node->GetIsFolder()) { 497 if (sync_node->GetIsFolder()) {
498 node = model->AddFolder(parent, index, 498 node = model->AddFolder(parent, index,
499 WideToUTF16Hack(sync_node->GetTitle())); 499 UTF8ToUTF16(sync_node->GetTitle()));
500 } else { 500 } else {
501 node = model->AddURL(parent, index, 501 node = model->AddURL(parent, index,
502 WideToUTF16Hack(sync_node->GetTitle()), 502 UTF8ToUTF16(sync_node->GetTitle()),
503 sync_node->GetURL()); 503 sync_node->GetURL());
504 SetBookmarkFavicon(sync_node, node, model); 504 SetBookmarkFavicon(sync_node, node, model);
505 } 505 }
506 return node; 506 return node;
507 } 507 }
508 508
509 // static 509 // static
510 // Sets the favicon of the given bookmark node from the given sync node. 510 // Sets the favicon of the given bookmark node from the given sync node.
511 bool BookmarkChangeProcessor::SetBookmarkFavicon( 511 bool BookmarkChangeProcessor::SetBookmarkFavicon(
512 sync_api::BaseNode* sync_node, 512 sync_api::BaseNode* sync_node,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 const BookmarkNode* bookmark_node, 553 const BookmarkNode* bookmark_node,
554 BookmarkModel* model, 554 BookmarkModel* model,
555 sync_api::WriteNode* sync_node) { 555 sync_api::WriteNode* sync_node) {
556 std::vector<unsigned char> favicon_bytes; 556 std::vector<unsigned char> favicon_bytes;
557 EncodeFavicon(bookmark_node, model, &favicon_bytes); 557 EncodeFavicon(bookmark_node, model, &favicon_bytes);
558 if (!favicon_bytes.empty()) 558 if (!favicon_bytes.empty())
559 sync_node->SetFaviconBytes(favicon_bytes); 559 sync_node->SetFaviconBytes(favicon_bytes);
560 } 560 }
561 561
562 } // namespace browser_sync 562 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/engine/syncapi_unittest.cc ('k') | chrome/browser/sync/glue/bookmark_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698