| OLD | NEW |
| 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/sync/test/integration/bookmarks_helper.h" | 5 #include "chrome/browser/sync/test/integration/bookmarks_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 return FaviconData(model->GetFavicon(node), node->icon_url()); | 248 return FaviconData(model->GetFavicon(node), node->icon_url()); |
| 249 } | 249 } |
| 250 | 250 |
| 251 // Sets the favicon for |profile| and |node|. |profile| may be | 251 // Sets the favicon for |profile| and |node|. |profile| may be |
| 252 // |test()->verifier()|. | 252 // |test()->verifier()|. |
| 253 void SetFaviconImpl(Profile* profile, | 253 void SetFaviconImpl(Profile* profile, |
| 254 const BookmarkNode* node, | 254 const BookmarkNode* node, |
| 255 const GURL& icon_url, | 255 const GURL& icon_url, |
| 256 const gfx::Image& image, | 256 const gfx::Image& image, |
| 257 bookmarks_helper::FaviconSource favicon_source) { | 257 bookmarks_helper::FaviconSource favicon_source) { |
| 258 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 258 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); |
| 259 | 259 |
| 260 FaviconChangeObserver observer(model, node); | 260 FaviconChangeObserver observer(model, node); |
| 261 favicon::FaviconService* favicon_service = | 261 favicon::FaviconService* favicon_service = |
| 262 FaviconServiceFactory::GetForProfile( | 262 FaviconServiceFactory::GetForProfile(profile, |
| 263 profile, ServiceAccessType::EXPLICIT_ACCESS); | 263 ServiceAccessType::EXPLICIT_ACCESS); |
| 264 if (favicon_source == bookmarks_helper::FROM_UI) { | 264 if (favicon_source == bookmarks_helper::FROM_UI) { |
| 265 favicon_service->SetFavicons( | 265 favicon_service->SetFavicons(node->url(), icon_url, favicon_base::FAVICON, |
| 266 node->url(), icon_url, favicon_base::FAVICON, image); | 266 image); |
| 267 } else { | 267 } else { |
| 268 ProfileSyncService* pss = | 268 ProfileSyncService* pss = |
| 269 ProfileSyncServiceFactory::GetForProfile(profile); | 269 ProfileSyncServiceFactory::GetForProfile(profile); |
| 270 browser_sync::BookmarkChangeProcessor::ApplyBookmarkFavicon( | 270 browser_sync::BookmarkChangeProcessor::ApplyBookmarkFavicon( |
| 271 node, pss->GetSyncClient(), icon_url, image.As1xPNGBytes()); | 271 node, pss->GetSyncClient(), icon_url, image.As1xPNGBytes()); |
| 272 } | 272 } |
| 273 | 273 |
| 274 // Wait for the favicon for |node| to be invalidated. | 274 // Wait for the favicon for |node| to be invalidated. |
| 275 observer.WaitForSetFavicon(); | 275 observer.WaitForSetFavicon(); |
| 276 // Wait for the BookmarkModel to fetch the updated favicon and for the new | 276 // Wait for the BookmarkModel to fetch the updated favicon and for the new |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 ASSERT_TRUE(NodesMatch(foreign_node, walker)); | 447 ASSERT_TRUE(NodesMatch(foreign_node, walker)); |
| 448 *result = walker; | 448 *result = walker; |
| 449 } | 449 } |
| 450 | 450 |
| 451 } // namespace | 451 } // namespace |
| 452 | 452 |
| 453 | 453 |
| 454 namespace bookmarks_helper { | 454 namespace bookmarks_helper { |
| 455 | 455 |
| 456 BookmarkModel* GetBookmarkModel(int index) { | 456 BookmarkModel* GetBookmarkModel(int index) { |
| 457 return BookmarkModelFactory::GetForProfile( | 457 return BookmarkModelFactory::GetForBrowserContext( |
| 458 sync_datatype_helper::test()->GetProfile(index)); | 458 sync_datatype_helper::test()->GetProfile(index)); |
| 459 } | 459 } |
| 460 | 460 |
| 461 const BookmarkNode* GetBookmarkBarNode(int index) { | 461 const BookmarkNode* GetBookmarkBarNode(int index) { |
| 462 return GetBookmarkModel(index)->bookmark_bar_node(); | 462 return GetBookmarkModel(index)->bookmark_bar_node(); |
| 463 } | 463 } |
| 464 | 464 |
| 465 const BookmarkNode* GetOtherNode(int index) { | 465 const BookmarkNode* GetOtherNode(int index) { |
| 466 return GetBookmarkModel(index)->other_node(); | 466 return GetBookmarkModel(index)->other_node(); |
| 467 } | 467 } |
| 468 | 468 |
| 469 const BookmarkNode* GetSyncedBookmarksNode(int index) { | 469 const BookmarkNode* GetSyncedBookmarksNode(int index) { |
| 470 return GetBookmarkModel(index)->mobile_node(); | 470 return GetBookmarkModel(index)->mobile_node(); |
| 471 } | 471 } |
| 472 | 472 |
| 473 const BookmarkNode* GetManagedNode(int index) { | 473 const BookmarkNode* GetManagedNode(int index) { |
| 474 return ManagedBookmarkServiceFactory::GetForProfile( | 474 return ManagedBookmarkServiceFactory::GetForProfile( |
| 475 sync_datatype_helper::test()->GetProfile(index)) | 475 sync_datatype_helper::test()->GetProfile(index)) |
| 476 ->managed_node(); | 476 ->managed_node(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 BookmarkModel* GetVerifierBookmarkModel() { | 479 BookmarkModel* GetVerifierBookmarkModel() { |
| 480 return BookmarkModelFactory::GetForProfile( | 480 return BookmarkModelFactory::GetForBrowserContext( |
| 481 sync_datatype_helper::test()->verifier()); | 481 sync_datatype_helper::test()->verifier()); |
| 482 } | 482 } |
| 483 | 483 |
| 484 const BookmarkNode* AddURL(int profile, | 484 const BookmarkNode* AddURL(int profile, |
| 485 const std::string& title, | 485 const std::string& title, |
| 486 const GURL& url) { | 486 const GURL& url) { |
| 487 return AddURL(profile, GetBookmarkBarNode(profile), 0, title, url); | 487 return AddURL(profile, GetBookmarkBarNode(profile), 0, title, url); |
| 488 } | 488 } |
| 489 | 489 |
| 490 const BookmarkNode* AddURL(int profile, | 490 const BookmarkNode* AddURL(int profile, |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 | 1001 |
| 1002 std::string IndexedSubfolderName(int i) { | 1002 std::string IndexedSubfolderName(int i) { |
| 1003 return base::StringPrintf("Subfolder Name %d", i); | 1003 return base::StringPrintf("Subfolder Name %d", i); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 std::string IndexedSubsubfolderName(int i) { | 1006 std::string IndexedSubsubfolderName(int i) { |
| 1007 return base::StringPrintf("Subsubfolder Name %d", i); | 1007 return base::StringPrintf("Subsubfolder Name %d", i); |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 } // namespace bookmarks_helper | 1010 } // namespace bookmarks_helper |
| OLD | NEW |