summaryrefslogtreecommitdiffstats
path: root/chrome/browser/favicon
diff options
context:
space:
mode:
authorjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-27 21:38:17 +0000
committerjam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-27 21:38:17 +0000
commitd583e3f2463dd1d216c92923e2eb9a9ba6066676 (patch)
treedcb942878d5bd6b548ae28555df88f49cdb988cc /chrome/browser/favicon
parent4806e850ba4d2fbc633ff2efebef757fbd050a8f (diff)
downloadchromium_src-d583e3f2463dd1d216c92923e2eb9a9ba6066676.zip
chromium_src-d583e3f2463dd1d216c92923e2eb9a9ba6066676.tar.gz
chromium_src-d583e3f2463dd1d216c92923e2eb9a9ba6066676.tar.bz2
Move FaviconStatus and SSLStatus out of NavigationEntry into their own files in content/public and in the content namespace. I've also made them structs instead of classes. This was because I didn't want to wrap them with Content API for what were really a collection of member variables. The one exception was SSLStatus::content_status which had helper functions around it to set and get the bitfield. Each of the two setter helpers were only called in one non-test code, and read in a few places, so I just converted them to do it directly.
BUG=98716 Review URL: http://codereview.chromium.org/9048002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@115847 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/favicon')
-rw-r--r--chrome/browser/favicon/favicon_handler.cc18
-rw-r--r--chrome/browser/favicon/favicon_handler_unittest.cc46
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.cc20
3 files changed, 43 insertions, 41 deletions
diff --git a/chrome/browser/favicon/favicon_handler.cc b/chrome/browser/favicon/favicon_handler.cc
index d317252..3ef1ca9 100644
--- a/chrome/browser/favicon/favicon_handler.cc
+++ b/chrome/browser/favicon/favicon_handler.cc
@@ -155,12 +155,12 @@ void FaviconHandler::UpdateFavicon(NavigationEntry* entry,
void FaviconHandler::UpdateFavicon(NavigationEntry* entry,
const gfx::Image* image) {
// No matter what happens, we need to mark the favicon as being set.
- entry->favicon().set_is_valid(true);
+ entry->GetFavicon().valid = true;
if (!image)
return;
- entry->favicon().set_bitmap(*image);
+ entry->GetFavicon().bitmap = *image;
delegate_->NotifyFaviconUpdated();
}
@@ -195,12 +195,12 @@ void FaviconHandler::OnUpdateFaviconURL(
// For FAVICON.
if (current_candidate()->icon_type == FaviconURL::FAVICON) {
- if (!favicon_expired_ && entry->favicon().is_valid() &&
- DoUrlAndIconMatch(*current_candidate(), entry->favicon().url(),
+ if (!favicon_expired_ && entry->GetFavicon().valid &&
+ DoUrlAndIconMatch(*current_candidate(), entry->GetFavicon().url,
history::FAVICON))
return;
- entry->favicon().set_url(current_candidate()->icon_url);
+ entry->GetFavicon().url = current_candidate()->icon_url;
} else if (!favicon_expired_ && got_favicon_from_history_ &&
history_icon_.is_valid() &&
DoUrlAndIconMatch(
@@ -322,7 +322,7 @@ void FaviconHandler::OnFaviconDataForInitialURL(
favicon_expired_ = (favicon.known_icon && favicon.expired);
if (favicon.known_icon && favicon.icon_type == history::FAVICON &&
- !entry->favicon().is_valid() &&
+ !entry->GetFavicon().valid &&
(!current_candidate() ||
DoUrlAndIconMatch(
*current_candidate(), favicon.icon_url, favicon.icon_type))) {
@@ -330,10 +330,10 @@ void FaviconHandler::OnFaviconDataForInitialURL(
// doesn't have an icon. Set the favicon now, and if the favicon turns out
// to be expired (or the wrong url) we'll fetch later on. This way the
// user doesn't see a flash of the default favicon.
- entry->favicon().set_url(favicon.icon_url);
+ entry->GetFavicon().url = favicon.icon_url;
if (favicon.is_valid())
UpdateFavicon(entry, favicon.image_data);
- entry->favicon().set_is_valid(true);
+ entry->GetFavicon().valid = true;
}
if (favicon.known_icon && !favicon.expired) {
@@ -405,7 +405,7 @@ void FaviconHandler::OnFaviconData(FaviconService::Handle handle,
if (!favicon.known_icon || favicon.expired) {
// We don't know the favicon, or it is out of date. Request the current
// one.
- ScheduleDownload(entry->GetURL(), entry->favicon().url(),
+ ScheduleDownload(entry->GetURL(), entry->GetFavicon().url,
preferred_icon_size(),
history::FAVICON,
FaviconTabHelper::ImageDownloadCallback());
diff --git a/chrome/browser/favicon/favicon_handler_unittest.cc b/chrome/browser/favicon/favicon_handler_unittest.cc
index 1358ba5..525c2ca 100644
--- a/chrome/browser/favicon/favicon_handler_unittest.cc
+++ b/chrome/browser/favicon/favicon_handler_unittest.cc
@@ -337,8 +337,8 @@ TEST_F(FaviconHandlerTest, GetFaviconFromHistory) {
// Send history response.
history_handler->InvokeCallback();
// Verify FaviconHandler status
- EXPECT_TRUE(helper.GetEntry()->favicon().is_valid());
- EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url());
+ EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
// Simulates update favicon url.
std::vector<FaviconURL> urls;
@@ -382,8 +382,8 @@ TEST_F(FaviconHandlerTest, DownloadFavicon) {
// Send history response.
history_handler->InvokeCallback();
// Verify FaviconHandler status
- EXPECT_TRUE(helper.GetEntry()->favicon().is_valid());
- EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url());
+ EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
// Simulates update favicon url.
std::vector<FaviconURL> urls;
@@ -418,9 +418,9 @@ TEST_F(FaviconHandlerTest, DownloadFavicon) {
EXPECT_EQ(page_url, history_handler->page_url_);
// Verify NavigationEntry.
- EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url());
- EXPECT_TRUE(helper.GetEntry()->favicon().is_valid());
- EXPECT_FALSE(helper.GetEntry()->favicon().bitmap().empty());
+ EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
+ EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty());
}
TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
@@ -454,8 +454,8 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
// Send history response.
history_handler->InvokeCallback();
// Verify FaviconHandler status.
- EXPECT_TRUE(helper.GetEntry()->favicon().is_valid());
- EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url());
+ EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
// Reset the history_handler to verify whether new icon is requested from
// history.
@@ -472,7 +472,7 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url);
ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
// The favicon status's url should be updated.
- ASSERT_EQ(new_icon_url, helper.GetEntry()->favicon().url());
+ ASSERT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url);
// Favicon should be requested from history.
history_handler = helper.history_handler();
@@ -507,9 +507,9 @@ TEST_F(FaviconHandlerTest, UpdateAndDownloadFavicon) {
EXPECT_EQ(page_url, history_handler->page_url_);
// Verify NavigationEntry.
- EXPECT_EQ(new_icon_url, helper.GetEntry()->favicon().url());
- EXPECT_TRUE(helper.GetEntry()->favicon().is_valid());
- EXPECT_FALSE(helper.GetEntry()->favicon().bitmap().empty());
+ EXPECT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url);
+ EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty());
}
TEST_F(FaviconHandlerTest, UpdateFavicon) {
@@ -543,8 +543,8 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) {
// Send history response.
history_handler->InvokeCallback();
// Verify FaviconHandler status.
- EXPECT_TRUE(helper.GetEntry()->favicon().is_valid());
- EXPECT_EQ(icon_url, helper.GetEntry()->favicon().url());
+ EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_EQ(icon_url, helper.GetEntry()->GetFavicon().url);
// Reset the history_handler to verify whether new icon is requested from
// history.
@@ -561,7 +561,7 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) {
ASSERT_EQ(new_icon_url, helper.current_candidate()->icon_url);
ASSERT_EQ(FaviconURL::FAVICON, helper.current_candidate()->icon_type);
// The favicon status's url should be updated.
- ASSERT_EQ(new_icon_url, helper.GetEntry()->favicon().url());
+ ASSERT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url);
// Favicon should be requested from history.
history_handler = helper.history_handler();
@@ -582,9 +582,9 @@ TEST_F(FaviconHandlerTest, UpdateFavicon) {
EXPECT_FALSE(helper.download_handler());
// Verify the favicon status.
- EXPECT_EQ(new_icon_url, helper.GetEntry()->favicon().url());
- EXPECT_TRUE(helper.GetEntry()->favicon().is_valid());
- EXPECT_FALSE(helper.GetEntry()->favicon().bitmap().empty());
+ EXPECT_EQ(new_icon_url, helper.GetEntry()->GetFavicon().url);
+ EXPECT_TRUE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_FALSE(helper.GetEntry()->GetFavicon().bitmap.empty());
}
TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) {
@@ -612,8 +612,8 @@ TEST_F(FaviconHandlerTest, Download2ndFaviconURLCandidate) {
// Send history response.
history_handler->InvokeCallback();
// Verify FaviconHandler status.
- EXPECT_FALSE(helper.GetEntry()->favicon().is_valid());
- EXPECT_EQ(GURL(), helper.GetEntry()->favicon().url());
+ EXPECT_FALSE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_EQ(GURL(), helper.GetEntry()->GetFavicon().url);
// Reset the history_handler to verify whether new icon is requested from
// history.
@@ -730,8 +730,8 @@ TEST_F(FaviconHandlerTest, UpdateDuringDownloading) {
// Send history response.
history_handler->InvokeCallback();
// Verify FaviconHandler status.
- EXPECT_FALSE(helper.GetEntry()->favicon().is_valid());
- EXPECT_EQ(GURL(), helper.GetEntry()->favicon().url());
+ EXPECT_FALSE(helper.GetEntry()->GetFavicon().valid);
+ EXPECT_EQ(GURL(), helper.GetEntry()->GetFavicon().url);
// Reset the history_handler to verify whether new icon is requested from
// history.
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc
index 282cf1c..88fe4a4 100644
--- a/chrome/browser/favicon/favicon_tab_helper.cc
+++ b/chrome/browser/favicon/favicon_tab_helper.cc
@@ -12,6 +12,7 @@
#include "chrome/common/icon_messages.h"
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/navigation_controller.h"
+#include "content/browser/tab_contents/navigation_entry.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/browser/webui/web_ui.h"
#include "content/public/browser/navigation_details.h"
@@ -20,6 +21,7 @@
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/image/image.h"
+using content::FaviconStatus;
using content::WebContents;
FaviconTabHelper::FaviconTabHelper(TabContents* tab_contents)
@@ -47,11 +49,11 @@ SkBitmap FaviconTabHelper::GetFavicon() const {
const NavigationController& controller = web_contents()->GetController();
NavigationEntry* entry = controller.GetTransientEntry();
if (entry)
- return entry->favicon().bitmap();
+ return entry->GetFavicon().bitmap;
entry = controller.GetLastCommittedEntry();
if (entry)
- return entry->favicon().bitmap();
+ return entry->GetFavicon().bitmap;
return SkBitmap();
}
@@ -59,11 +61,11 @@ bool FaviconTabHelper::FaviconIsValid() const {
const NavigationController& controller = web_contents()->GetController();
NavigationEntry* entry = controller.GetTransientEntry();
if (entry)
- return entry->favicon().is_valid();
+ return entry->GetFavicon().valid;
entry = controller.GetLastCommittedEntry();
if (entry)
- return entry->favicon().is_valid();
+ return entry->GetFavicon().valid;
return false;
}
@@ -97,15 +99,15 @@ void FaviconTabHelper::SaveFavicon() {
GetOriginalProfile()->GetFaviconService(Profile::IMPLICIT_ACCESS);
if (!service)
return;
- const NavigationEntry::FaviconStatus& favicon(entry->favicon());
- if (!favicon.is_valid() || favicon.url().is_empty() ||
- favicon.bitmap().empty()) {
+ const FaviconStatus& favicon(entry->GetFavicon());
+ if (!favicon.valid || favicon.url.is_empty() ||
+ favicon.bitmap.empty()) {
return;
}
std::vector<unsigned char> image_data;
- gfx::PNGCodec::EncodeBGRASkBitmap(favicon.bitmap(), false, &image_data);
+ gfx::PNGCodec::EncodeBGRASkBitmap(favicon.bitmap, false, &image_data);
service->SetFavicon(
- entry->GetURL(), favicon.url(), image_data, history::FAVICON);
+ entry->GetURL(), favicon.url, image_data, history::FAVICON);
}
int FaviconTabHelper::DownloadImage(const GURL& image_url,