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

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

Issue 5159001: Rest of the autofill work. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: autofill second part with cr feedback fixed Created 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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
11
10 #include "base/string16.h" 12 #include "base/string16.h"
11 #include "base/string_util.h" 13 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 14 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/bookmarks/bookmark_utils.h" 15 #include "chrome/browser/bookmarks/bookmark_utils.h"
14 #include "chrome/browser/browser_thread.h" 16 #include "chrome/browser/browser_thread.h"
15 #include "chrome/browser/favicon_service.h" 17 #include "chrome/browser/favicon_service.h"
16 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/sync/profile_sync_service.h" 19 #include "chrome/browser/sync/profile_sync_service.h"
18 #include "gfx/codec/png_codec.h" 20 #include "gfx/codec/png_codec.h"
19 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 20 matching lines...) Expand all
40 } 42 }
41 43
42 void BookmarkChangeProcessor::StopImpl() { 44 void BookmarkChangeProcessor::StopImpl() {
43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
44 DCHECK(bookmark_model_); 46 DCHECK(bookmark_model_);
45 bookmark_model_->RemoveObserver(this); 47 bookmark_model_->RemoveObserver(this);
46 bookmark_model_ = NULL; 48 bookmark_model_ = NULL;
47 model_associator_ = NULL; 49 model_associator_ = NULL;
48 } 50 }
49 51
52
50 void BookmarkChangeProcessor::UpdateSyncNodeProperties( 53 void BookmarkChangeProcessor::UpdateSyncNodeProperties(
51 const BookmarkNode* src, BookmarkModel* model, sync_api::WriteNode* dst) { 54 const BookmarkNode* src, BookmarkModel* model, sync_api::WriteNode* dst) {
52 // Set the properties of the item. 55 // Set the properties of the item.
53 dst->SetIsFolder(src->is_folder()); 56 dst->SetIsFolder(src->is_folder());
54 dst->SetTitle(UTF16ToWideHack(src->GetTitle())); 57 dst->SetTitle(UTF16ToWideHack(src->GetTitle()));
55 if (!src->is_folder()) 58 if (!src->is_folder())
56 dst->SetURL(src->GetURL()); 59 dst->SetURL(src->GetURL());
57 SetSyncNodeFavicon(src, model, dst); 60 SetSyncNodeFavicon(src, model, dst);
58 } 61 }
59 62
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 441
439 // Create a bookmark node corresponding to |src| if one is not already 442 // Create a bookmark node corresponding to |src| if one is not already
440 // associated with |src|. 443 // associated with |src|.
441 const BookmarkNode* BookmarkChangeProcessor::CreateOrUpdateBookmarkNode( 444 const BookmarkNode* BookmarkChangeProcessor::CreateOrUpdateBookmarkNode(
442 sync_api::BaseNode* src, 445 sync_api::BaseNode* src,
443 BookmarkModel* model) { 446 BookmarkModel* model) {
444 const BookmarkNode* parent = 447 const BookmarkNode* parent =
445 model_associator_->GetChromeNodeFromSyncId(src->GetParentId()); 448 model_associator_->GetChromeNodeFromSyncId(src->GetParentId());
446 if (!parent) { 449 if (!parent) {
447 DLOG(WARNING) << "Could not find parent of node being added/updated." 450 DLOG(WARNING) << "Could not find parent of node being added/updated."
448 << " Node title: " << src->GetTitle() 451 //<< " Node title: " << src->GetTitle()
449 << ", parent id = " << src->GetParentId(); 452 << ", parent id = " << src->GetParentId();
453
450 return NULL; 454 return NULL;
451 } 455 }
452 int index = CalculateBookmarkModelInsertionIndex(parent, src); 456 int index = CalculateBookmarkModelInsertionIndex(parent, src);
453 const BookmarkNode* dst = model_associator_->GetChromeNodeFromSyncId( 457 const BookmarkNode* dst = model_associator_->GetChromeNodeFromSyncId(
454 src->GetId()); 458 src->GetId());
455 if (!dst) { 459 if (!dst) {
456 dst = CreateBookmarkNode(src, parent, model, index); 460 dst = CreateBookmarkNode(src, parent, model, index);
457 model_associator_->Associate(dst, src->GetId()); 461 model_associator_->Associate(dst, src->GetId());
458 } else { 462 } else {
459 // URL and is_folder are not expected to change. 463 // URL and is_folder are not expected to change.
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 const BookmarkNode* bookmark_node, 546 const BookmarkNode* bookmark_node,
543 BookmarkModel* model, 547 BookmarkModel* model,
544 sync_api::WriteNode* sync_node) { 548 sync_api::WriteNode* sync_node) {
545 std::vector<unsigned char> favicon_bytes; 549 std::vector<unsigned char> favicon_bytes;
546 EncodeFavicon(bookmark_node, model, &favicon_bytes); 550 EncodeFavicon(bookmark_node, model, &favicon_bytes);
547 if (!favicon_bytes.empty()) 551 if (!favicon_bytes.empty())
548 sync_node->SetFaviconBytes(favicon_bytes); 552 sync_node->SetFaviconBytes(favicon_bytes);
549 } 553 }
550 554
551 } // namespace browser_sync 555 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698