| 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/ui/toolbar/back_forward_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
| 6 | 6 |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 11 #include "chrome/browser/history/history.h" | 12 #include "chrome/browser/history/history.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
| 13 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 14 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| 15 #include "chrome/browser/ui/browser_tabstrip.h" | 16 #include "chrome/browser/ui/browser_tabstrip.h" |
| 16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 18 #include "chrome/test/base/test_browser_window.h" | 19 #include "chrome/test/base/test_browser_window.h" |
| 19 #include "chrome/test/base/testing_profile.h" | 20 #include "chrome/test/base/testing_profile.h" |
| 20 #include "content/public/browser/navigation_controller.h" | 21 #include "content/public/browser/navigation_controller.h" |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 GURL url1_favicon("http://www.a.com/1/favicon.ico"); | 523 GURL url1_favicon("http://www.a.com/1/favicon.ico"); |
| 523 | 524 |
| 524 NavigateAndCommit(url1); | 525 NavigateAndCommit(url1); |
| 525 // Navigate to a new URL so that url1 will be in the BackForwardMenuModel. | 526 // Navigate to a new URL so that url1 will be in the BackForwardMenuModel. |
| 526 NavigateAndCommit(url2); | 527 NavigateAndCommit(url2); |
| 527 | 528 |
| 528 // Set the desired favicon for url1. | 529 // Set the desired favicon for url1. |
| 529 HistoryServiceFactory::GetForProfile( | 530 HistoryServiceFactory::GetForProfile( |
| 530 profile(), Profile::EXPLICIT_ACCESS)->AddPage( | 531 profile(), Profile::EXPLICIT_ACCESS)->AddPage( |
| 531 url1, history::SOURCE_BROWSED); | 532 url1, history::SOURCE_BROWSED); |
| 532 profile()->GetFaviconService(Profile::EXPLICIT_ACCESS)->SetFavicon(url1, | 533 FaviconServiceFactory::GetForProfile( |
| 533 url1_favicon, icon_data, history::FAVICON); | 534 profile(), Profile::EXPLICIT_ACCESS)->SetFavicon( |
| 535 url1, url1_favicon, icon_data, history::FAVICON); |
| 534 | 536 |
| 535 // Will return the current icon (default) but start an anync call | 537 // Will return the current icon (default) but start an anync call |
| 536 // to retrieve the favicon from the favicon service. | 538 // to retrieve the favicon from the favicon service. |
| 537 gfx::Image default_icon; | 539 gfx::Image default_icon; |
| 538 back_model.GetIconAt(0, &default_icon); | 540 back_model.GetIconAt(0, &default_icon); |
| 539 | 541 |
| 540 // Make the favicon service run GetFavIconForURL, | 542 // Make the favicon service run GetFavIconForURL, |
| 541 // FaviconDelegate.OnIconChanged will be called. | 543 // FaviconDelegate.OnIconChanged will be called. |
| 542 MessageLoop::current()->Run(); | 544 MessageLoop::current()->Run(); |
| 543 | 545 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 562 // Verify we did get the expected favicon. | 564 // Verify we did get the expected favicon. |
| 563 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), | 565 EXPECT_EQ(0, memcmp(new_icon_bitmap.getPixels(), |
| 564 valid_icon_bitmap.getPixels(), | 566 valid_icon_bitmap.getPixels(), |
| 565 new_icon_bitmap.getSize())); | 567 new_icon_bitmap.getSize())); |
| 566 | 568 |
| 567 // Make sure the browser deconstructor doesn't have problems. | 569 // Make sure the browser deconstructor doesn't have problems. |
| 568 chrome::CloseAllTabs(browser.get()); | 570 chrome::CloseAllTabs(browser.get()); |
| 569 // This is required to prevent the message loop from hanging. | 571 // This is required to prevent the message loop from hanging. |
| 570 profile()->DestroyHistoryService(); | 572 profile()->DestroyHistoryService(); |
| 571 } | 573 } |
| OLD | NEW |