OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/views/cookie_info_view.h" | 5 #include "chrome/browser/ui/views/cookie_info_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/time_formatting.h" | 9 #include "base/i18n/time_formatting.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/browsing_data/cookies_tree_model.h" | 14 #include "chrome/browser/browsing_data/cookies_tree_model.h" |
15 #include "chrome/grit/generated_resources.h" | 15 #include "chrome/grit/generated_resources.h" |
16 #include "chrome/grit/locale_settings.h" | 16 #include "chrome/grit/locale_settings.h" |
17 #include "net/cookies/canonical_cookie.h" | 17 #include "net/cookies/canonical_cookie.h" |
18 #include "net/cookies/parsed_cookie.h" | 18 #include "net/cookies/parsed_cookie.h" |
19 #include "third_party/skia/include/core/SkColor.h" | 19 #include "third_party/skia/include/core/SkColor.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/gfx/canvas.h" | 21 #include "ui/gfx/canvas.h" |
22 #include "ui/native_theme/native_theme.h" | 22 #include "ui/native_theme/native_theme.h" |
23 #include "ui/views/border.h" | 23 #include "ui/views/border.h" |
24 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
25 #include "ui/views/controls/textfield/textfield.h" | 25 #include "ui/views/controls/textfield/textfield.h" |
26 #include "ui/views/layout/grid_layout.h" | 26 #include "ui/views/layout/grid_layout.h" |
27 #include "ui/views/layout/layout_constants.h" | 27 #include "ui/views/layout/layout_constants.h" |
28 #include "ui/views/window/dialog_delegate.h" | 28 #include "ui/views/window/dialog_delegate.h" |
29 | 29 |
30 namespace { | |
31 | |
32 // Adjustment to the spacing between subsequent label-field lines. | |
33 const int kExtraLineHeightPadding = 3; | |
34 | |
35 } // namespace | |
36 | |
37 /////////////////////////////////////////////////////////////////////////////// | 30 /////////////////////////////////////////////////////////////////////////////// |
38 // CookieInfoView, public: | 31 // CookieInfoView, public: |
39 | 32 |
40 CookieInfoView::CookieInfoView() | 33 CookieInfoView::CookieInfoView() |
41 : name_label_(NULL), | 34 : name_label_(NULL), |
42 name_value_field_(NULL), | 35 name_value_field_(NULL), |
43 content_label_(NULL), | 36 content_label_(NULL), |
44 content_value_field_(NULL), | 37 content_value_field_(NULL), |
45 domain_label_(NULL), | 38 domain_label_(NULL), |
46 domain_value_field_(NULL), | 39 domain_value_field_(NULL), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 104 |
112 /////////////////////////////////////////////////////////////////////////////// | 105 /////////////////////////////////////////////////////////////////////////////// |
113 // CookieInfoView, views::View overrides. | 106 // CookieInfoView, views::View overrides. |
114 | 107 |
115 void CookieInfoView::ViewHierarchyChanged( | 108 void CookieInfoView::ViewHierarchyChanged( |
116 const ViewHierarchyChangedDetails& details) { | 109 const ViewHierarchyChangedDetails& details) { |
117 if (details.is_add && details.child == this) | 110 if (details.is_add && details.child == this) |
118 Init(); | 111 Init(); |
119 } | 112 } |
120 | 113 |
121 void CookieInfoView::AddLabelRow(int layout_id, views::GridLayout* layout, | 114 void CookieInfoView::AddLabelRow(int layout_id, |
| 115 views::GridLayout* layout, |
122 views::Label* label, | 116 views::Label* label, |
123 views::Textfield* text_field) { | 117 views::Textfield* textfield) { |
124 layout->StartRow(0, layout_id); | 118 layout->StartRow(0, layout_id); |
125 layout->AddView(label); | 119 layout->AddView(label); |
126 layout->AddView(text_field, 2, 1, views::GridLayout::FILL, | 120 layout->AddView( |
127 views::GridLayout::CENTER); | 121 textfield, 2, 1, views::GridLayout::FILL, views::GridLayout::CENTER); |
128 layout->AddPaddingRow(0, kExtraLineHeightPadding); | |
129 | 122 |
130 // Now that the Textfield is in the view hierarchy, it can be initialized. | 123 // Now that the Textfield is in the view hierarchy, it can be initialized. |
131 text_field->SetReadOnly(true); | 124 textfield->SetReadOnly(true); |
132 text_field->SetBorder(views::Border::NullBorder()); | 125 textfield->SetBorder(views::Border::NullBorder()); |
133 // Color these borderless text areas the same as the containing dialog. | 126 // Color these borderless text areas the same as the containing dialog. |
134 text_field->SetBackgroundColor(GetNativeTheme()->GetSystemColor( | 127 textfield->SetBackgroundColor(GetNativeTheme()->GetSystemColor( |
135 ui::NativeTheme::kColorId_DialogBackground)); | 128 ui::NativeTheme::kColorId_DialogBackground)); |
136 text_field->SetTextColor(SkColorSetRGB(0x78, 0x78, 0x78)); | 129 textfield->SetTextColor(SkColorSetRGB(0x78, 0x78, 0x78)); |
137 } | 130 } |
138 | 131 |
139 /////////////////////////////////////////////////////////////////////////////// | 132 /////////////////////////////////////////////////////////////////////////////// |
140 // CookieInfoView, private: | 133 // CookieInfoView, private: |
141 | 134 |
142 void CookieInfoView::Init() { | 135 void CookieInfoView::Init() { |
143 // Ensure we don't run this more than once and leak memory. | 136 // Ensure we don't run this more than once and leak memory. |
144 DCHECK(!name_label_); | 137 DCHECK(!name_label_); |
145 name_label_ = new views::Label( | 138 name_label_ = new views::Label( |
146 l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_NAME_LABEL)); | 139 l10n_util::GetStringUTF16(IDS_COOKIES_COOKIE_NAME_LABEL)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 AddLabelRow(three_column_layout_id, layout, domain_label_, | 178 AddLabelRow(three_column_layout_id, layout, domain_label_, |
186 domain_value_field_); | 179 domain_value_field_); |
187 AddLabelRow(three_column_layout_id, layout, path_label_, path_value_field_); | 180 AddLabelRow(three_column_layout_id, layout, path_label_, path_value_field_); |
188 AddLabelRow(three_column_layout_id, layout, send_for_label_, | 181 AddLabelRow(three_column_layout_id, layout, send_for_label_, |
189 send_for_value_field_); | 182 send_for_value_field_); |
190 AddLabelRow(three_column_layout_id, layout, created_label_, | 183 AddLabelRow(three_column_layout_id, layout, created_label_, |
191 created_value_field_); | 184 created_value_field_); |
192 AddLabelRow(three_column_layout_id, layout, expires_label_, | 185 AddLabelRow(three_column_layout_id, layout, expires_label_, |
193 expires_value_field_); | 186 expires_value_field_); |
194 } | 187 } |
OLD | NEW |