diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 02:06:55 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-13 02:06:55 +0000 |
commit | b0c54878d30128f0aad207bf80a24426d619a6ed (patch) | |
tree | 642f25894b352c7f7f58a1ed3a876d09b8174cf6 /chrome | |
parent | 2309775146992010901f711af529a2523706a208 (diff) | |
download | chromium_src-b0c54878d30128f0aad207bf80a24426d619a6ed.zip chromium_src-b0c54878d30128f0aad207bf80a24426d619a6ed.tar.gz chromium_src-b0c54878d30128f0aad207bf80a24426d619a6ed.tar.bz2 |
Gtk: update options "Open on startup" to match new behavior.
Also, change "use current" to allow new tab page.
BUG=43802
TEST=manual
Review URL: http://codereview.chromium.org/2012016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/custom_home_pages_table_model.cc | 24 | ||||
-rw-r--r-- | chrome/browser/custom_home_pages_table_model.h | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/list_store_favicon_loader.cc | 84 | ||||
-rw-r--r-- | chrome/browser/gtk/list_store_favicon_loader.h | 66 | ||||
-rw-r--r-- | chrome/browser/gtk/options/general_page_gtk.cc | 163 | ||||
-rw-r--r-- | chrome/browser/gtk/options/general_page_gtk.h | 32 | ||||
-rw-r--r-- | chrome/browser/views/options/general_page_view.cc | 26 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 2 |
8 files changed, 109 insertions, 292 deletions
diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc index 7b4675f..9f4aa95 100644 --- a/chrome/browser/custom_home_pages_table_model.cc +++ b/chrome/browser/custom_home_pages_table_model.cc @@ -8,8 +8,11 @@ #include "app/resource_bundle.h" #include "app/table_model_observer.h" #include "base/i18n/rtl.h" +#include "chrome/browser/browser.h" +#include "chrome/browser/browser_list.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" +#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/pref_names.h" #include "gfx/codec/png_codec.h" #include "grit/app_resources.h" @@ -66,6 +69,27 @@ void CustomHomePagesTableModel::Remove(int index) { observer_->OnItemsRemoved(index, 1); } +void CustomHomePagesTableModel::SetToCurrentlyOpenPages() { + // Remove the current entries. + while (RowCount()) + Remove(0); + + // And add all tabs for all open browsers with our profile. + int add_index = 0; + for (BrowserList::const_iterator browser_i = BrowserList::begin(); + browser_i != BrowserList::end(); ++browser_i) { + Browser* browser = *browser_i; + if (browser->profile() != profile_) + continue; // Skip incognito browsers. + + for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { + const GURL url = browser->GetTabContentsAt(tab_index)->GetURL(); + if (!url.is_empty()) + Add(add_index++, url); + } + } +} + std::vector<GURL> CustomHomePagesTableModel::GetURLs() { std::vector<GURL> urls(entries_.size()); for (size_t i = 0; i < entries_.size(); ++i) diff --git a/chrome/browser/custom_home_pages_table_model.h b/chrome/browser/custom_home_pages_table_model.h index dd2e1aa..b67c4b8 100644 --- a/chrome/browser/custom_home_pages_table_model.h +++ b/chrome/browser/custom_home_pages_table_model.h @@ -34,6 +34,10 @@ class CustomHomePagesTableModel : public TableModel { // Removes the entry at the specified index. void Remove(int index); + // Clears any entries and fills the list with pages currently opened in the + // browser. + void SetToCurrentlyOpenPages(); + // Returns the set of urls this model contains. std::vector<GURL> GetURLs(); diff --git a/chrome/browser/gtk/list_store_favicon_loader.cc b/chrome/browser/gtk/list_store_favicon_loader.cc deleted file mode 100644 index b86ad0c..0000000 --- a/chrome/browser/gtk/list_store_favicon_loader.cc +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/gtk/list_store_favicon_loader.h" - -#include <vector> - -#include "base/callback.h" -#include "chrome/browser/gtk/gtk_theme_provider.h" -#include "chrome/browser/profile.h" -#include "gfx/codec/png_codec.h" -#include "gfx/gtk_util.h" -#include "third_party/skia/include/core/SkBitmap.h" - -ListStoreFavIconLoader::ListStoreFavIconLoader( - GtkListStore* list_store, gint favicon_col, gint favicon_handle_col, - Profile* profile, CancelableRequestConsumer* consumer) - : list_store_(list_store), favicon_col_(favicon_col), - favicon_handle_col_(favicon_handle_col), profile_(profile), - consumer_(consumer), - default_favicon_(GtkThemeProvider::GetDefaultFavicon(true)) { -} - -ListStoreFavIconLoader::~ListStoreFavIconLoader() { -} - -void ListStoreFavIconLoader::LoadFaviconForRow(const GURL& url, - GtkTreeIter* iter) { - FaviconService* favicon_service = - profile_->GetFaviconService(Profile::EXPLICIT_ACCESS); - if (favicon_service) { - FaviconService::Handle handle = favicon_service->GetFaviconForURL( - url, consumer_, - NewCallback(this, &ListStoreFavIconLoader::OnGotFavIcon)); - gtk_list_store_set(list_store_, iter, - favicon_handle_col_, handle, - favicon_col_, default_favicon_, - -1); - } -} - -bool ListStoreFavIconLoader::GetRowByFavIconHandle( - FaviconService::Handle handle, GtkTreeIter* result_iter) { - GtkTreeIter iter; - gboolean valid = gtk_tree_model_get_iter_first( - GTK_TREE_MODEL(list_store_), &iter); - while (valid) { - gint row_handle; - gtk_tree_model_get(GTK_TREE_MODEL(list_store_), &iter, - favicon_handle_col_, &row_handle, - -1); - if (row_handle == handle) { - *result_iter = iter; - return true; - } - valid = gtk_tree_model_iter_next( - GTK_TREE_MODEL(list_store_), &iter); - } - return false; -} - -void ListStoreFavIconLoader::OnGotFavIcon( - FaviconService::Handle handle, bool know_fav_icon, - scoped_refptr<RefCountedMemory> image_data, bool is_expired, - GURL icon_url) { - GtkTreeIter iter; - if (!GetRowByFavIconHandle(handle, &iter)) - return; - gtk_list_store_set(list_store_, &iter, - favicon_handle_col_, 0, - -1); - if (know_fav_icon && image_data.get() && image_data->size()) { - SkBitmap icon; - if (gfx::PNGCodec::Decode(image_data->front(), - image_data->size(), &icon)) { - GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); - gtk_list_store_set(list_store_, &iter, - favicon_col_, pixbuf, - -1); - g_object_unref(pixbuf); - } - } -} diff --git a/chrome/browser/gtk/list_store_favicon_loader.h b/chrome/browser/gtk/list_store_favicon_loader.h deleted file mode 100644 index 8d68e3c..0000000 --- a/chrome/browser/gtk/list_store_favicon_loader.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_GTK_LIST_STORE_FAVICON_LOADER_H_ -#define CHROME_BROWSER_GTK_LIST_STORE_FAVICON_LOADER_H_ - -#include <gtk/gtk.h> - -#include "chrome/browser/favicon_service.h" -#include "googleurl/src/gurl.h" - -class Profile; - -// Handles loading favicons into a GDK_TYPE_PIXBUF column of a GtkListStore. -// The GtkListStore must also have a G_TYPE_INT column, passed as -// |favicon_handle_col|, which will be used internally by the loader. -// Note: this implementation will be inefficient if the GtkListStore has a large -// number of rows. -class ListStoreFavIconLoader { - public: - ListStoreFavIconLoader(GtkListStore* list_store, - gint favicon_col, - gint favicon_handle_col, - Profile* profile, - CancelableRequestConsumer* consumer); - - ~ListStoreFavIconLoader(); - - // Start loading the favicon for |url| into the row |iter|. - void LoadFaviconForRow(const GURL& url, GtkTreeIter* iter); - - private: - // Find a row from the GetFavIconForURL handle. Returns true if the row was - // found. - bool GetRowByFavIconHandle(FaviconService::Handle handle, - GtkTreeIter* result_iter); - - // Callback from FaviconService:::GetFavIconForURL - void OnGotFavIcon(FaviconService::Handle handle, bool know_fav_icon, - scoped_refptr<RefCountedMemory> image_data, bool is_expired, - GURL icon_url); - - // The list store we are loading favicons into. - GtkListStore* list_store_; - - // The index of the GDK_TYPE_PIXBUF column to receive the favicons. - gint favicon_col_; - - // The index of the G_TYPE_INT column used internally to track the - // FaviconService::Handle of each favicon request. - gint favicon_handle_col_; - - // The profile from which we will get the FaviconService. - Profile* profile_; - - // Used in loading favicons. - CancelableRequestConsumer* consumer_; - - // Default icon to show when one can't be found for the URL. - GdkPixbuf* default_favicon_; - - DISALLOW_COPY_AND_ASSIGN(ListStoreFavIconLoader); -}; - -#endif // CHROME_BROWSER_GTK_LIST_STORE_FAVICON_LOADER_H_ diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc index cccdcad..16a0a05 100644 --- a/chrome/browser/gtk/options/general_page_gtk.cc +++ b/chrome/browser/gtk/options/general_page_gtk.cc @@ -4,14 +4,16 @@ #include "chrome/browser/gtk/options/general_page_gtk.h" +#include <set> +#include <vector> + #include "app/l10n_util.h" #include "base/callback.h" -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_list.h" +#include "base/utf_string_conversions.h" +#include "chrome/browser/custom_home_pages_table_model.h" #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" #include "chrome/browser/gtk/gtk_util.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" @@ -19,10 +21,10 @@ #include "chrome/browser/profile.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/session_startup_pref.h" -#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/url_constants.h" +#include "gfx/gtk_util.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" @@ -37,11 +39,11 @@ const char kDefaultBrowserLabelColor[] = "008700"; // Color of the default browser text when Chromium is not the default browser const char kNotDefaultBrowserLabelColor[] = "870000"; -// Column ids for |startup_custom_pages_model_|. +// Column ids for |startup_custom_pages_store_|. enum { - COL_FAVICON_HANDLE, COL_FAVICON, COL_URL, + COL_TOOLTIP, COL_COUNT, }; @@ -141,7 +143,7 @@ void GeneralPageGtk::NotifyPrefChanged(const std::wstring* pref_name) { PrefService* prefs = profile()->GetPrefs(); const SessionStartupPref startup_pref = SessionStartupPref::GetStartupPref(prefs); - PopulateCustomUrlList(startup_pref.urls); + startup_custom_pages_table_model_->SetURLs(startup_pref.urls); } if (!pref_name || *pref_name == prefs::kHomePageIsNewTabPage) { @@ -216,18 +218,20 @@ GtkWidget* GeneralPageGtk::InitStartupGroup() { GTK_SHADOW_ETCHED_IN); gtk_container_add(GTK_CONTAINER(url_list_container), scroll_window); - startup_custom_pages_model_ = gtk_list_store_new(COL_COUNT, - G_TYPE_INT, + startup_custom_pages_store_ = gtk_list_store_new(COL_COUNT, GDK_TYPE_PIXBUF, + G_TYPE_STRING, G_TYPE_STRING); startup_custom_pages_tree_ = gtk_tree_view_new_with_model( - GTK_TREE_MODEL(startup_custom_pages_model_)); + GTK_TREE_MODEL(startup_custom_pages_store_)); gtk_container_add(GTK_CONTAINER(scroll_window), startup_custom_pages_tree_); - // Release |startup_custom_pages_model_| so that |startup_custom_pages_tree_| + // Release |startup_custom_pages_store_| so that |startup_custom_pages_tree_| // owns the model. - g_object_unref(startup_custom_pages_model_); + g_object_unref(startup_custom_pages_store_); + gtk_tree_view_set_tooltip_column(GTK_TREE_VIEW(startup_custom_pages_tree_), + COL_TOOLTIP); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(startup_custom_pages_tree_), FALSE); GtkTreeViewColumn* column = gtk_tree_view_column_new(); @@ -245,11 +249,12 @@ GtkWidget* GeneralPageGtk::InitStartupGroup() { GTK_SELECTION_MULTIPLE); g_signal_connect(startup_custom_pages_selection_, "changed", G_CALLBACK(OnStartupPagesSelectionChangedThunk), this); - favicon_loader_.reset(new ListStoreFavIconLoader(startup_custom_pages_model_, - COL_FAVICON, - COL_FAVICON_HANDLE, - profile(), - &fav_icon_consumer_)); + + startup_custom_pages_table_model_.reset( + new CustomHomePagesTableModel(profile())); + startup_custom_pages_table_adapter_.reset( + new gtk_tree::TableAdapter(this, startup_custom_pages_store_, + startup_custom_pages_table_model_.get())); GtkWidget* url_list_buttons = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); gtk_box_pack_end(GTK_BOX(url_list_container), url_list_buttons, @@ -497,106 +502,72 @@ void GeneralPageGtk::SaveStartupPref() { pref.type = SessionStartupPref::URLS; } - pref.urls = GetCustomUrlList(); + pref.urls = startup_custom_pages_table_model_->GetURLs(); SessionStartupPref::SetStartupPref(profile()->GetPrefs(), pref); } -void GeneralPageGtk::PopulateCustomUrlList(const std::vector<GURL>& urls) { - gtk_list_store_clear(startup_custom_pages_model_); - for (size_t i = 0; i < urls.size(); ++i) { - GtkTreeIter iter; - gtk_list_store_append(startup_custom_pages_model_, &iter); - PopulateCustomUrlRow(urls[i], &iter); - } -} - -void GeneralPageGtk::PopulateCustomUrlRow(const GURL& url, GtkTreeIter* iter) { - favicon_loader_->LoadFaviconForRow(url, iter); - gtk_list_store_set(startup_custom_pages_model_, iter, - COL_URL, url.spec().c_str(), +void GeneralPageGtk::SetColumnValues(int row, GtkTreeIter* iter) { + SkBitmap bitmap = startup_custom_pages_table_model_->GetIcon(row); + GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); + std::wstring text = startup_custom_pages_table_model_->GetText(row, 0); + std::string tooltip = + WideToUTF8(startup_custom_pages_table_model_->GetTooltip(row)); + gchar* escaped_tooltip = g_markup_escape_text(tooltip.c_str(), + tooltip.size()); + gtk_list_store_set(startup_custom_pages_store_, iter, + COL_FAVICON, pixbuf, + COL_URL, WideToUTF8(text).c_str(), + COL_TOOLTIP, escaped_tooltip, -1); + g_object_unref(pixbuf); + g_free(escaped_tooltip); } void GeneralPageGtk::SetCustomUrlListFromCurrentPages() { - std::vector<GURL> urls; - for (BrowserList::const_iterator browser_i = BrowserList::begin(); - browser_i != BrowserList::end(); ++browser_i) { - Browser* browser = *browser_i; - if (browser->profile() != profile()) - continue; // Only want entries for open profile. - - for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { - TabContents* tab = browser->GetTabContentsAt(tab_index); - if (tab->ShouldDisplayURL()) { - const GURL url = browser->GetTabContentsAt(tab_index)->GetURL(); - if (!url.is_empty()) - urls.push_back(url); - } - } - } - PopulateCustomUrlList(urls); + startup_custom_pages_table_model_->SetToCurrentlyOpenPages(); + SaveStartupPref(); } void GeneralPageGtk::OnAddCustomUrl(const GURL& url) { - GtkTreeIter iter; - if (gtk_tree_selection_count_selected_rows( - startup_custom_pages_selection_) == 1) { - GList* list = gtk_tree_selection_get_selected_rows( - startup_custom_pages_selection_, NULL); - GtkTreeIter sibling; - gtk_tree_model_get_iter(GTK_TREE_MODEL(startup_custom_pages_model_), - &sibling, static_cast<GtkTreePath*>(list->data)); - g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); - g_list_free(list); - - gtk_list_store_insert_before(startup_custom_pages_model_, - &iter, &sibling); - } else { - gtk_list_store_append(startup_custom_pages_model_, &iter); - } - PopulateCustomUrlRow(url, &iter); + std::set<int> indices; + gtk_tree::GetSelectedIndicies(startup_custom_pages_selection_, &indices); + int index; + if (indices.empty()) + index = startup_custom_pages_table_model_->RowCount(); + else + index = *indices.begin() + 1; + startup_custom_pages_table_model_->Add(index, url); + SaveStartupPref(); + + gtk_tree::SelectAndFocusRowNum(index, + GTK_TREE_VIEW(startup_custom_pages_tree_)); } void GeneralPageGtk::RemoveSelectedCustomUrls() { - GList* list = gtk_tree_selection_get_selected_rows( - startup_custom_pages_selection_, NULL); - std::vector<GtkTreeIter> selected_iters( - gtk_tree_selection_count_selected_rows(startup_custom_pages_selection_)); - GList* node; - size_t i; - for (i = 0, node = list; node != NULL; ++i, node = node->next) { - gtk_tree_model_get_iter(GTK_TREE_MODEL(startup_custom_pages_model_), - &selected_iters[i], - static_cast<GtkTreePath*>(node->data)); + std::set<int> indices; + gtk_tree::GetSelectedIndicies(startup_custom_pages_selection_, &indices); + + int selected_row = 0; + for (std::set<int>::reverse_iterator i = indices.rbegin(); + i != indices.rend(); ++i) { + startup_custom_pages_table_model_->Remove(*i); + selected_row = *i; } - g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); - g_list_free(list); - for (i = 0; i < selected_iters.size(); ++i) { - gtk_list_store_remove(startup_custom_pages_model_, &selected_iters[i]); - } SaveStartupPref(); -} -std::vector<GURL> GeneralPageGtk::GetCustomUrlList() const { - std::vector<GURL> urls; - GtkTreeIter iter; - gboolean valid = gtk_tree_model_get_iter_first( - GTK_TREE_MODEL(startup_custom_pages_model_), &iter); - while (valid) { - gchar* url_data; - gtk_tree_model_get(GTK_TREE_MODEL(startup_custom_pages_model_), &iter, - COL_URL, &url_data, - -1); - urls.push_back(GURL(url_data)); - g_free(url_data); - valid = gtk_tree_model_iter_next( - GTK_TREE_MODEL(startup_custom_pages_model_), &iter); + // Select the next row after the last row deleted, or the above item if the + // latest item was deleted or nothing when the table doesn't have any items. + int row_count = startup_custom_pages_table_model_->RowCount(); + if (selected_row >= row_count) + selected_row = row_count - 1; + if (selected_row >= 0) { + gtk_tree::SelectAndFocusRowNum(selected_row, + GTK_TREE_VIEW(startup_custom_pages_tree_)); } - return urls; } void GeneralPageGtk::OnTemplateURLModelChanged() { diff --git a/chrome/browser/gtk/options/general_page_gtk.h b/chrome/browser/gtk/options/general_page_gtk.h index 22885c3..e7139163 100644 --- a/chrome/browser/gtk/options/general_page_gtk.h +++ b/chrome/browser/gtk/options/general_page_gtk.h @@ -8,10 +8,9 @@ #include <gtk/gtk.h> #include <string> -#include <vector> #include "app/gtk_signal.h" -#include "chrome/browser/cancelable_request.h" +#include "chrome/browser/gtk/gtk_tree.h" #include "chrome/browser/options_page_base.h" #include "chrome/browser/pref_member.h" #include "chrome/browser/search_engines/template_url_model.h" @@ -19,12 +18,13 @@ #include "googleurl/src/gurl.h" class AccessibleWidgetHelper; +class CustomHomePagesTableModel; class Profile; -class ListStoreFavIconLoader; class GeneralPageGtk : public OptionsPageBase, public TemplateURLModelObserver, - public ShellIntegration::DefaultBrowserObserver { + public ShellIntegration::DefaultBrowserObserver, + public gtk_tree::TableAdapter::Delegate { public: explicit GeneralPageGtk(Profile* profile); ~GeneralPageGtk(); @@ -45,12 +45,6 @@ class GeneralPageGtk : public OptionsPageBase, // Saves the startup preference from the values in the ui void SaveStartupPref(); - // Fill the startup_custom_pages_model_ - void PopulateCustomUrlList(const std::vector<GURL>& urls); - - // Fill a single row in the startup_custom_pages_model_ - void PopulateCustomUrlRow(const GURL& url, GtkTreeIter *iter); - // Set the custom url list using the pages currently open void SetCustomUrlListFromCurrentPages(); @@ -62,9 +56,6 @@ class GeneralPageGtk : public OptionsPageBase, // Removes urls that are currently selected void RemoveSelectedCustomUrls(); - // Retrieve entries from the startup_custom_pages_model_ - std::vector<GURL> GetCustomUrlList() const; - // Overridden from TemplateURLModelObserver. // Populates the default search engine combobox from the model. virtual void OnTemplateURLModelChanged(); @@ -107,17 +98,24 @@ class GeneralPageGtk : public OptionsPageBase, virtual void SetDefaultBrowserUIState( ShellIntegration::DefaultBrowserUIState state); + // gtk_tree::TableAdapter::Delegate implementation. + virtual void SetColumnValues(int row, GtkTreeIter* iter); + // Widgets of the startup group GtkWidget* startup_homepage_radio_; GtkWidget* startup_last_session_radio_; GtkWidget* startup_custom_radio_; GtkWidget* startup_custom_pages_tree_; - GtkListStore* startup_custom_pages_model_; + GtkListStore* startup_custom_pages_store_; GtkTreeSelection* startup_custom_pages_selection_; GtkWidget* startup_add_custom_page_button_; GtkWidget* startup_remove_custom_page_button_; GtkWidget* startup_use_current_page_button_; + // The model for |startup_custom_pages_store_|. + scoped_ptr<CustomHomePagesTableModel> startup_custom_pages_table_model_; + scoped_ptr<gtk_tree::TableAdapter> startup_custom_pages_table_adapter_; + // Widgets and prefs of the homepage group GtkWidget* homepage_use_newtab_radio_; GtkWidget* homepage_use_url_radio_; @@ -147,12 +145,6 @@ class GeneralPageGtk : public OptionsPageBase, // then turning around and saving them again. bool initializing_; - // Used in loading favicons. - CancelableRequestConsumer fav_icon_consumer_; - - // Helper to load the favicon pixbufs into the |startup_custom_pages_model_|. - scoped_ptr<ListStoreFavIconLoader> favicon_loader_; - // The helper object that performs default browser set/check tasks. scoped_refptr<ShellIntegration::DefaultBrowserWorker> default_browser_worker_; diff --git a/chrome/browser/views/options/general_page_view.cc b/chrome/browser/views/options/general_page_view.cc index b287d81..cdc85be 100644 --- a/chrome/browser/views/options/general_page_view.cc +++ b/chrome/browser/views/options/general_page_view.cc @@ -9,8 +9,7 @@ #include "base/callback.h" #include "base/message_loop.h" #include "base/string_util.h" -#include "chrome/browser/browser.h" -#include "chrome/browser/browser_list.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/custom_home_pages_table_model.h" #include "chrome/browser/dom_ui/new_tab_ui.h" #include "chrome/browser/net/url_fixer_upper.h" @@ -19,7 +18,6 @@ #include "chrome/browser/session_startup_pref.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/browser/search_engines/template_url_model.h" -#include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/views/keyword_editor_view.h" #include "chrome/browser/views/options/options_group_view.h" #include "chrome/common/chrome_constants.h" @@ -720,27 +718,7 @@ void GeneralPageView::RemoveURLsFromStartupURLs() { } void GeneralPageView::SetStartupURLToCurrentPage() { - // Remove the current entries. - while (startup_custom_pages_table_model_->RowCount()) - startup_custom_pages_table_model_->Remove(0); - - // And add all entries for all open browsers with our profile. - int add_index = 0; - for (BrowserList::const_iterator browser_i = BrowserList::begin(); - browser_i != BrowserList::end(); ++browser_i) { - Browser* browser = *browser_i; - if (browser->profile() != profile()) - continue; // Only want entries for open profile. - - for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { - TabContents* tab = browser->GetTabContentsAt(tab_index); - if (tab->ShouldDisplayURL()) { - const GURL url = browser->GetTabContentsAt(tab_index)->GetURL(); - if (!url.is_empty()) - startup_custom_pages_table_model_->Add(add_index++, url); - } - } - } + startup_custom_pages_table_model_->SetToCurrentlyOpenPages(); SaveStartupPref(); } diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 946760e..9def079 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1304,8 +1304,6 @@ 'browser/gtk/infobar_gtk.h', 'browser/gtk/keyword_editor_view.cc', 'browser/gtk/keyword_editor_view.h', - 'browser/gtk/list_store_favicon_loader.cc', - 'browser/gtk/list_store_favicon_loader.h', 'browser/gtk/location_bar_view_gtk.cc', 'browser/gtk/location_bar_view_gtk.h', 'browser/gtk/menu_bar_helper.cc', |