OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/local_storage_info_view.h" | 5 #include "chrome/browser/ui/views/local_storage_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/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
12 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 13 #include "ui/base/text/bytes_formatting.h" |
13 #include "ui/gfx/color_utils.h" | 14 #include "ui/gfx/color_utils.h" |
14 #include "views/controls/label.h" | 15 #include "views/controls/label.h" |
15 #include "views/controls/textfield/textfield.h" | 16 #include "views/controls/textfield/textfield.h" |
16 #include "views/layout/grid_layout.h" | 17 #include "views/layout/grid_layout.h" |
17 #include "views/layout/layout_constants.h" | 18 #include "views/layout/layout_constants.h" |
18 | 19 |
19 static const int kLocalStorageInfoViewBorderSize = 1; | 20 static const int kLocalStorageInfoViewBorderSize = 1; |
20 static const int kLocalStorageInfoViewInsetSize = 3; | 21 static const int kLocalStorageInfoViewInsetSize = 3; |
21 | 22 |
22 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
23 // LocalStorageInfoView, public: | 24 // LocalStorageInfoView, public: |
24 | 25 |
25 LocalStorageInfoView::LocalStorageInfoView() | 26 LocalStorageInfoView::LocalStorageInfoView() |
26 : origin_value_field_(NULL), | 27 : origin_value_field_(NULL), |
27 size_value_field_(NULL), | 28 size_value_field_(NULL), |
28 last_modified_value_field_(NULL) { | 29 last_modified_value_field_(NULL) { |
29 } | 30 } |
30 | 31 |
31 LocalStorageInfoView::~LocalStorageInfoView() { | 32 LocalStorageInfoView::~LocalStorageInfoView() { |
32 } | 33 } |
33 | 34 |
34 void LocalStorageInfoView::SetLocalStorageInfo( | 35 void LocalStorageInfoView::SetLocalStorageInfo( |
35 const BrowsingDataLocalStorageHelper::LocalStorageInfo& | 36 const BrowsingDataLocalStorageHelper::LocalStorageInfo& |
36 local_storage_info) { | 37 local_storage_info) { |
37 origin_value_field_->SetText(UTF8ToWide(local_storage_info.origin)); | 38 origin_value_field_->SetText(UTF8ToWide(local_storage_info.origin)); |
38 size_value_field_->SetText( | 39 size_value_field_->SetText(ui::FormatBytes(local_storage_info.size)); |
39 FormatBytes(local_storage_info.size, | |
40 GetByteDisplayUnits(local_storage_info.size), | |
41 true)); | |
42 last_modified_value_field_->SetText( | 40 last_modified_value_field_->SetText( |
43 base::TimeFormatFriendlyDateAndTime(local_storage_info.last_modified)); | 41 base::TimeFormatFriendlyDateAndTime(local_storage_info.last_modified)); |
44 EnableLocalStorageDisplay(true); | 42 EnableLocalStorageDisplay(true); |
45 } | 43 } |
46 | 44 |
47 void LocalStorageInfoView::EnableLocalStorageDisplay(bool enabled) { | 45 void LocalStorageInfoView::EnableLocalStorageDisplay(bool enabled) { |
48 origin_value_field_->SetEnabled(enabled); | 46 origin_value_field_->SetEnabled(enabled); |
49 size_value_field_->SetEnabled(enabled); | 47 size_value_field_->SetEnabled(enabled); |
50 last_modified_value_field_->SetEnabled(enabled); | 48 last_modified_value_field_->SetEnabled(enabled); |
51 } | 49 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 origin_value_field_->RemoveBorder(); | 123 origin_value_field_->RemoveBorder(); |
126 origin_value_field_->SetBackgroundColor(text_area_background); | 124 origin_value_field_->SetBackgroundColor(text_area_background); |
127 size_value_field_->SetReadOnly(true); | 125 size_value_field_->SetReadOnly(true); |
128 size_value_field_->RemoveBorder(); | 126 size_value_field_->RemoveBorder(); |
129 size_value_field_->SetBackgroundColor(text_area_background); | 127 size_value_field_->SetBackgroundColor(text_area_background); |
130 last_modified_value_field_->SetReadOnly(true); | 128 last_modified_value_field_->SetReadOnly(true); |
131 last_modified_value_field_->RemoveBorder(); | 129 last_modified_value_field_->RemoveBorder(); |
132 last_modified_value_field_->SetBackgroundColor(text_area_background); | 130 last_modified_value_field_->SetBackgroundColor(text_area_background); |
133 } | 131 } |
134 | 132 |
OLD | NEW |