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

Unified Diff: chrome/browser/tab_contents/tab_contents.cc

Issue 5753007: Make us save favicon in incognito mode if the url is bookmarked. This (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/chrome
Patch Set: Merged and renamed method 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/tab_contents.cc
diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc
index 4215528e02daaaa2cc4c9f02be2f7ca7fbceb11d..2c482a291ffc1e0d07f69adb83af767864a01dab 100644
--- a/chrome/browser/tab_contents/tab_contents.cc
+++ b/chrome/browser/tab_contents/tab_contents.cc
@@ -40,6 +40,7 @@
#include "chrome/browser/download/download_request_limiter.h"
#include "chrome/browser/external_protocol_handler.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/history/history.h"
#include "chrome/browser/history/history_types.h"
#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/host_zoom_map.h"
@@ -99,6 +100,7 @@
#include "chrome/common/render_messages_params.h"
#include "chrome/common/renderer_preferences.h"
#include "chrome/common/url_constants.h"
+#include "gfx/codec/png_codec.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -971,6 +973,33 @@ void TabContents::ShowPageInfo(const GURL& url,
delegate_->ShowPageInfo(profile(), url, ssl, show_history);
}
+void TabContents::SaveFavicon() {
+ NavigationEntry* entry = controller_.GetActiveEntry();
+ if (!entry || entry->url().is_empty())
+ return;
+
+ // Make sure the page is in history, otherwise adding the favicon does
+ // nothing.
+ HistoryService* history = profile()->GetOriginalProfile()->GetHistoryService(
+ Profile::IMPLICIT_ACCESS);
+ if (!history)
+ return;
+ history->AddPageNoVisitForBookmark(entry->url());
+
+ FaviconService* service = profile()->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()) {
+ return;
+ }
+ std::vector<unsigned char> image_data;
+ gfx::PNGCodec::EncodeBGRASkBitmap(favicon.bitmap(), false, &image_data);
+ service->SetFavicon(entry->url(), favicon.url(), image_data);
+}
+
ConstrainedWindow* TabContents::CreateConstrainedDialog(
ConstrainedWindowDelegate* delegate) {
ConstrainedWindow* window =
« no previous file with comments | « chrome/browser/tab_contents/tab_contents.h ('k') | chrome/browser/ui/browser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698