summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-19 20:49:30 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-19 20:49:30 +0000
commitcf9e07811d9d198470ac73a6b84b0f0597854641 (patch)
tree1b50a1ca54cb886bfb908ffb0b5972bec2471fe7
parent7edf5b5462727c06c0232b541c5db549f176d84a (diff)
downloadchromium_src-cf9e07811d9d198470ac73a6b84b0f0597854641.zip
chromium_src-cf9e07811d9d198470ac73a6b84b0f0597854641.tar.gz
chromium_src-cf9e07811d9d198470ac73a6b84b0f0597854641.tar.bz2
Buttons for the collected cookies dialog to add content exceptions.
BUG=45230 TEST=CollectedCookiesTest.* Review URL: http://codereview.chromium.org/2808053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52950 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd9
-rw-r--r--chrome/browser/collected_cookies_uitest.cc6
-rw-r--r--chrome/browser/gtk/collected_cookies_gtk.cc125
-rw-r--r--chrome/browser/gtk/collected_cookies_gtk.h28
-rw-r--r--chrome/browser/views/collected_cookies_win.cc104
-rw-r--r--chrome/browser/views/collected_cookies_win.h27
6 files changed, 282 insertions, 17 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index a439920..3550b37 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6063,6 +6063,15 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_COLLECTED_COOKIES_BLOCKED_COOKIES_LABEL" desc="The label used to describe the cookies that were blocked">
The following cookies were blocked:
</message>
+ <message name="IDS_COLLECTED_COOKIES_ALLOW_BUTTON" desc="A button that lets the use create a content settings exception to allow certain domains.">
+ Allow
+ </message>
+ <message name="IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON" desc="A button that lets the use create a content settings exception to allow certain domains for a session only. Please consider that this text will be displayed as a button when translating.">
+ Allow for session only
+ </message>
+ <message name="IDS_COLLECTED_COOKIES_BLOCK_BUTTON" desc="A button that lets the use create a content settings exception to block certain domains.">
+ Block
+ </message>
<!-- Cookies Window -->
<message name="IDS_COOKIES_WINDOW_TITLE" desc="The title of the Cookies Window">
diff --git a/chrome/browser/collected_cookies_uitest.cc b/chrome/browser/collected_cookies_uitest.cc
index 44bcc16..cfd3b1e 100644
--- a/chrome/browser/collected_cookies_uitest.cc
+++ b/chrome/browser/collected_cookies_uitest.cc
@@ -21,7 +21,8 @@ const wchar_t kDocRoot[] = L"chrome/test/data";
typedef UITest CollectedCookiesTest;
-TEST_F(CollectedCookiesTest, FAILS_TestDoubleDisplay) {
+// Test is flaky. http://crbug.com/49539
+TEST_F(CollectedCookiesTest, FLAKY_DoubleDisplay) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(kDocRoot, NULL);
ASSERT_TRUE(NULL != server.get());
@@ -43,7 +44,8 @@ TEST_F(CollectedCookiesTest, FAILS_TestDoubleDisplay) {
ASSERT_TRUE(tab->ShowCollectedCookiesDialog());
}
-TEST_F(CollectedCookiesTest, FAILS_NavigateAway) {
+// Test is flaky. http://crbug.com/49539
+TEST_F(CollectedCookiesTest, FLAKY_NavigateAway) {
scoped_refptr<HTTPTestServer> server =
HTTPTestServer::CreateServer(kDocRoot, NULL);
ASSERT_TRUE(NULL != server.get());
diff --git a/chrome/browser/gtk/collected_cookies_gtk.cc b/chrome/browser/gtk/collected_cookies_gtk.cc
index a1bd94a..67830ad 100644
--- a/chrome/browser/gtk/collected_cookies_gtk.cc
+++ b/chrome/browser/gtk/collected_cookies_gtk.cc
@@ -8,6 +8,7 @@
#include "app/l10n_util.h"
#include "chrome/browser/cookies_tree_model.h"
#include "chrome/browser/gtk/gtk_util.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
@@ -83,6 +84,21 @@ void CollectedCookiesGtk::Init() {
gtk_tree_view_append_column(GTK_TREE_VIEW(allowed_tree_), title_column);
g_signal_connect(allowed_tree_, "row-expanded",
G_CALLBACK(OnTreeViewRowExpandedThunk), this);
+ allowed_selection_ =
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(allowed_tree_));
+ gtk_tree_selection_set_mode(allowed_selection_, GTK_SELECTION_MULTIPLE);
+ g_signal_connect(allowed_selection_, "changed",
+ G_CALLBACK(OnTreeViewSelectionChangeThunk), this);
+
+ GtkWidget* button_box = gtk_hbutton_box_new();
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_START);
+ gtk_box_set_spacing(GTK_BOX(button_box), gtk_util::kControlSpacing);
+ gtk_box_pack_start(GTK_BOX(dialog_), button_box, FALSE, FALSE, 0);
+ block_allowed_cookie_button_ = gtk_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_BLOCK_BUTTON).c_str());
+ g_signal_connect(block_allowed_cookie_button_, "clicked",
+ G_CALLBACK(OnBlockAllowedButtonClickedThunk), this);
+ gtk_container_add(GTK_CONTAINER(button_box), block_allowed_cookie_button_);
// Blocked Cookie list.
cookie_list_vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
@@ -128,9 +144,31 @@ void CollectedCookiesGtk::Init() {
gtk_tree_view_append_column(GTK_TREE_VIEW(blocked_tree_), title_column);
g_signal_connect(blocked_tree_, "row-expanded",
G_CALLBACK(OnTreeViewRowExpandedThunk), this);
+ blocked_selection_ =
+ gtk_tree_view_get_selection(GTK_TREE_VIEW(blocked_tree_));
+ gtk_tree_selection_set_mode(blocked_selection_, GTK_SELECTION_MULTIPLE);
+ g_signal_connect(blocked_selection_, "changed",
+ G_CALLBACK(OnTreeViewSelectionChangeThunk), this);
+
+ button_box = gtk_hbutton_box_new();
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_START);
+ gtk_box_set_spacing(GTK_BOX(button_box), gtk_util::kControlSpacing);
+ gtk_box_pack_start(GTK_BOX(dialog_), button_box, FALSE, FALSE, 0);
+ allow_blocked_cookie_button_ = gtk_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_ALLOW_BUTTON).c_str());
+ g_signal_connect(allow_blocked_cookie_button_, "clicked",
+ G_CALLBACK(OnAllowBlockedButtonClickedThunk), this);
+ gtk_container_add(GTK_CONTAINER(button_box), allow_blocked_cookie_button_);
+ for_session_blocked_cookie_button_ = gtk_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON).
+ c_str());
+ g_signal_connect(for_session_blocked_cookie_button_, "clicked",
+ G_CALLBACK(OnForSessionBlockedButtonClickedThunk), this);
+ gtk_container_add(GTK_CONTAINER(button_box),
+ for_session_blocked_cookie_button_);
// Close button.
- GtkWidget* button_box = gtk_hbutton_box_new();
+ button_box = gtk_hbutton_box_new();
gtk_button_box_set_layout(GTK_BUTTON_BOX(button_box), GTK_BUTTONBOX_END);
gtk_box_set_spacing(GTK_BOX(button_box), gtk_util::kControlSpacing);
gtk_box_pack_end(GTK_BOX(dialog_), button_box, FALSE, TRUE, 0);
@@ -143,6 +181,7 @@ void CollectedCookiesGtk::Init() {
// Show the dialog.
allowed_cookies_tree_adapter_->Init();
blocked_cookies_tree_adapter_->Init();
+ EnableControls();
window_ = tab_contents_->CreateConstrainedDialog(this);
}
@@ -158,6 +197,50 @@ void CollectedCookiesGtk::DeleteDelegate() {
delete this;
}
+bool CollectedCookiesGtk::SelectionContainsOriginNode(
+ GtkTreeSelection* selection, gtk_tree::TreeAdapter* adapter) {
+ // Check whether at least one "origin" node is selected.
+ GtkTreeModel* model;
+ GList* paths =
+ gtk_tree_selection_get_selected_rows(selection, &model);
+ bool contains_origin_node = false;
+ for (GList* item = paths; item; item = item->next) {
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter(
+ model, &iter, reinterpret_cast<GtkTreePath*>(item->data));
+ CookieTreeNode* node =
+ static_cast<CookieTreeNode*>(adapter->GetNode(&iter));
+ if (node->GetDetailedInfo().node_type !=
+ CookieTreeNode::DetailedInfo::TYPE_ORIGIN)
+ continue;
+ CookieTreeOriginNode* origin_node = static_cast<CookieTreeOriginNode*>(
+ node);
+ if (!origin_node->CanCreateContentException())
+ continue;
+ contains_origin_node = true;
+ }
+ g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL);
+ g_list_free(paths);
+ return contains_origin_node;
+}
+
+void CollectedCookiesGtk::EnableControls() {
+ // Update button states.
+ bool enable_for_allowed_cookies =
+ SelectionContainsOriginNode(allowed_selection_,
+ allowed_cookies_tree_adapter_.get());
+ gtk_widget_set_sensitive(block_allowed_cookie_button_,
+ enable_for_allowed_cookies);
+
+ bool enable_for_blocked_cookies =
+ SelectionContainsOriginNode(blocked_selection_,
+ blocked_cookies_tree_adapter_.get());
+ gtk_widget_set_sensitive(allow_blocked_cookie_button_,
+ enable_for_blocked_cookies);
+ gtk_widget_set_sensitive(for_session_blocked_cookie_button_,
+ enable_for_blocked_cookies);
+}
+
void CollectedCookiesGtk::Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
@@ -171,6 +254,42 @@ void CollectedCookiesGtk::OnClose(GtkWidget* close_button) {
window_->CloseConstrainedWindow();
}
+void CollectedCookiesGtk::AddExceptions(GtkTreeSelection* selection,
+ gtk_tree::TreeAdapter* adapter,
+ ContentSetting setting) {
+ GtkTreeModel* model;
+ GList* paths =
+ gtk_tree_selection_get_selected_rows(selection, &model);
+ for (GList* item = paths; item; item = item->next) {
+ GtkTreeIter iter;
+ gtk_tree_model_get_iter(
+ model, &iter, reinterpret_cast<GtkTreePath*>(item->data));
+ CookieTreeOriginNode* node = static_cast<CookieTreeOriginNode*>(
+ adapter->GetNode(&iter));
+ if (!node->CanCreateContentException()) {
+ node->CreateContentException(
+ tab_contents_->profile()->GetHostContentSettingsMap(), setting);
+ }
+ }
+ g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL);
+ g_list_free(paths);
+}
+
+void CollectedCookiesGtk::OnBlockAllowedButtonClicked(GtkWidget* button) {
+ AddExceptions(allowed_selection_, allowed_cookies_tree_adapter_.get(),
+ CONTENT_SETTING_BLOCK);
+}
+
+void CollectedCookiesGtk::OnAllowBlockedButtonClicked(GtkWidget* button) {
+ AddExceptions(blocked_selection_, blocked_cookies_tree_adapter_.get(),
+ CONTENT_SETTING_ALLOW);
+}
+
+void CollectedCookiesGtk::OnForSessionBlockedButtonClicked(GtkWidget* button) {
+ AddExceptions(blocked_selection_, blocked_cookies_tree_adapter_.get(),
+ CONTENT_SETTING_SESSION_ONLY);
+}
+
void CollectedCookiesGtk::OnTreeViewRowExpanded(GtkWidget* tree_view,
GtkTreeIter* iter,
GtkTreePath* path) {
@@ -181,3 +300,7 @@ void CollectedCookiesGtk::OnTreeViewRowExpanded(GtkWidget* tree_view,
g_signal_handlers_unblock_by_func(
tree_view, reinterpret_cast<gpointer>(OnTreeViewRowExpandedThunk), this);
}
+
+void CollectedCookiesGtk::OnTreeViewSelectionChange(GtkWidget* selection) {
+ EnableControls();
+}
diff --git a/chrome/browser/gtk/collected_cookies_gtk.h b/chrome/browser/gtk/collected_cookies_gtk.h
index 0691d06..2d8f2a0 100644
--- a/chrome/browser/gtk/collected_cookies_gtk.h
+++ b/chrome/browser/gtk/collected_cookies_gtk.h
@@ -13,6 +13,7 @@
#include "base/scoped_ptr.h"
#include "chrome/browser/gtk/constrained_window_gtk.h"
#include "chrome/browser/gtk/gtk_tree.h"
+#include "chrome/common/content_settings.h"
#include "chrome/common/notification_registrar.h"
class CookiesTreeModel;
@@ -34,8 +35,21 @@ class CollectedCookiesGtk : public ConstrainedDialogDelegate,
private:
virtual ~CollectedCookiesGtk();
+ // Initialize all widgets of this dialog.
void Init();
+ // True if the selection contains at least one origin node.
+ bool SelectionContainsOriginNode(GtkTreeSelection* selection,
+ gtk_tree::TreeAdapter* adapter);
+
+ // Enable the allow/block buttons if at least one origin node is selected.
+ void EnableControls();
+
+ // Add exceptions for all origin nodes within the selection.
+ void AddExceptions(GtkTreeSelection* selection,
+ gtk_tree::TreeAdapter* adapter,
+ ContentSetting setting);
+
// Notification Observer implementation.
void Observe(NotificationType type,
const NotificationSource& source,
@@ -44,7 +58,12 @@ class CollectedCookiesGtk : public ConstrainedDialogDelegate,
// Callbacks.
CHROMEGTK_CALLBACK_2(CollectedCookiesGtk, void, OnTreeViewRowExpanded,
GtkTreeIter*, GtkTreePath*);
+ CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnTreeViewSelectionChange);
CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnClose);
+ CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnBlockAllowedButtonClicked);
+ CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void, OnAllowBlockedButtonClicked);
+ CHROMEGTK_CALLBACK_0(CollectedCookiesGtk, void,
+ OnForSessionBlockedButtonClicked);
NotificationRegistrar registrar_;
@@ -56,12 +75,17 @@ class CollectedCookiesGtk : public ConstrainedDialogDelegate,
GtkWidget* allowed_description_label_;
GtkWidget* blocked_description_label_;
+ GtkWidget* block_allowed_cookie_button_;
+
+ GtkWidget* allow_blocked_cookie_button_;
+ GtkWidget* for_session_blocked_cookie_button_;
+
// The table listing the cookies.
GtkWidget* allowed_tree_;
GtkWidget* blocked_tree_;
- GtkWidget* allowed_cookie_display_;
- GtkWidget* blocked_cookie_display_;
+ GtkTreeSelection* allowed_selection_;
+ GtkTreeSelection* blocked_selection_;
// The tab contents.
TabContents* tab_contents_;
diff --git a/chrome/browser/views/collected_cookies_win.cc b/chrome/browser/views/collected_cookies_win.cc
index b5e5c3c..1a7f405 100644
--- a/chrome/browser/views/collected_cookies_win.cc
+++ b/chrome/browser/views/collected_cookies_win.cc
@@ -6,12 +6,13 @@
#include "app/l10n_util.h"
#include "chrome/browser/cookies_tree_model.h"
+#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "views/controls/label.h"
-#include "views/controls/tree/tree_view.h"
+#include "views/controls/button/native_button.h"
#include "views/standard_layout.h"
#include "views/window/window.h"
@@ -32,7 +33,14 @@ void ShowCollectedCookiesDialog(gfx::NativeWindow parent_window,
CollectedCookiesWin::CollectedCookiesWin(gfx::NativeWindow parent_window,
TabContents* tab_contents)
- : tab_contents_(tab_contents) {
+ : tab_contents_(tab_contents),
+ allowed_label_(NULL),
+ blocked_label_(NULL),
+ allowed_cookies_tree_(NULL),
+ blocked_cookies_tree_(NULL),
+ block_allowed_button_(NULL),
+ allow_blocked_button_(NULL),
+ for_session_blocked_button_(NULL) {
TabSpecificContentSettings* content_settings =
tab_contents->GetTabSpecificContentSettings();
registrar_.Add(this, NotificationType::COLLECTED_COOKIES_SHOWN,
@@ -59,6 +67,7 @@ void CollectedCookiesWin::Init() {
content_settings->GetAllowedCookiesTreeModel());
allowed_cookies_tree_ = new views::TreeView();
allowed_cookies_tree_->SetModel(allowed_cookies_tree_model_.get());
+ allowed_cookies_tree_->SetController(this);
allowed_cookies_tree_->SetRootShown(false);
allowed_cookies_tree_->SetEditable(false);
allowed_cookies_tree_->set_lines_at_root(true);
@@ -71,6 +80,7 @@ void CollectedCookiesWin::Init() {
content_settings->GetBlockedCookiesTreeModel());
blocked_cookies_tree_ = new views::TreeView();
blocked_cookies_tree_->SetModel(blocked_cookies_tree_model_.get());
+ blocked_cookies_tree_->SetController(this);
blocked_cookies_tree_->SetRootShown(false);
blocked_cookies_tree_->SetEditable(false);
blocked_cookies_tree_->set_lines_at_root(true);
@@ -86,6 +96,14 @@ void CollectedCookiesWin::Init() {
column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
+ const int three_columns_layout_id = 1;
+ column_set = layout->AddColumnSet(three_columns_layout_id);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
+ GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
+ GridLayout::USE_PREF, 0, 0);
+
layout->StartRow(0, single_column_layout_id);
layout->AddView(allowed_label_);
@@ -93,6 +111,13 @@ void CollectedCookiesWin::Init() {
layout->StartRow(1, single_column_layout_id);
layout->AddView(
allowed_cookies_tree_, 1, 1, GridLayout::FILL, GridLayout::FILL);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ layout->StartRow(0, single_column_layout_id);
+ block_allowed_button_ = new views::NativeButton(
+ this, l10n_util::GetString(IDS_COLLECTED_COOKIES_BLOCK_BUTTON));
+ layout->AddView(
+ block_allowed_button_, 1, 1, GridLayout::LEADING, GridLayout::CENTER);
layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
layout->StartRow(0, single_column_layout_id);
@@ -102,10 +127,21 @@ void CollectedCookiesWin::Init() {
layout->StartRow(1, single_column_layout_id);
layout->AddView(
blocked_cookies_tree_, 1, 1, GridLayout::FILL, GridLayout::FILL);
+ layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
+
+ layout->StartRow(0, three_columns_layout_id);
+ allow_blocked_button_ = new views::NativeButton(
+ this, l10n_util::GetString(IDS_COLLECTED_COOKIES_ALLOW_BUTTON));
+ layout->AddView(allow_blocked_button_);
+ for_session_blocked_button_ = new views::NativeButton(
+ this, l10n_util::GetString(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON));
+ layout->AddView(for_session_blocked_button_);
+
+ EnableControls();
}
///////////////////////////////////////////////////////////////////////////////
-// views::DialogDelegate implementation.
+// ConstrainedDialogDelegate implementation.
std::wstring CollectedCookiesWin::GetWindowTitle() const {
return l10n_util::GetString(IDS_COLLECTED_COOKIES_DIALOG_TITLE);
@@ -128,14 +164,32 @@ bool CollectedCookiesWin::Cancel() {
return true;
}
-///////////////////////////////////////////////////////////////////////////////
-// views::WindowDelegate implementation.
-
views::View* CollectedCookiesWin::GetContentsView() {
return this;
}
///////////////////////////////////////////////////////////////////////////////
+// views::ButtonListener implementation.
+
+void CollectedCookiesWin::ButtonPressed(views::Button* sender,
+ const views::Event& event) {
+ if (sender == block_allowed_button_)
+ AddContentException(allowed_cookies_tree_, CONTENT_SETTING_BLOCK);
+ else if (sender == allow_blocked_button_)
+ AddContentException(blocked_cookies_tree_, CONTENT_SETTING_ALLOW);
+ else if (sender == for_session_blocked_button_)
+ AddContentException(blocked_cookies_tree_, CONTENT_SETTING_SESSION_ONLY);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// views::View implementation.
+
+void CollectedCookiesWin::OnTreeViewSelectionChanged(
+ views::TreeView* tree_view) {
+ EnableControls();
+}
+
+///////////////////////////////////////////////////////////////////////////////
// views::View implementation.
gfx::Size CollectedCookiesWin::GetPreferredSize() {
@@ -145,6 +199,44 @@ gfx::Size CollectedCookiesWin::GetPreferredSize() {
}
///////////////////////////////////////////////////////////////////////////////
+// CollectedCookiesWin, private methods.
+
+void CollectedCookiesWin::EnableControls() {
+ bool enable_allowed_buttons = false;
+ TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode();
+ if (node) {
+ CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node);
+ if (cookie_node->GetDetailedInfo().node_type ==
+ CookieTreeNode::DetailedInfo::TYPE_ORIGIN) {
+ enable_allowed_buttons = static_cast<CookieTreeOriginNode*>(
+ cookie_node)->CanCreateContentException();
+ }
+ }
+ block_allowed_button_->SetEnabled(enable_allowed_buttons);
+
+ bool enable_blocked_buttons = false;
+ node = blocked_cookies_tree_->GetSelectedNode();
+ if (node) {
+ CookieTreeNode* cookie_node = static_cast<CookieTreeNode*>(node);
+ if (cookie_node->GetDetailedInfo().node_type ==
+ CookieTreeNode::DetailedInfo::TYPE_ORIGIN) {
+ enable_blocked_buttons = static_cast<CookieTreeOriginNode*>(
+ cookie_node)->CanCreateContentException();
+ }
+ }
+ allow_blocked_button_->SetEnabled(enable_blocked_buttons);
+ for_session_blocked_button_->SetEnabled(enable_blocked_buttons);
+}
+
+void CollectedCookiesWin::AddContentException(views::TreeView* tree_view,
+ ContentSetting setting) {
+ CookieTreeOriginNode* origin_node =
+ static_cast<CookieTreeOriginNode*>(tree_view->GetSelectedNode());
+ origin_node->CreateContentException(
+ tab_contents_->profile()->GetHostContentSettingsMap(), setting);
+}
+
+///////////////////////////////////////////////////////////////////////////////
// NotificationObserver implementation.
void CollectedCookiesWin::Observe(NotificationType type,
diff --git a/chrome/browser/views/collected_cookies_win.h b/chrome/browser/views/collected_cookies_win.h
index 16b5f89..fc33d3c 100644
--- a/chrome/browser/views/collected_cookies_win.h
+++ b/chrome/browser/views/collected_cookies_win.h
@@ -8,7 +8,9 @@
#define CHROME_BROWSER_VIEWS_COLLECTED_COOKIES_WIN_H_
#include "chrome/browser/tab_contents/constrained_window.h"
+#include "chrome/common/content_settings.h"
#include "chrome/common/notification_registrar.h"
+#include "views/controls/tree/tree_view.h"
#include "views/window/dialog_delegate.h"
class ConstrainedWindow;
@@ -16,7 +18,7 @@ class CookiesTreeModel;
class TabContents;
namespace views {
class Label;
-class TreeView;
+class NativeButton;
}
// CollectedCookiesWin is a dialog that displays the allowed and blocked
@@ -25,32 +27,41 @@ class TreeView;
class CollectedCookiesWin : public ConstrainedDialogDelegate,
NotificationObserver,
+ views::ButtonListener,
+ views::TreeViewController,
views::View {
public:
// Use BrowserWindow::ShowCollectedCookiesDialog to show.
CollectedCookiesWin(gfx::NativeWindow parent_window,
TabContents* tab_contents);
- // views::DialogDelegate implementation.
+ // ConstrainedDialogDelegate implementation.
virtual std::wstring GetWindowTitle() const;
virtual int GetDialogButtons() const;
virtual std::wstring GetDialogButtonLabel(
MessageBoxFlags::DialogButton button) const;
virtual void DeleteDelegate();
-
virtual bool Cancel();
-
- // views::WindowDelegate implementation.
virtual views::View* GetContentsView();
+ // views::ButtonListener implementation.
+ virtual void ButtonPressed(views::Button* sender, const views::Event& event);
+
+ // views::TreeViewController implementation.
+ virtual void OnTreeViewSelectionChanged(views::TreeView* tree_view);
+
// views::View implementation.
- gfx::Size GetPreferredSize();
+ virtual gfx::Size GetPreferredSize();
private:
virtual ~CollectedCookiesWin();
void Init();
+ void EnableControls();
+
+ void AddContentException(views::TreeView* tree_view, ContentSetting setting);
+
// Notification Observer implementation.
void Observe(NotificationType type,
const NotificationSource& source,
@@ -70,6 +81,10 @@ class CollectedCookiesWin : public ConstrainedDialogDelegate,
views::TreeView* allowed_cookies_tree_;
views::TreeView* blocked_cookies_tree_;
+ views::NativeButton* block_allowed_button_;
+ views::NativeButton* allow_blocked_button_;
+ views::NativeButton* for_session_blocked_button_;
+
scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_;
scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_;