summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk/options/general_page_gtk.cc
diff options
context:
space:
mode:
authormattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 18:23:34 +0000
committermattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-22 18:23:34 +0000
commiteec14db8dd65f57aedea891a99b9fee6944d3f6a (patch)
tree8204a5ced1827741b3969957d03895c732b504b5 /chrome/browser/gtk/options/general_page_gtk.cc
parent63329059634643cb573b323aa03b9fdeda555bd4 (diff)
downloadchromium_src-eec14db8dd65f57aedea891a99b9fee6944d3f6a.zip
chromium_src-eec14db8dd65f57aedea891a99b9fee6944d3f6a.tar.gz
chromium_src-eec14db8dd65f57aedea891a99b9fee6944d3f6a.tar.bz2
Refactor the favicon loader out of gtk/options/general_page_gtk to gtk/list_store_favicon_loader,
so that it can be used by the url_picker_dialog_gtk as well. BUG=11507 Review URL: http://codereview.chromium.org/141035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/options/general_page_gtk.cc')
-rw-r--r--chrome/browser/gtk/options/general_page_gtk.cc75
1 files changed, 7 insertions, 68 deletions
diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc
index 589f8ea..8f5055b 100644
--- a/chrome/browser/gtk/options/general_page_gtk.cc
+++ b/chrome/browser/gtk/options/general_page_gtk.cc
@@ -5,12 +5,10 @@
#include "chrome/browser/gtk/options/general_page_gtk.h"
#include "app/l10n_util.h"
-#include "app/resource_bundle.h"
-#include "base/gfx/gtk_util.h"
-#include "base/gfx/png_decoder.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/gtk/keyword_editor_view.h"
+#include "chrome/browser/gtk/list_store_favicon_loader.h"
#include "chrome/browser/gtk/options/options_layout_gtk.h"
#include "chrome/browser/gtk/options/url_picker_dialog_gtk.h"
#include "chrome/browser/net/url_fixer_upper.h"
@@ -22,7 +20,6 @@
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/url_constants.h"
-#include "grit/app_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -199,9 +196,6 @@ GtkWidget* GeneralPageGtk::InitStartupGroup() {
gtk_util::kControlSpacing);
gtk_box_pack_start(GTK_BOX(vbox), url_list_container, TRUE, TRUE, 0);
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- default_favicon_ = rb.GetPixbufNamed(IDR_DEFAULT_FAVICON);
-
GtkWidget* scroll_window = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window),
GTK_POLICY_AUTOMATIC,
@@ -235,6 +229,11 @@ GtkWidget* GeneralPageGtk::InitStartupGroup() {
GTK_SELECTION_MULTIPLE);
g_signal_connect(G_OBJECT(startup_custom_pages_selection_), "changed",
G_CALLBACK(OnStartupPagesSelectionChanged), this);
+ favicon_loader_.reset(new ListStoreFavIconLoader(startup_custom_pages_model_,
+ COL_FAVICON,
+ COL_FAVICON_HANDLE,
+ profile(),
+ &fav_icon_consumer_));
GtkWidget* url_list_buttons = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
gtk_box_pack_end(GTK_BOX(url_list_container), url_list_buttons,
@@ -515,72 +514,12 @@ void GeneralPageGtk::PopulateCustomUrlList(const std::vector<GURL>& urls) {
}
void GeneralPageGtk::PopulateCustomUrlRow(const GURL& url, GtkTreeIter* iter) {
- HistoryService* history =
- profile()->GetHistoryService(Profile::EXPLICIT_ACCESS);
- HistoryService::Handle handle(0);
- if (history) {
- handle = history->GetFavIconForURL(
- url, &fav_icon_consumer_,
- NewCallback(this, &GeneralPageGtk::OnGotFavIcon));
- }
+ favicon_loader_->LoadFaviconForRow(url, iter);
gtk_list_store_set(startup_custom_pages_model_, iter,
- COL_FAVICON_HANDLE, handle,
- COL_FAVICON, default_favicon_,
COL_URL, url.spec().c_str(),
-1);
}
-bool GeneralPageGtk::GetRowByFavIconHandle(HistoryService::Handle handle,
- GtkTreeIter* result_iter) {
- GtkTreeIter iter;
- gboolean valid = gtk_tree_model_get_iter_first(
- GTK_TREE_MODEL(startup_custom_pages_model_), &iter);
- while (valid) {
- gint row_handle;
- gtk_tree_model_get(GTK_TREE_MODEL(startup_custom_pages_model_), &iter,
- COL_FAVICON_HANDLE, &row_handle,
- -1);
- if (row_handle == handle) {
- *result_iter = iter;
- return true;
- }
- valid = gtk_tree_model_iter_next(
- GTK_TREE_MODEL(startup_custom_pages_model_), &iter);
- }
- return false;
-}
-
-void GeneralPageGtk::OnGotFavIcon(HistoryService::Handle handle,
- bool know_fav_icon,
- scoped_refptr<RefCountedBytes> image_data,
- bool is_expired,
- GURL icon_url) {
- GtkTreeIter iter;
- if (!GetRowByFavIconHandle(handle, &iter))
- return;
- gtk_list_store_set(startup_custom_pages_model_, &iter,
- COL_FAVICON_HANDLE, 0,
- -1);
- if (know_fav_icon && image_data.get() && !image_data->data.empty()) {
- int width, height;
- std::vector<unsigned char> decoded_data;
- if (PNGDecoder::Decode(&image_data->data.front(), image_data->data.size(),
- PNGDecoder::FORMAT_BGRA, &decoded_data, &width,
- &height)) {
- SkBitmap icon;
- icon.setConfig(SkBitmap::kARGB_8888_Config, width, height);
- icon.allocPixels();
- memcpy(icon.getPixels(), &decoded_data.front(),
- width * height * 4);
- GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon);
- gtk_list_store_set(startup_custom_pages_model_, &iter,
- COL_FAVICON, pixbuf,
- -1);
- g_object_unref(pixbuf);
- }
- }
-}
-
void GeneralPageGtk::SetCustomUrlListFromCurrentPages() {
std::vector<GURL> urls;
for (BrowserList::const_iterator browser_i = BrowserList::begin();