| Index: chrome/browser/ui/views/collected_cookies_views.cc
|
| diff --git a/chrome/browser/ui/views/collected_cookies_views.cc b/chrome/browser/ui/views/collected_cookies_views.cc
|
| index 260f1d8223ef3f62480fd3d439a2e2448b20215e..992254d7941f6453ffec7a8ec7311e90f3fac61b 100644
|
| --- a/chrome/browser/ui/views/collected_cookies_views.cc
|
| +++ b/chrome/browser/ui/views/collected_cookies_views.cc
|
| @@ -20,9 +20,11 @@
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
|
| #include "chrome/browser/ui/constrained_window.h"
|
| +#include "chrome/browser/ui/constrained_window_constants.h"
|
| #include "chrome/browser/ui/views/constrained_window_views.h"
|
| #include "chrome/browser/ui/views/cookie_info_view.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "content/public/browser/notification_details.h"
|
| #include "content/public/browser/notification_source.h"
|
| @@ -34,6 +36,7 @@
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| #include "ui/gfx/color_utils.h"
|
| +#include "ui/views/controls/button/chrome_style.h"
|
| #include "ui/views/controls/button/text_button.h"
|
| #include "ui/views/controls/image_view.h"
|
| #include "ui/views/controls/label.h"
|
| @@ -75,6 +78,35 @@ const int kTreeViewHeight = 125;
|
|
|
| } // namespace
|
|
|
| +struct CollectedCookiesViews::LayoutParams {
|
| + // Padding above the Block/Unblock button.
|
| + int button_top_padding;
|
| + // Padding between the button and the cookie info view.
|
| + int cookie_info_view_top_padding;
|
| + // Padding below the cookie info view.
|
| + int cookie_info_view_bottom_padding;
|
| + int label_top_padding;
|
| + int label_bottom_padding;
|
| +};
|
| +
|
| +const CollectedCookiesViews::LayoutParams
|
| + CollectedCookiesViews::standard_layout_params = {
|
| + views::kRelatedControlVerticalSpacing,
|
| + views::kRelatedControlVerticalSpacing,
|
| + views::kRelatedControlVerticalSpacing,
|
| + 0,
|
| + views::kRelatedControlVerticalSpacing
|
| +};
|
| +
|
| +const CollectedCookiesViews::LayoutParams
|
| + CollectedCookiesViews::chrome_style_layout_params = {
|
| + 10,
|
| + 19,
|
| + ConstrainedWindowConstants::kRowPadding,
|
| + ConstrainedWindowConstants::kRowPadding,
|
| + ConstrainedWindowConstants::kRowPadding
|
| +};
|
| +
|
| // A custom view that conditionally displays an infobar.
|
| class InfobarView : public views::View {
|
| public:
|
| @@ -83,7 +115,9 @@ class InfobarView : public views::View {
|
| #if defined(USE_AURA) || !defined(OS_WIN)
|
| SkColor border_color = SK_ColorGRAY;
|
| #else
|
| - SkColor border_color = color_utils::GetSysSkColor(COLOR_3DSHADOW);
|
| + SkColor border_color = chrome::UseChromeStyleDialogs() ?
|
| + SK_ColorGRAY :
|
| + color_utils::GetSysSkColor(COLOR_3DSHADOW);
|
| #endif
|
| views::Border* border = views::Border::CreateSolidBorder(
|
| kInfobarBorderSize, border_color);
|
| @@ -193,13 +227,18 @@ CollectedCookiesViews::CollectedCookiesViews(content::WebContents* web_contents)
|
| for_session_blocked_button_(NULL),
|
| cookie_info_view_(NULL),
|
| infobar_(NULL),
|
| - status_changed_(false) {
|
| + status_changed_(false),
|
| + layout_params_(chrome::UseChromeStyleDialogs() ?
|
| + chrome_style_layout_params : standard_layout_params) {
|
| TabSpecificContentSettings* content_settings =
|
| TabSpecificContentSettings::FromWebContents(web_contents);
|
| registrar_.Add(this, chrome::NOTIFICATION_COLLECTED_COOKIES_SHOWN,
|
| content::Source<TabSpecificContentSettings>(content_settings));
|
| window_ = new ConstrainedWindowViews(
|
| - web_contents, this, false, ConstrainedWindowViews::DEFAULT_INSETS);
|
| + web_contents,
|
| + this,
|
| + chrome::UseChromeStyleDialogs(),
|
| + ConstrainedWindowViews::FRAME_LAYOUT_HEADER_ONLY);
|
| }
|
|
|
| ///////////////////////////////////////////////////////////////////////////////
|
| @@ -222,6 +261,19 @@ void CollectedCookiesViews::DeleteDelegate() {
|
| delete this;
|
| }
|
|
|
| +bool CollectedCookiesViews::UseChromeStyle() const {
|
| + return chrome::UseChromeStyleDialogs();
|
| +}
|
| +
|
| +void CollectedCookiesViews::GetChromeStyleMargins(int* vertical_edge,
|
| + int* horizontal_edge) const {
|
| + DCHECK(vertical_edge);
|
| + DCHECK(horizontal_edge);
|
| + *vertical_edge = ConstrainedWindowConstants::kClientBottomPadding -
|
| + views::GetChromeStyleButtonShadowMargin();
|
| + *horizontal_edge = ConstrainedWindowConstants::kHorizontalPadding;
|
| +}
|
| +
|
| bool CollectedCookiesViews::Cancel() {
|
| if (status_changed_) {
|
| InfoBarTabHelper* infobar_helper =
|
| @@ -288,7 +340,9 @@ CollectedCookiesViews::~CollectedCookiesViews() {
|
| void CollectedCookiesViews::Init() {
|
| using views::GridLayout;
|
|
|
| - GridLayout* layout = GridLayout::CreatePanel(this);
|
| + GridLayout* layout = chrome::UseChromeStyleDialogs() ?
|
| + new GridLayout(this) :
|
| + GridLayout::CreatePanel(this);
|
| SetLayoutManager(layout);
|
|
|
| const int single_column_layout_id = 0;
|
| @@ -304,10 +358,11 @@ void CollectedCookiesViews::Init() {
|
| column_set_with_padding->AddPaddingColumn(0, 2);
|
|
|
| layout->StartRow(0, single_column_layout_id);
|
| - views::TabbedPane* tabbed_pane = new views::TabbedPane();
|
| + views::TabbedPane* tabbed_pane =
|
| + new views::TabbedPane(chrome::UseChromeStyleDialogs());
|
| #if defined(OS_WIN) && !defined(USE_AURA)
|
| // "set_use_native_win_control" must be called before the first tab is added.
|
| - tabbed_pane->set_use_native_win_control(true);
|
| + tabbed_pane->set_use_native_win_control(!chrome::UseChromeStyleDialogs());
|
| #endif
|
| layout->AddView(tabbed_pane);
|
| // NOTE: the panes need to be added after the tabbed_pane has been added to
|
| @@ -320,12 +375,12 @@ void CollectedCookiesViews::Init() {
|
| tabbed_pane->AddTab(label_blocked, CreateBlockedPane());
|
| tabbed_pane->SelectTabAt(0);
|
| tabbed_pane->set_listener(this);
|
| - layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
| + layout->AddPaddingRow(0, layout_params_.cookie_info_view_top_padding);
|
|
|
| layout->StartRow(0, single_column_with_padding_layout_id);
|
| cookie_info_view_ = new CookieInfoView(false);
|
| layout->AddView(cookie_info_view_);
|
| - layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
| + layout->AddPaddingRow(0, layout_params_.cookie_info_view_bottom_padding);
|
|
|
| layout->StartRow(0, single_column_with_padding_layout_id);
|
| infobar_ = new InfobarView();
|
| @@ -354,7 +409,7 @@ views::View* CollectedCookiesViews::CreateAllowedPane() {
|
| allowed_cookies_tree_->set_auto_expand_children(true);
|
| allowed_cookies_tree_->SetController(this);
|
|
|
| - block_allowed_button_ = new views::NativeTextButton(this,
|
| + block_allowed_button_ = CreateTextButton(
|
| l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_BLOCK_BUTTON));
|
|
|
| // Create the view that holds all the controls together. This will be the
|
| @@ -362,7 +417,16 @@ views::View* CollectedCookiesViews::CreateAllowedPane() {
|
| using views::GridLayout;
|
|
|
| views::View* pane = new views::View();
|
| - GridLayout* layout = GridLayout::CreatePanel(pane);
|
| + GridLayout* layout;
|
| + if (chrome::UseChromeStyleDialogs()) {
|
| + layout = new GridLayout(pane);
|
| + layout->SetInsets(0,
|
| + ConstrainedWindowConstants::kHorizontalPadding,
|
| + 0,
|
| + ConstrainedWindowConstants::kHorizontalPadding);
|
| + } else {
|
| + layout = GridLayout::CreatePanel(pane);
|
| + }
|
| pane->SetLayoutManager(layout);
|
|
|
| const int single_column_layout_id = 0;
|
| @@ -370,15 +434,16 @@ views::View* CollectedCookiesViews::CreateAllowedPane() {
|
| column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
|
| GridLayout::USE_PREF, 0, 0);
|
|
|
| + layout->AddPaddingRow(0, layout_params_.label_top_padding);
|
| layout->StartRow(0, single_column_layout_id);
|
| layout->AddView(allowed_label_);
|
| - layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
| + layout->AddPaddingRow(0, layout_params_.label_bottom_padding);
|
|
|
| layout->StartRow(1, single_column_layout_id);
|
| layout->AddView(allowed_cookies_tree_->CreateParentIfNecessary(), 1, 1,
|
| GridLayout::FILL, GridLayout::FILL, kTreeViewWidth,
|
| kTreeViewHeight);
|
| - layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
| + layout->AddPaddingRow(0, layout_params_.button_top_padding);
|
|
|
| layout->StartRow(0, single_column_layout_id);
|
| layout->AddView(block_allowed_button_, 1, 1, GridLayout::LEADING,
|
| @@ -414,9 +479,9 @@ views::View* CollectedCookiesViews::CreateBlockedPane() {
|
| blocked_cookies_tree_->set_auto_expand_children(true);
|
| blocked_cookies_tree_->SetController(this);
|
|
|
| - allow_blocked_button_ = new views::NativeTextButton(this,
|
| + allow_blocked_button_ = CreateTextButton(
|
| l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_ALLOW_BUTTON));
|
| - for_session_blocked_button_ = new views::NativeTextButton(this,
|
| + for_session_blocked_button_ = CreateTextButton(
|
| l10n_util::GetStringUTF16(IDS_COLLECTED_COOKIES_SESSION_ONLY_BUTTON));
|
|
|
| // Create the view that holds all the controls together. This will be the
|
| @@ -424,7 +489,16 @@ views::View* CollectedCookiesViews::CreateBlockedPane() {
|
| using views::GridLayout;
|
|
|
| views::View* pane = new views::View();
|
| - GridLayout* layout = GridLayout::CreatePanel(pane);
|
| + GridLayout* layout;
|
| + if (chrome::UseChromeStyleDialogs()) {
|
| + layout = new GridLayout(pane);
|
| + layout->SetInsets(0,
|
| + ConstrainedWindowConstants::kHorizontalPadding,
|
| + 0,
|
| + ConstrainedWindowConstants::kHorizontalPadding);
|
| + } else {
|
| + layout = GridLayout::CreatePanel(pane);
|
| + }
|
| pane->SetLayoutManager(layout);
|
|
|
| const int single_column_layout_id = 0;
|
| @@ -440,15 +514,16 @@ views::View* CollectedCookiesViews::CreateBlockedPane() {
|
| column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
|
| GridLayout::USE_PREF, 0, 0);
|
|
|
| + layout->AddPaddingRow(0, layout_params_.label_top_padding);
|
| layout->StartRow(0, single_column_layout_id);
|
| layout->AddView(blocked_label_, 1, 1, GridLayout::FILL, GridLayout::FILL);
|
| - layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
| + layout->AddPaddingRow(0, layout_params_.label_bottom_padding);
|
|
|
| layout->StartRow(1, single_column_layout_id);
|
| layout->AddView(
|
| blocked_cookies_tree_->CreateParentIfNecessary(), 1, 1,
|
| GridLayout::FILL, GridLayout::FILL, kTreeViewWidth, kTreeViewHeight);
|
| - layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
|
| + layout->AddPaddingRow(0, layout_params_.button_top_padding);
|
|
|
| layout->StartRow(0, three_columns_layout_id);
|
| layout->AddView(allow_blocked_button_);
|
| @@ -457,6 +532,17 @@ views::View* CollectedCookiesViews::CreateBlockedPane() {
|
| return pane;
|
| }
|
|
|
| +views::TextButton* CollectedCookiesViews::CreateTextButton(
|
| + const string16& text) {
|
| + if (UseChromeStyle()) {
|
| + views::TextButton* button = new views::TextButton(this, text);
|
| + ApplyChromeStyle(button);
|
| + return button;
|
| + } else {
|
| + return new views::NativeTextButton(this, text);
|
| + }
|
| +}
|
| +
|
| void CollectedCookiesViews::EnableControls() {
|
| bool enable_allowed_buttons = false;
|
| ui::TreeModelNode* node = allowed_cookies_tree_->GetSelectedNode();
|
|
|