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

Side by Side Diff: chrome/browser/views/local_storage_set_item_info_view.cc

Issue 597061: Make the setItem CONTENT_SETTING_ASK dialog more useful by showing the actual... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/local_storage_info_view.h" 5 #include "chrome/browser/views/local_storage_set_item_info_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "app/gfx/color_utils.h" 9 #include "app/gfx/color_utils.h"
10 #include "app/l10n_util.h" 10 #include "app/l10n_util.h"
11 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/string_util.h" 12 #include "base/string_util.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "views/grid_layout.h" 14 #include "views/grid_layout.h"
15 #include "views/controls/label.h" 15 #include "views/controls/label.h"
16 #include "views/controls/textfield/textfield.h" 16 #include "views/controls/textfield/textfield.h"
17 #include "views/standard_layout.h" 17 #include "views/standard_layout.h"
18 18
19 static const int kLocalStorageInfoViewBorderSize = 1; 19 static const int kLocalStorageSetItemInfoViewBorderSize = 1;
20 static const int kLocalStorageInfoViewInsetSize = 3; 20 static const int kLocalStorageSetItemInfoViewInsetSize = 3;
21 21
22 /////////////////////////////////////////////////////////////////////////////// 22 ///////////////////////////////////////////////////////////////////////////////
23 // LocalStorageInfoView, public: 23 // LocalStorageSetItemInfoView, public:
24 24
25 LocalStorageInfoView::LocalStorageInfoView() 25 LocalStorageSetItemInfoView::LocalStorageSetItemInfoView()
26 : origin_value_field_(NULL), 26 : host_value_field_(NULL),
27 size_value_field_(NULL), 27 key_value_field_(NULL),
28 last_modified_value_field_(NULL) { 28 value_value_field_(NULL) {
29 } 29 }
30 30
31 LocalStorageInfoView::~LocalStorageInfoView() { 31 LocalStorageSetItemInfoView::~LocalStorageSetItemInfoView() {
32 } 32 }
33 33
34 void LocalStorageInfoView::SetLocalStorageInfo( 34 void LocalStorageSetItemInfoView::SetFields(const std::string& host,
35 const BrowsingDataLocalStorageHelper::LocalStorageInfo& 35 const string16& key,
36 local_storage_info) { 36 const string16& value) {
37 origin_value_field_->SetText(UTF8ToWide(local_storage_info.origin)); 37 host_value_field_->SetText(UTF8ToWide(host));
38 size_value_field_->SetText( 38 key_value_field_->SetText(key);
39 FormatBytes(local_storage_info.size, 39 value_value_field_->SetText(value);
40 GetByteDisplayUnits(local_storage_info.size),
41 true));
42 last_modified_value_field_->SetText(
43 base::TimeFormatFriendlyDateAndTime(local_storage_info.last_modified));
44 EnableLocalStorageDisplay(true); 40 EnableLocalStorageDisplay(true);
45 } 41 }
46 42
47 void LocalStorageInfoView::EnableLocalStorageDisplay(bool enabled) { 43 void LocalStorageSetItemInfoView::EnableLocalStorageDisplay(bool enabled) {
48 origin_value_field_->SetEnabled(enabled); 44 host_value_field_->SetEnabled(enabled);
49 size_value_field_->SetEnabled(enabled); 45 key_value_field_->SetEnabled(enabled);
50 last_modified_value_field_->SetEnabled(enabled); 46 value_value_field_->SetEnabled(enabled);
51 } 47 }
52 48
53 void LocalStorageInfoView::ClearLocalStorageDisplay() { 49 void LocalStorageSetItemInfoView::ClearLocalStorageDisplay() {
54 std::wstring no_cookie_string = 50 std::wstring no_cookie_string =
55 l10n_util::GetString(IDS_COOKIES_COOKIE_NONESELECTED); 51 l10n_util::GetString(IDS_COOKIES_COOKIE_NONESELECTED);
56 origin_value_field_->SetText(no_cookie_string); 52 host_value_field_->SetText(no_cookie_string);
57 size_value_field_->SetText(no_cookie_string); 53 key_value_field_->SetText(no_cookie_string);
58 last_modified_value_field_->SetText(no_cookie_string); 54 value_value_field_->SetText(no_cookie_string);
59 EnableLocalStorageDisplay(false); 55 EnableLocalStorageDisplay(false);
60 } 56 }
61 57
62 /////////////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////////////
63 // LocalStorageInfoView, views::View overrides: 59 // LocalStorageSetItemInfoView, views::View overrides:
64 60
65 void LocalStorageInfoView::ViewHierarchyChanged(bool is_add, 61 void LocalStorageSetItemInfoView::ViewHierarchyChanged(bool is_add,
66 views::View* parent, 62 views::View* parent,
67 views::View* child) { 63 views::View* child) {
68 if (is_add && child == this) 64 if (is_add && child == this)
69 Init(); 65 Init();
70 } 66 }
71 67
72 /////////////////////////////////////////////////////////////////////////////// 68 ///////////////////////////////////////////////////////////////////////////////
73 // LocalStorageInfoView, private: 69 // LocalStorageSetItemInfoView, private:
74 70
75 void LocalStorageInfoView::Init() { 71 void LocalStorageSetItemInfoView::Init() {
76 SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW); 72 SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW);
77 views::Border* border = views::Border::CreateSolidBorder( 73 views::Border* border = views::Border::CreateSolidBorder(
78 kLocalStorageInfoViewBorderSize, border_color); 74 kLocalStorageSetItemInfoViewBorderSize, border_color);
79 set_border(border); 75 set_border(border);
80 76
81 views::Label* origin_label = new views::Label( 77 // TODO(jorlow): These strings are not quite right, but we're post-freeze.
82 l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL)); 78 views::Label* host_label = new views::Label(
83 origin_value_field_ = new views::Textfield; 79 l10n_util::GetString(IDS_COOKIES_COOKIE_DOMAIN_LABEL));
84 views::Label* size_label = new views::Label( 80 host_value_field_ = new views::Textfield;
85 l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL)); 81 views::Label* key_label = new views::Label(
86 size_value_field_ = new views::Textfield; 82 l10n_util::GetString(IDS_COOKIES_COOKIE_NAME_LABEL));
87 views::Label* last_modified_label = new views::Label( 83 key_value_field_ = new views::Textfield;
88 l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL)); 84 views::Label* value_label = new views::Label(
89 last_modified_value_field_ = new views::Textfield; 85 l10n_util::GetString(IDS_COOKIES_COOKIE_CONTENT_LABEL));
86 value_value_field_ = new views::Textfield;
90 87
91 using views::GridLayout; 88 using views::GridLayout;
92 89
93 GridLayout* layout = new GridLayout(this); 90 GridLayout* layout = new GridLayout(this);
94 layout->SetInsets(kLocalStorageInfoViewInsetSize, 91 layout->SetInsets(kLocalStorageSetItemInfoViewInsetSize,
95 kLocalStorageInfoViewInsetSize, 92 kLocalStorageSetItemInfoViewInsetSize,
96 kLocalStorageInfoViewInsetSize, 93 kLocalStorageSetItemInfoViewInsetSize,
97 kLocalStorageInfoViewInsetSize); 94 kLocalStorageSetItemInfoViewInsetSize);
98 SetLayoutManager(layout); 95 SetLayoutManager(layout);
99 96
100 int three_column_layout_id = 0; 97 int three_column_layout_id = 0;
101 views::ColumnSet* column_set = layout->AddColumnSet(three_column_layout_id); 98 views::ColumnSet* column_set = layout->AddColumnSet(three_column_layout_id);
102 column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0, 99 column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
103 GridLayout::USE_PREF, 0, 0); 100 GridLayout::USE_PREF, 0, 0);
104 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); 101 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
105 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, 102 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
106 GridLayout::USE_PREF, 0, 0); 103 GridLayout::USE_PREF, 0, 0);
107 104
108 layout->StartRow(0, three_column_layout_id); 105 layout->StartRow(0, three_column_layout_id);
109 layout->AddView(origin_label); 106 layout->AddView(host_label);
110 layout->AddView(origin_value_field_); 107 layout->AddView(host_value_field_);
111 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); 108 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
112 layout->StartRow(0, three_column_layout_id); 109 layout->StartRow(0, three_column_layout_id);
113 layout->AddView(size_label); 110 layout->AddView(key_label);
114 layout->AddView(size_value_field_); 111 layout->AddView(key_value_field_);
115 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); 112 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
116 layout->StartRow(0, three_column_layout_id); 113 layout->StartRow(0, three_column_layout_id);
117 layout->AddView(last_modified_label); 114 layout->AddView(value_label);
118 layout->AddView(last_modified_value_field_); 115 layout->AddView(value_value_field_);
119 116
120 // Color these borderless text areas the same as the containing dialog. 117 // Color these borderless text areas the same as the containing dialog.
121 SkColor text_area_background = color_utils::GetSysSkColor(COLOR_3DFACE); 118 SkColor text_area_background = color_utils::GetSysSkColor(COLOR_3DFACE);
122 // Now that the Textfields are in the view hierarchy, we can initialize them. 119 // Now that the Textfields are in the view hierarchy, we can initialize them.
123 origin_value_field_->SetReadOnly(true); 120 host_value_field_->SetReadOnly(true);
124 origin_value_field_->RemoveBorder(); 121 host_value_field_->RemoveBorder();
125 origin_value_field_->SetBackgroundColor(text_area_background); 122 host_value_field_->SetBackgroundColor(text_area_background);
126 size_value_field_->SetReadOnly(true); 123 key_value_field_->SetReadOnly(true);
127 size_value_field_->RemoveBorder(); 124 key_value_field_->RemoveBorder();
128 size_value_field_->SetBackgroundColor(text_area_background); 125 key_value_field_->SetBackgroundColor(text_area_background);
129 last_modified_value_field_->SetReadOnly(true); 126 value_value_field_->SetReadOnly(true);
130 last_modified_value_field_->RemoveBorder(); 127 value_value_field_->RemoveBorder();
131 last_modified_value_field_->SetBackgroundColor(text_area_background); 128 value_value_field_->SetBackgroundColor(text_area_background);
132 } 129 }
133 130
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698