diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cookies_tree_model.cc | 25 | ||||
-rw-r--r-- | chrome/browser/cookies_tree_model.h | 5 | ||||
-rw-r--r-- | chrome/browser/gtk/collected_cookies_gtk.cc | 126 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_tree.cc | 4 | ||||
-rw-r--r-- | chrome/browser/gtk/gtk_tree.h | 21 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map.cc | 2 |
6 files changed, 22 insertions, 161 deletions
diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index 5f166d5..ed17c13 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -281,31 +281,6 @@ bool CookieTreeOriginNode::CanCreateContentException() const { return !url_.SchemeIsFile(); } -std::string CookieTreeOriginNode::GetCurrentContentSettingTitle( - HostContentSettingsMap* content_settings) const { - if (!CanCreateContentException()) - return std::string(); - - ContentSettings settings = - content_settings->GetNonDefaultContentSettings(url_); - switch (settings.settings[CONTENT_SETTINGS_TYPE_COOKIES]) { - case CONTENT_SETTING_ALLOW: - return l10n_util::GetStringUTF8(IDS_EXCEPTIONS_ALLOW_BUTTON); - case CONTENT_SETTING_BLOCK: - return l10n_util::GetStringUTF8(IDS_EXCEPTIONS_BLOCK_BUTTON); - case CONTENT_SETTING_ASK: - return l10n_util::GetStringUTF8(IDS_EXCEPTIONS_ASK_BUTTON); - case CONTENT_SETTING_SESSION_ONLY: - return l10n_util::GetStringUTF8(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); - case CONTENT_SETTING_DEFAULT: - return std::string(); - default: - NOTREACHED(); - } - - return std::string(); // not reached. -} - /////////////////////////////////////////////////////////////////////////////// // CookieTreeCookiesNode, public: diff --git a/chrome/browser/cookies_tree_model.h b/chrome/browser/cookies_tree_model.h index 3c6795d..faae9b5 100644 --- a/chrome/browser/cookies_tree_model.h +++ b/chrome/browser/cookies_tree_model.h @@ -168,11 +168,6 @@ class CookieTreeOriginNode : public CookieTreeNode { // True if a content exception can be created for this origin. bool CanCreateContentException() const; - // Returns a textual representation of the current content exception - // applying to this domain. - std::string GetCurrentContentSettingTitle( - HostContentSettingsMap* content_settings) const; - private: // Pointers to the cookies, databases, local and session storage and appcache // nodes. When we build up the tree we need to quickly get a reference to diff --git a/chrome/browser/gtk/collected_cookies_gtk.cc b/chrome/browser/gtk/collected_cookies_gtk.cc index de88a63..2992120 100644 --- a/chrome/browser/gtk/collected_cookies_gtk.cc +++ b/chrome/browser/gtk/collected_cookies_gtk.cc @@ -6,7 +6,6 @@ #include "app/l10n_util.h" #include "chrome/browser/cookies_tree_model.h" -#include "chrome/browser/gtk/gtk_theme_provider.h" #include "chrome/browser/gtk/gtk_util.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -14,68 +13,7 @@ #include "grit/generated_resources.h" namespace { -class CookiesTreeAdapter : public gtk_tree::TreeAdapter { - public: - // Column ids for the tree store. - enum { - COOKIES_COL_ICON, - COOKIES_COL_TITLE, - COOKIES_COL_NODE_PTR, - COOKIES_COL_SETTING, - COOKIES_COL_STYLE, - COOKIES_COL_COUNT, - }; - - CookiesTreeAdapter(Delegate* delegate, - TreeModel* tree_model, - HostContentSettingsMap* host_content_settings_map) - : TreeAdapter(delegate, tree_model), - host_content_settings_map_(host_content_settings_map) { - g_object_unref(tree_store_); - tree_store_ = gtk_tree_store_new(COOKIES_COL_COUNT, - GDK_TYPE_PIXBUF, - G_TYPE_STRING, - G_TYPE_POINTER, - G_TYPE_STRING, - PANGO_TYPE_STYLE); - } - - virtual ~CookiesTreeAdapter() {} - - private: - virtual void FillRow(GtkTreeIter* iter, TreeModelNode* node) { - GdkPixbuf* pixbuf = NULL; - int icon_index = tree_model_->GetIconIndex(node); - if (icon_index >= 0 && icon_index < static_cast<int>(pixbufs_.size())) - pixbuf = pixbufs_[icon_index]; - else - pixbuf = GtkThemeProvider::GetFolderIcon(true); - std::string setting; - CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node); - if (cookie_node->GetDetailedInfo().node_type == - CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { - CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>( - cookie_node); - setting = origin_node->GetCurrentContentSettingTitle( - host_content_settings_map_); - } - PangoStyle style = PANGO_STYLE_ITALIC; - gtk_tree_store_set(tree_store_, iter, - COOKIES_COL_ICON, pixbuf, - COOKIES_COL_TITLE, WideToUTF8(node->GetTitle()).c_str(), - COOKIES_COL_NODE_PTR, node, - COOKIES_COL_SETTING, setting.c_str(), - COOKIES_COL_STYLE, style, - -1); - } - - HostContentSettingsMap* host_content_settings_map_; - - DISALLOW_COPY_AND_ASSIGN(CookiesTreeAdapter); -}; - -// Widht and height of the cookie tree view. -const int kTreeViewWidth = 450; +// Height of the cookie tree view. const int kTreeViewHeight = 150; } // namespace @@ -91,9 +29,6 @@ CollectedCookiesGtk::CollectedCookiesGtk(GtkWindow* parent, } void CollectedCookiesGtk::Init() { - HostContentSettingsMap* host_content_settings_map = - tab_contents_->profile()->GetHostContentSettingsMap(); - dialog_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); gtk_box_set_spacing(GTK_BOX(dialog_), gtk_util::kContentAreaSpacing); @@ -125,12 +60,10 @@ void CollectedCookiesGtk::Init() { allowed_cookies_tree_model_.reset( content_settings->GetAllowedCookiesTreeModel()); allowed_cookies_tree_adapter_.reset( - new CookiesTreeAdapter(this, - allowed_cookies_tree_model_.get(), - host_content_settings_map)); + new gtk_tree::TreeAdapter(this, allowed_cookies_tree_model_.get())); allowed_tree_ = gtk_tree_view_new_with_model( GTK_TREE_MODEL(allowed_cookies_tree_adapter_->tree_store())); - gtk_widget_set_size_request(allowed_tree_, kTreeViewWidth, kTreeViewHeight); + gtk_widget_set_size_request(allowed_tree_, -1, kTreeViewHeight); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(allowed_tree_), FALSE); gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(allowed_tree_), TRUE); gtk_container_add(GTK_CONTAINER(scroll_window), allowed_tree_); @@ -139,24 +72,15 @@ void CollectedCookiesGtk::Init() { GtkCellRenderer* pixbuf_renderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(title_column, pixbuf_renderer, FALSE); gtk_tree_view_column_add_attribute(title_column, pixbuf_renderer, "pixbuf", - CookiesTreeAdapter::COOKIES_COL_ICON); + gtk_tree::TreeAdapter::COL_ICON); GtkCellRenderer* title_renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(title_column, title_renderer, TRUE); gtk_tree_view_column_add_attribute(title_column, title_renderer, "text", - CookiesTreeAdapter::COOKIES_COL_TITLE); + gtk_tree::TreeAdapter::COL_TITLE); gtk_tree_view_column_set_title( title_column, l10n_util::GetStringUTF8( IDS_COOKIES_DOMAIN_COLUMN_HEADER).c_str()); - gtk_tree_view_column_set_expand(title_column, TRUE); gtk_tree_view_append_column(GTK_TREE_VIEW(allowed_tree_), title_column); - GtkTreeViewColumn* setting_column = gtk_tree_view_column_new_with_attributes( - l10n_util::GetStringUTF8(IDS_EXCEPTIONS_ACTION_HEADER).c_str(), - gtk_cell_renderer_text_new(), - "text", CookiesTreeAdapter::COOKIES_COL_SETTING, - "style", CookiesTreeAdapter::COOKIES_COL_STYLE, - NULL); - gtk_tree_view_column_set_alignment(setting_column, 1); - gtk_tree_view_append_column(GTK_TREE_VIEW(allowed_tree_), setting_column); g_signal_connect(allowed_tree_, "row-expanded", G_CALLBACK(OnTreeViewRowExpandedThunk), this); allowed_selection_ = @@ -175,27 +99,15 @@ void CollectedCookiesGtk::Init() { G_CALLBACK(OnBlockAllowedButtonClickedThunk), this); gtk_container_add(GTK_CONTAINER(button_box), block_allowed_cookie_button_); - GtkWidget* separator = gtk_hseparator_new(); - gtk_box_pack_start(GTK_BOX(dialog_), separator, TRUE, TRUE, 0); - // Blocked Cookie list. cookie_list_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); gtk_box_pack_start(GTK_BOX(dialog_), cookie_list_vbox, TRUE, TRUE, 0); - if (host_content_settings_map->BlockThirdPartyCookies()) { - label = gtk_label_new( - l10n_util::GetStringUTF8( - IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED). - c_str()); - } else { - label = gtk_label_new( - l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL). - c_str()); - } - gtk_widget_set_size_request(label, kTreeViewWidth, -1); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); + label = gtk_label_new( + l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL). + c_str()); gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); - gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(cookie_list_vbox), label, FALSE, FALSE, 0); scroll_window = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_window), @@ -208,12 +120,10 @@ void CollectedCookiesGtk::Init() { blocked_cookies_tree_model_.reset( content_settings->GetBlockedCookiesTreeModel()); blocked_cookies_tree_adapter_.reset( - new CookiesTreeAdapter(this, - blocked_cookies_tree_model_.get(), - host_content_settings_map)); + new gtk_tree::TreeAdapter(this, blocked_cookies_tree_model_.get())); blocked_tree_ = gtk_tree_view_new_with_model( GTK_TREE_MODEL(blocked_cookies_tree_adapter_->tree_store())); - gtk_widget_set_size_request(blocked_tree_, kTreeViewWidth, kTreeViewHeight); + gtk_widget_set_size_request(blocked_tree_, -1, kTreeViewHeight); gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(blocked_tree_), FALSE); gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(blocked_tree_), TRUE); gtk_container_add(GTK_CONTAINER(scroll_window), blocked_tree_); @@ -222,24 +132,15 @@ void CollectedCookiesGtk::Init() { pixbuf_renderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(title_column, pixbuf_renderer, FALSE); gtk_tree_view_column_add_attribute(title_column, pixbuf_renderer, "pixbuf", - CookiesTreeAdapter::COL_ICON); + gtk_tree::TreeAdapter::COL_ICON); title_renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(title_column, title_renderer, TRUE); gtk_tree_view_column_add_attribute(title_column, title_renderer, "text", - CookiesTreeAdapter::COL_TITLE); + gtk_tree::TreeAdapter::COL_TITLE); gtk_tree_view_column_set_title( title_column, l10n_util::GetStringUTF8( IDS_COOKIES_DOMAIN_COLUMN_HEADER).c_str()); - gtk_tree_view_column_set_expand(title_column, TRUE); gtk_tree_view_append_column(GTK_TREE_VIEW(blocked_tree_), title_column); - setting_column = gtk_tree_view_column_new_with_attributes( - l10n_util::GetStringUTF8(IDS_EXCEPTIONS_ACTION_HEADER).c_str(), - gtk_cell_renderer_text_new(), - "text", CookiesTreeAdapter::COOKIES_COL_SETTING, - "style", CookiesTreeAdapter::COOKIES_COL_STYLE, - NULL); - gtk_tree_view_column_set_alignment(setting_column, 1); - gtk_tree_view_append_column(GTK_TREE_VIEW(blocked_tree_), setting_column); g_signal_connect(blocked_tree_, "row-expanded", G_CALLBACK(OnTreeViewRowExpandedThunk), this); blocked_selection_ = @@ -367,7 +268,6 @@ void CollectedCookiesGtk::AddExceptions(GtkTreeSelection* selection, if (node->CanCreateContentException()) { node->CreateContentException( tab_contents_->profile()->GetHostContentSettingsMap(), setting); - adapter->TreeNodeChanged(adapter->tree_model(), adapter->GetNode(&iter)); } } g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); diff --git a/chrome/browser/gtk/gtk_tree.cc b/chrome/browser/gtk/gtk_tree.cc index 303df11..eeb4511 100644 --- a/chrome/browser/gtk/gtk_tree.cc +++ b/chrome/browser/gtk/gtk_tree.cc @@ -158,8 +158,8 @@ void TableAdapter::OnItemsRemoved(int start, int length) { // TreeAdapter TreeAdapter::TreeAdapter(Delegate* delegate, TreeModel* tree_model) - : tree_model_(tree_model), - delegate_(delegate) { + : delegate_(delegate), + tree_model_(tree_model) { tree_store_ = gtk_tree_store_new(COL_COUNT, GDK_TYPE_PIXBUF, G_TYPE_STRING, diff --git a/chrome/browser/gtk/gtk_tree.h b/chrome/browser/gtk/gtk_tree.h index 550a992..a302bba 100644 --- a/chrome/browser/gtk/gtk_tree.h +++ b/chrome/browser/gtk/gtk_tree.h @@ -66,8 +66,8 @@ class TableAdapter : public TableModelObserver { }; // |table_model| may be NULL. - TableAdapter(Delegate* delegate, GtkListStore* list_store, - TableModel* table_model); + explicit TableAdapter(Delegate* delegate, GtkListStore* list_store, + TableModel* table_model); virtual ~TableAdapter() {} // Replace the TableModel with a different one. If the list store currenty @@ -127,9 +127,6 @@ class TreeAdapter : public TreeModelObserver { // Return the tree store. GtkTreeStore* tree_store() { return tree_store_; } - // Return the tree model. - TreeModel* tree_model() { return tree_model_; } - // Get the TreeModelNode corresponding to iter in the tree store. TreeModelNode* GetNode(GtkTreeIter* iter); @@ -145,15 +142,10 @@ class TreeAdapter : public TreeModelObserver { virtual void TreeNodeChanged(TreeModel* model, TreeModelNode* node); // End TreeModelObserver implementation. - protected: + private: // Fill the tree store values for a given node. - virtual void FillRow(GtkTreeIter* iter, TreeModelNode* node); - - GtkTreeStore* tree_store_; - TreeModel* tree_model_; - std::vector<GdkPixbuf*> pixbufs_; + void FillRow(GtkTreeIter* iter, TreeModelNode* node); - private: // Fill the tree store for a row and all its descendants. void Fill(GtkTreeIter* parent_iter, TreeModelNode* parent_node); @@ -165,8 +157,9 @@ class TreeAdapter : public TreeModelObserver { bool GetTreeIter(TreeModelNode* node, GtkTreeIter* iter); Delegate* delegate_; - - DISALLOW_COPY_AND_ASSIGN(TreeAdapter); + GtkTreeStore* tree_store_; + TreeModel* tree_model_; + std::vector<GdkPixbuf*> pixbufs_; }; } // namespace gtk_tree diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index cf7d98b..dabdc96 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -340,8 +340,6 @@ ContentSettings HostContentSettingsMap::GetContentSettings( const GURL& url) const { ContentSettings output = GetNonDefaultContentSettings(url); - AutoLock auto_lock(lock_); - // Make the remaining defaults explicit. for (int j = 0; j < CONTENT_SETTINGS_NUM_TYPES; ++j) if (output.settings[j] == CONTENT_SETTING_DEFAULT || |