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

Unified Diff: chrome/browser/views/options/cookies_view.cc

Issue 523139: Adds local storage nodes to cookie tree model and cookies view. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 years, 11 months 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/views/options/cookies_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/views/options/cookies_view.cc
===================================================================
--- chrome/browser/views/options/cookies_view.cc (revision 36995)
+++ chrome/browser/views/options/cookies_view.cc (working copy)
@@ -31,7 +31,6 @@
static const int kCookieInfoViewInsetSize = 3;
static const int kSearchFilterDelayMs = 500;
-
///////////////////////////////////////////////////////////////////////////////
// CookiesTreeView
// Overridden to handle Delete key presses
@@ -49,20 +48,19 @@
};
CookiesTreeView::CookiesTreeView(CookiesTreeModel* cookies_model) {
- SetModel(cookies_model);
- SetRootShown(false);
- SetEditable(false);
+ SetModel(cookies_model);
+ SetRootShown(false);
+ SetEditable(false);
}
void CookiesTreeView::RemoveSelectedItems() {
TreeModelNode* selected_node = GetSelectedNode();
if (selected_node) {
static_cast<CookiesTreeModel*>(model())->DeleteCookieNode(
- static_cast<CookieTreeCookieNode*>(GetSelectedNode()));
+ static_cast<CookieTreeNode*>(GetSelectedNode()));
}
}
-
///////////////////////////////////////////////////////////////////////////////
// CookieInfoView, public:
@@ -253,6 +251,123 @@
}
///////////////////////////////////////////////////////////////////////////////
+// LocalStorageInfoView, public:
+
+LocalStorageInfoView::LocalStorageInfoView()
+ : origin_label_(NULL),
+ origin_value_field_(NULL),
+ size_label_(NULL),
+ size_value_field_(NULL),
+ last_modified_label_(NULL),
+ last_modified_value_field_(NULL) {
+}
+
+LocalStorageInfoView::~LocalStorageInfoView() {
+}
+
+void LocalStorageInfoView::SetLocalStorageInfo(
+ const BrowsingDataLocalStorageHelper::LocalStorageInfo&
+ local_storage_info) {
+ origin_value_field_->SetText(UTF8ToWide(local_storage_info.origin));
+ size_value_field_->SetText(
+ FormatBytes(local_storage_info.size,
+ GetByteDisplayUnits(local_storage_info.size),
+ true));
+ last_modified_value_field_->SetText(
+ base::TimeFormatFriendlyDateAndTime(local_storage_info.last_modified));
+ EnableLocalStorageDisplay(true);
+}
+
+void LocalStorageInfoView::EnableLocalStorageDisplay(bool enabled) {
+ origin_value_field_->SetEnabled(enabled);
+ size_value_field_->SetEnabled(enabled);
+ last_modified_value_field_->SetEnabled(enabled);
+}
+
+void LocalStorageInfoView::ClearLocalStorageDisplay() {
+ std::wstring no_cookie_string =
+ l10n_util::GetString(IDS_COOKIES_COOKIE_NONESELECTED);
+ origin_value_field_->SetText(no_cookie_string);
+ size_value_field_->SetText(no_cookie_string);
+ last_modified_value_field_->SetText(no_cookie_string);
+ EnableLocalStorageDisplay(false);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// LocalStorageInfoView, views::View overrides:
+
+void LocalStorageInfoView::ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) {
+ if (is_add && child == this)
+ Init();
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// LocalStorageInfoView, private:
+
+void LocalStorageInfoView::Init() {
+ SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW);
+ views::Border* border = views::Border::CreateSolidBorder(
+ kCookieInfoViewBorderSize, border_color);
+ set_border(border);
+
+ origin_label_ = new views::Label(
+ l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL));
+ origin_value_field_ = new views::Textfield;
+ size_label_ = new views::Label(
+ l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL));
+ size_value_field_ = new views::Textfield;
+ last_modified_label_ = new views::Label(
+ l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL));
+ last_modified_value_field_ = new views::Textfield;
+
+ using views::GridLayout;
+ using views::ColumnSet;
+
+ GridLayout* layout = new GridLayout(this);
+ layout->SetInsets(kCookieInfoViewInsetSize,
+ kCookieInfoViewInsetSize,
+ kCookieInfoViewInsetSize,
+ kCookieInfoViewInsetSize);
+ SetLayoutManager(layout);
+
+ int three_column_layout_id = 0;
+ ColumnSet* column_set = layout->AddColumnSet(three_column_layout_id);
+ column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
+ GridLayout::USE_PREF, 0, 0);
+ column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
+ column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
+ GridLayout::USE_PREF, 0, 0);
+
+ layout->StartRow(0, three_column_layout_id);
+ layout->AddView(origin_label_);
+ layout->AddView(origin_value_field_);
+ layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
+ layout->StartRow(0, three_column_layout_id);
+ layout->AddView(size_label_);
+ layout->AddView(size_value_field_);
+ layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
+ layout->StartRow(0, three_column_layout_id);
+ layout->AddView(last_modified_label_);
+ layout->AddView(last_modified_value_field_);
+
+ // Color these borderless text areas the same as the containing dialog.
+ SkColor text_area_background = color_utils::GetSysSkColor(COLOR_3DFACE);
+ // Now that the Textfields are in the view hierarchy, we can initialize them.
+ origin_value_field_->SetReadOnly(true);
+ origin_value_field_->RemoveBorder();
+ origin_value_field_->SetBackgroundColor(text_area_background);
+ size_value_field_->SetReadOnly(true);
+ size_value_field_->RemoveBorder();
+ size_value_field_->SetBackgroundColor(text_area_background);
+ last_modified_value_field_->SetReadOnly(true);
+ last_modified_value_field_->RemoveBorder();
+ last_modified_value_field_->SetBackgroundColor(text_area_background);
+}
+
+
+///////////////////////////////////////////////////////////////////////////////
// CookiesView, public:
// static
@@ -371,10 +486,17 @@
static_cast<CookieTreeNode*>(tree_view->GetSelectedNode())->
GetDetailedInfo();
if (detailed_info.node_type == CookieTreeNode::DetailedInfo::TYPE_COOKIE) {
- info_view_->SetCookie(detailed_info.cookie->first,
- detailed_info.cookie->second);
+ UpdateVisibleDetailedInfo(cookie_info_view_);
+ cookie_info_view_->SetCookie(detailed_info.cookie->first,
+ detailed_info.cookie->second);
+ } else if (detailed_info.node_type ==
+ CookieTreeNode::DetailedInfo::TYPE_LOCAL_STORAGE) {
+ UpdateVisibleDetailedInfo(local_storage_info_view_);
+ local_storage_info_view_->SetLocalStorageInfo(
+ *detailed_info.local_storage_info);
} else {
- info_view_->ClearCookieDisplay();
+ UpdateVisibleDetailedInfo(cookie_info_view_);
+ cookie_info_view_->ClearCookieDisplay();
}
}
@@ -393,7 +515,8 @@
clear_search_button_(NULL),
description_label_(NULL),
cookies_tree_(NULL),
- info_view_(NULL),
+ cookie_info_view_(NULL),
+ local_storage_info_view_(NULL),
remove_button_(NULL),
remove_all_button_(NULL),
profile_(profile),
@@ -420,8 +543,10 @@
description_label_ = new views::Label(
l10n_util::GetString(IDS_COOKIES_INFO_LABEL));
description_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- cookies_tree_model_.reset(new CookiesTreeModel(profile_));
- info_view_ = new CookieInfoView;
+ cookies_tree_model_.reset(new CookiesTreeModel(
+ profile_, new BrowsingDataLocalStorageHelper(profile_)));
+ cookie_info_view_ = new CookieInfoView;
+ local_storage_info_view_ = new LocalStorageInfoView;
cookies_tree_ = new CookiesTreeView(cookies_tree_model_.get());
remove_button_ = new views::NativeButton(
this, l10n_util::GetString(IDS_COOKIES_REMOVE_LABEL));
@@ -469,14 +594,19 @@
layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
layout->StartRow(0, single_column_layout_id);
- layout->AddView(info_view_);
+ layout->AddView(cookie_info_view_, 1, 2);
+ layout->StartRow(0, single_column_layout_id);
+ layout->AddView(local_storage_info_view_);
+
// Add the Remove/Remove All buttons to the ClientView
View* parent = GetParent();
parent->AddChildView(remove_button_);
parent->AddChildView(remove_all_button_);
if (!cookies_tree_model_.get()->GetRoot()->GetChildCount())
UpdateForEmptyState();
+ else
+ UpdateVisibleDetailedInfo(cookie_info_view_);
}
void CookiesView::ResetSearchQuery() {
@@ -486,7 +616,15 @@
}
void CookiesView::UpdateForEmptyState() {
- info_view_->ClearCookieDisplay();
+ cookie_info_view_->ClearCookieDisplay();
remove_button_->SetEnabled(false);
remove_all_button_->SetEnabled(false);
+ UpdateVisibleDetailedInfo(cookie_info_view_);
}
+
+void CookiesView::UpdateVisibleDetailedInfo(views::View* view) {
+ view->SetVisible(true);
+ views::View* other = local_storage_info_view_;
+ if (view == local_storage_info_view_) other = cookie_info_view_;
+ other->SetVisible(false);
+}
« no previous file with comments | « chrome/browser/views/options/cookies_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698