Commit 6acff6fd authored by tfarina@chromium.org's avatar tfarina@chromium.org

views: Remove appcache_info_view* and generic_info_view* files.

R=ben@chromium.org

Review URL: https://chromiumcodereview.appspot.com/10332211

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@137668 0039d316-1c4b-4281-b951-d872f2087c98
parent 7122a5ab
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/appcache_info_view.h"
#include "base/i18n/time_formatting.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "grit/generated_resources.h"
#include "ui/base/text/bytes_formatting.h"
namespace {
const int kInfoLabelIds[] = {
IDS_COOKIES_APPLICATION_CACHE_MANIFEST_LABEL,
IDS_COOKIES_SIZE_LABEL,
IDS_COOKIES_COOKIE_CREATED_LABEL,
IDS_COOKIES_LAST_ACCESSED_LABEL
};
} // namespace
AppCacheInfoView::AppCacheInfoView()
: GenericInfoView(ARRAYSIZE(kInfoLabelIds), kInfoLabelIds) {
}
void AppCacheInfoView::SetAppCacheInfo(const appcache::AppCacheInfo* info) {
DCHECK(info);
string16 manifest_url =
UTF8ToUTF16(info->manifest_url.spec());
string16 size =
ui::FormatBytes(info->size);
string16 creation_date =
base::TimeFormatFriendlyDateAndTime(info->creation_time);
string16 last_access_date =
base::TimeFormatFriendlyDateAndTime(info->last_access_time);
int row = 0;
SetValue(row++, manifest_url);
SetValue(row++, size);
SetValue(row++, creation_date);
SetValue(row++, last_access_date);
}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_APPCACHE_INFO_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_APPCACHE_INFO_VIEW_H_
#pragma once
#include "chrome/browser/browsing_data_appcache_helper.h"
#include "chrome/browser/ui/views/generic_info_view.h"
// AppCacheInfoView
// Displays a tabular grid of AppCache information.
class AppCacheInfoView : public GenericInfoView {
public:
AppCacheInfoView();
void SetAppCacheInfo(const appcache::AppCacheInfo* info);
private:
DISALLOW_COPY_AND_ASSIGN(AppCacheInfoView);
};
#endif // CHROME_BROWSER_UI_VIEWS_APPCACHE_INFO_VIEW_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/generic_info_view.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_utils.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/layout/layout_constants.h"
GenericInfoView::GenericInfoView(int number_of_rows)
: number_of_rows_(number_of_rows), name_string_ids_(NULL) {
DCHECK(number_of_rows_ > 0);
}
GenericInfoView::GenericInfoView(
int number_of_rows, const int name_string_ids[])
: number_of_rows_(number_of_rows), name_string_ids_(name_string_ids) {
DCHECK(number_of_rows_ > 0);
}
void GenericInfoView::SetNameByStringId(int row, int name_string_id) {
SetName(row, l10n_util::GetStringUTF16(name_string_id));
}
void GenericInfoView::SetName(int row, const string16& name) {
DCHECK(name_views_.get()); // Can only be called after Init time.
DCHECK(row >= 0 && row < number_of_rows_);
name_views_[row]->SetText(name);
}
void GenericInfoView::SetValue(int row, const string16& name) {
DCHECK(value_views_.get()); // Can only be called after Init time.
DCHECK(row >= 0 && row < number_of_rows_);
value_views_[row]->SetText(name);
}
void GenericInfoView::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
if (is_add && child == this) {
InitGenericInfoView();
if (name_string_ids_) {
for (int i = 0; i < number_of_rows_; ++i)
SetNameByStringId(i, name_string_ids_[i]);
}
}
}
void GenericInfoView::InitGenericInfoView() {
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(
kInfoViewBorderSize, border_color);
set_border(border);
using views::GridLayout;
GridLayout* layout = new GridLayout(this);
layout->SetInsets(kInfoViewInsetSize, kInfoViewInsetSize,
kInfoViewInsetSize, kInfoViewInsetSize);
SetLayoutManager(layout);
views::ColumnSet* column_set = layout->AddColumnSet(kLayoutId);
column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
GridLayout::USE_PREF, 0, 0);
column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
name_views_.reset(new views::Label* [number_of_rows_]);
value_views_.reset(new views::Textfield* [number_of_rows_]);
for (int i = 0; i < number_of_rows_; ++i) {
if (i)
layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing);
name_views_[i] = new views::Label;
value_views_[i] = new views::Textfield;
AddRow(kLayoutId, layout, name_views_[i], value_views_[i]);
}
}
void GenericInfoView::AddRow(
int layout_id, views::GridLayout* layout, views::Label* name,
views::Textfield* value) {
// Add to the view hierarchy.
layout->StartRow(0, layout_id);
layout->AddView(name);
layout->AddView(value);
// Color these borderless text areas the same as the containing dialog.
SkColor text_area_background = color_utils::GetSysSkColor(COLOR_3DFACE);
// Init them now that they're in the view hierarchy.
value->SetReadOnly(true);
value->RemoveBorder();
value->SetBackgroundColor(text_area_background);
}
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_GENERIC_INFO_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_GENERIC_INFO_VIEW_H_
#pragma once
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "ui/views/view.h"
namespace views {
class GridLayout;
class Label;
class Textfield;
}
// GenericInfoView, displays a tabular grid of read-only textual information,
// <name, value> pairs. The fixed number of rows must be known at the time of
// construction.
class GenericInfoView : public views::View {
public:
// Constructs a info view with |number_of_rows| and populated with
// empty strings.
explicit GenericInfoView(int number_of_rows);
// Constructs a info view with |number_of_rows|, and populates
// the name column with localized strings having the given
// |name_string_ids|. The array of ids should contain |number_of_rows|
// values and should remain valid for the life of the view.
GenericInfoView(int number_of_rows, const int name_string_ids[]);
// The following methods should only be called after
// the view has been added to a view hierarchy.
void SetNameByStringId(int row, int id);
void SetName(int row, const string16& name);
void SetValue(int row, const string16& value);
void ClearValues() {
const string16 kEmptyString;
for (int i = 0; i < number_of_rows_; ++i)
SetValue(i, kEmptyString);
}
protected:
// views::View override
virtual void ViewHierarchyChanged(
bool is_add, views::View* parent, views::View* child);
private:
FRIEND_TEST_ALL_PREFIXES(GenericInfoViewTest, GenericInfoView);
void InitGenericInfoView();
void AddRow(int layout_id, views::GridLayout* layout,
views::Label* name, views::Textfield* value);
const int number_of_rows_;
const int* name_string_ids_;
scoped_array<views::Label*> name_views_;
scoped_array<views::Textfield*> value_views_;
DISALLOW_COPY_AND_ASSIGN(GenericInfoView);
};
#endif // CHROME_BROWSER_UI_VIEWS_GENERIC_INFO_VIEW_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/views/generic_info_view.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/widget/widget.h"
// This class is only used on windows for now.
#if defined(OS_WIN)
class GenericInfoViewTest : public testing::Test {
private:
MessageLoopForUI message_loop_;
};
TEST_F(GenericInfoViewTest, GenericInfoView) {
const string16 kName = ASCIIToUTF16("Name");
const string16 kValue = ASCIIToUTF16("Value");
views::Widget* widget = new views::Widget;
views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP);
params.bounds = gfx::Rect(0, 0, 100, 100);
widget->Init(params);
views::View* root_view = widget->GetRootView();
GenericInfoView* view1 = new GenericInfoView(1);
root_view->AddChildView(view1);
view1->SetName(0, kName);
view1->SetValue(0, kValue);
EXPECT_EQ(kName, view1->name_views_[0]->text());
EXPECT_EQ(kValue, view1->value_views_[0]->text());
view1->ClearValues();
EXPECT_TRUE(view1->value_views_[0]->text().empty());
// Test setting values by localized string id.
static int kNameIds[] = {
IDS_PRODUCT_NAME,
IDS_PRODUCT_DESCRIPTION
};
GenericInfoView* view2 = new GenericInfoView(ARRAYSIZE(kNameIds), kNameIds);
root_view->AddChildView(view2);
string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_NAME);
string16 product_desc = l10n_util::GetStringUTF16(IDS_PRODUCT_DESCRIPTION);
EXPECT_EQ(product_name, view2->name_views_[0]->text());
EXPECT_EQ(product_desc, view2->name_views_[1]->text());
widget->CloseNow();
}
#endif // OS_WIN
...@@ -3259,8 +3259,6 @@ ...@@ -3259,8 +3259,6 @@
'browser/ui/views/accessibility_event_router_views.h', 'browser/ui/views/accessibility_event_router_views.h',
'browser/ui/views/app_menu_button_win.cc', 'browser/ui/views/app_menu_button_win.cc',
'browser/ui/views/app_menu_button_win.h', 'browser/ui/views/app_menu_button_win.h',
'browser/ui/views/appcache_info_view.cc',
'browser/ui/views/appcache_info_view.h',
'browser/ui/views/ash/app_list/app_list_model_builder.cc', 'browser/ui/views/ash/app_list/app_list_model_builder.cc',
'browser/ui/views/ash/app_list/app_list_model_builder.h', 'browser/ui/views/ash/app_list/app_list_model_builder.h',
'browser/ui/views/ash/app_list/app_list_view_delegate.cc', 'browser/ui/views/ash/app_list/app_list_view_delegate.cc',
...@@ -3445,8 +3443,6 @@ ...@@ -3445,8 +3443,6 @@
'browser/ui/views/frame/system_menu_model_delegate.h', 'browser/ui/views/frame/system_menu_model_delegate.h',
'browser/ui/views/fullscreen_exit_bubble_views.cc', 'browser/ui/views/fullscreen_exit_bubble_views.cc',
'browser/ui/views/fullscreen_exit_bubble_views.h', 'browser/ui/views/fullscreen_exit_bubble_views.h',
'browser/ui/views/generic_info_view.cc',
'browser/ui/views/generic_info_view.h',
'browser/ui/views/global_error_bubble_view.cc', 'browser/ui/views/global_error_bubble_view.cc',
'browser/ui/views/global_error_bubble_view.h', 'browser/ui/views/global_error_bubble_view.h',
'browser/ui/views/hung_renderer_view.cc', 'browser/ui/views/hung_renderer_view.cc',
...@@ -4826,12 +4822,8 @@ ...@@ -4826,12 +4822,8 @@
['exclude', '^browser/google/google_update.cc'], ['exclude', '^browser/google/google_update.cc'],
['exclude', '^browser/google/google_update.h'], ['exclude', '^browser/google/google_update.h'],
['exclude', '^browser/platform_util_common_linux.cc'], ['exclude', '^browser/platform_util_common_linux.cc'],
['exclude', '^browser/ui/views/appcache_info_view.cc'],
['exclude', '^browser/ui/views/appcache_info_view.h'],
['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.cc'], ['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.cc'],
['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.h'], ['exclude', '^browser/ui/views/frame/app_panel_browser_frame_view.h'],
['exclude', '^browser/ui/views/generic_info_view.cc'],
['exclude', '^browser/ui/views/generic_info_view.h'],
['exclude', '^browser/ui/views/indexed_db_info_view.cc'], ['exclude', '^browser/ui/views/indexed_db_info_view.cc'],
['exclude', '^browser/ui/views/indexed_db_info_view.h'], ['exclude', '^browser/ui/views/indexed_db_info_view.h'],
['exclude', '^browser/ui/views/local_storage_info_view.cc'], ['exclude', '^browser/ui/views/local_storage_info_view.cc'],
......
...@@ -1760,7 +1760,6 @@ ...@@ -1760,7 +1760,6 @@
'browser/ui/views/crypto_module_password_dialog_view_unittest.cc', 'browser/ui/views/crypto_module_password_dialog_view_unittest.cc',
'browser/ui/views/extensions/browser_action_drag_data_unittest.cc', 'browser/ui/views/extensions/browser_action_drag_data_unittest.cc',
'browser/ui/views/first_run_bubble_unittest.cc', 'browser/ui/views/first_run_bubble_unittest.cc',
'browser/ui/views/generic_info_view_unittest.cc',
'browser/ui/views/reload_button_unittest.cc', 'browser/ui/views/reload_button_unittest.cc',
'browser/ui/views/select_file_dialog_extension_unittest.cc', 'browser/ui/views/select_file_dialog_extension_unittest.cc',
'browser/ui/views/select_file_dialog_win_unittest.cc', 'browser/ui/views/select_file_dialog_win_unittest.cc',
...@@ -2297,7 +2296,6 @@ ...@@ -2297,7 +2296,6 @@
'browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc', 'browser/ui/views/bookmarks/bookmark_editor_view_unittest.cc',
'browser/ui/views/extensions/browser_action_drag_data_unittest.cc', 'browser/ui/views/extensions/browser_action_drag_data_unittest.cc',
'browser/ui/views/first_run_search_engine_view_unittest.cc', 'browser/ui/views/first_run_search_engine_view_unittest.cc',
'browser/ui/views/generic_info_view_unittest.cc',
'test/data/resource.rc', 'test/data/resource.rc',
], ],
}], }],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment