| Index: chrome/browser/views/appcache_info_view.cc
 | 
| ===================================================================
 | 
| --- chrome/browser/views/appcache_info_view.cc	(revision 39380)
 | 
| +++ chrome/browser/views/appcache_info_view.cc	(working copy)
 | 
| @@ -2,7 +2,7 @@
 | 
|  // Use of this source code is governed by a BSD-style license that can be
 | 
|  // found in the LICENSE file.
 | 
|  
 | 
| -#include "chrome/browser/views/local_storage_info_view.h"
 | 
| +#include "chrome/browser/views/appcache_info_view.h"
 | 
|  
 | 
|  #include <algorithm>
 | 
|  
 | 
| @@ -16,118 +16,121 @@
 | 
|  #include "views/controls/textfield/textfield.h"
 | 
|  #include "views/standard_layout.h"
 | 
|  
 | 
| -static const int kLocalStorageInfoViewBorderSize = 1;
 | 
| -static const int kLocalStorageInfoViewInsetSize = 3;
 | 
| -
 | 
|  ///////////////////////////////////////////////////////////////////////////////
 | 
| -// LocalStorageInfoView, public:
 | 
| +// AppCacheInfoView, public:
 | 
|  
 | 
| -LocalStorageInfoView::LocalStorageInfoView()
 | 
| -    : origin_value_field_(NULL),
 | 
| -      size_value_field_(NULL),
 | 
| -      last_modified_value_field_(NULL) {
 | 
| +AppCacheInfoView::AppCacheInfoView()
 | 
| +    : manifest_url_field_(NULL),
 | 
| +      size_field_(NULL),
 | 
| +      creation_date_field_(NULL),
 | 
| +      last_access_field_(NULL) {
 | 
|  }
 | 
|  
 | 
| -LocalStorageInfoView::~LocalStorageInfoView() {
 | 
| +AppCacheInfoView::~AppCacheInfoView() {
 | 
|  }
 | 
|  
 | 
| -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 AppCacheInfoView::SetAppCacheInfo(
 | 
| +    const BrowsingDataAppCacheHelper::AppCacheInfo* info) {
 | 
| +  DCHECK(info);
 | 
| +  manifest_url_field_->SetText(UTF8ToWide(info->manifest_url.spec()));
 | 
| +  size_field_->SetText(
 | 
| +      FormatBytes(info->size, GetByteDisplayUnits(info->size), true));
 | 
| +  creation_date_field_->SetText(
 | 
| +      base::TimeFormatFriendlyDateAndTime(info->creation_time));
 | 
| +  last_access_field_->SetText(
 | 
| +      base::TimeFormatFriendlyDateAndTime(info->last_access_time));
 | 
| +  EnableAppCacheDisplay(true);
 | 
|  }
 | 
|  
 | 
| -void LocalStorageInfoView::EnableLocalStorageDisplay(bool enabled) {
 | 
| -  origin_value_field_->SetEnabled(enabled);
 | 
| -  size_value_field_->SetEnabled(enabled);
 | 
| -  last_modified_value_field_->SetEnabled(enabled);
 | 
| +void AppCacheInfoView::EnableAppCacheDisplay(bool enabled) {
 | 
| +  manifest_url_field_->SetEnabled(enabled);
 | 
| +  size_field_->SetEnabled(enabled);
 | 
| +  creation_date_field_->SetEnabled(enabled);
 | 
| +  last_access_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);
 | 
| +void AppCacheInfoView::ClearAppCacheDisplay() {
 | 
| +  const string16 kEmpty;
 | 
| +  manifest_url_field_->SetText(kEmpty);
 | 
| +  size_field_->SetText(kEmpty);
 | 
| +  creation_date_field_->SetText(kEmpty);
 | 
| +  last_access_field_->SetText(kEmpty);
 | 
| +  EnableAppCacheDisplay(false);
 | 
|  }
 | 
|  
 | 
|  ///////////////////////////////////////////////////////////////////////////////
 | 
| -// LocalStorageInfoView, views::View overrides:
 | 
| +// AppCacheInfoView, views::View overrides:
 | 
|  
 | 
| -void LocalStorageInfoView::ViewHierarchyChanged(bool is_add,
 | 
| -                                                views::View* parent,
 | 
| -                                                views::View* child) {
 | 
| +void AppCacheInfoView::ViewHierarchyChanged(bool is_add,
 | 
| +                                            views::View* parent,
 | 
| +                                            views::View* child) {
 | 
|    if (is_add && child == this)
 | 
|      Init();
 | 
|  }
 | 
|  
 | 
|  ///////////////////////////////////////////////////////////////////////////////
 | 
| -// LocalStorageInfoView, private:
 | 
| +// AppCacheInfoView, private:
 | 
|  
 | 
| -void LocalStorageInfoView::Init() {
 | 
| +
 | 
| +void AppCacheInfoView::Init() {
 | 
| +  const int kInfoViewBorderSize = 1;
 | 
| +  const int kInfoViewInsetSize = 3;
 | 
| +  const int kLayoutId = 0;
 | 
| +
 | 
|    SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW);
 | 
|    views::Border* border = views::Border::CreateSolidBorder(
 | 
| -      kLocalStorageInfoViewBorderSize, border_color);
 | 
| +      kInfoViewBorderSize, border_color);
 | 
|    set_border(border);
 | 
|  
 | 
| -  views::Label* origin_label = new views::Label(
 | 
| -      l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_ORIGIN_LABEL));
 | 
| -  origin_value_field_ = new views::Textfield;
 | 
| +  views::Label* manifest_url_label = new views::Label(
 | 
| +      l10n_util::GetString(IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL));
 | 
| +  manifest_url_field_ = new views::Textfield;
 | 
|    views::Label* size_label = new views::Label(
 | 
| -      l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_SIZE_ON_DISK_LABEL));
 | 
| -  size_value_field_ = new views::Textfield;
 | 
| -  views::Label* last_modified_label = new views::Label(
 | 
| -      l10n_util::GetString(IDS_COOKIES_LOCAL_STORAGE_LAST_MODIFIED_LABEL));
 | 
| -  last_modified_value_field_ = new views::Textfield;
 | 
| +      l10n_util::GetString(IDS_COOKIES_SIZE_LABEL));
 | 
| +  size_field_ = new views::Textfield;
 | 
| +  views::Label* creation_date_label = new views::Label(
 | 
| +      l10n_util::GetString(IDS_COOKIES_COOKIE_CREATED_LABEL));
 | 
| +  creation_date_field_ = new views::Textfield;
 | 
| +  views::Label* last_access_label = new views::Label(
 | 
| +      l10n_util::GetString(IDS_COOKIES_LAST_ACCESSED_LABEL));
 | 
| +  last_access_field_ = new views::Textfield;
 | 
|  
 | 
|    using views::GridLayout;
 | 
|  
 | 
|    GridLayout* layout = new GridLayout(this);
 | 
| -  layout->SetInsets(kLocalStorageInfoViewInsetSize,
 | 
| -                    kLocalStorageInfoViewInsetSize,
 | 
| -                    kLocalStorageInfoViewInsetSize,
 | 
| -                    kLocalStorageInfoViewInsetSize);
 | 
| +  layout->SetInsets(kInfoViewInsetSize, kInfoViewInsetSize,
 | 
| +                    kInfoViewInsetSize, kInfoViewInsetSize);
 | 
|    SetLayoutManager(layout);
 | 
|  
 | 
| -  int three_column_layout_id = 0;
 | 
| -  views::ColumnSet* column_set = layout->AddColumnSet(three_column_layout_id);
 | 
| +  views::ColumnSet* column_set = layout->AddColumnSet(kLayoutId);
 | 
|    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_);
 | 
| +  AddRow(kLayoutId, layout, manifest_url_label, manifest_url_field_, true);
 | 
| +  AddRow(kLayoutId, layout, size_label, size_field_, true);
 | 
| +  AddRow(kLayoutId, layout, creation_date_label, creation_date_field_, true);
 | 
| +  AddRow(kLayoutId, layout, last_access_label, last_access_field_, false);
 | 
| +}
 | 
|  
 | 
| +void AppCacheInfoView::AddRow(
 | 
| +    int layout_id, views::GridLayout* layout, views::Label* label,
 | 
| +    views::Textfield* field, bool add_padding_row) {
 | 
| +  // Add to the view hierarchy.
 | 
| +  layout->StartRow(0, layout_id);
 | 
| +  layout->AddView(label);
 | 
| +  layout->AddView(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);
 | 
| +
 | 
| +  // Init them now that they're in the view heirarchy.
 | 
| +  field->SetReadOnly(true);
 | 
| +  field->RemoveBorder();
 | 
| +  field->SetBackgroundColor(text_area_background);
 | 
| +
 | 
| +  if (add_padding_row)
 | 
| +    layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
 | 
|  }
 | 
| -
 | 
| 
 |