| 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/options/simple_content_exceptions_view.h" | 5 #include "chrome/browser/ui/views/options/simple_content_exceptions_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 break; | 62 break; |
| 63 default: | 63 default: |
| 64 NOTREACHED(); | 64 NOTREACHED(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 void SimpleContentExceptionsView::Layout() { | 68 void SimpleContentExceptionsView::Layout() { |
| 69 views::NativeButton* buttons[] = { remove_button_, remove_all_button_ }; | 69 views::NativeButton* buttons[] = { remove_button_, remove_all_button_ }; |
| 70 | 70 |
| 71 // The buttons are placed in the parent, but we need to lay them out. | 71 // The buttons are placed in the parent, but we need to lay them out. |
| 72 int max_y = | 72 int max_y = parent()->GetLocalBounds().bottom() - views::kButtonVEdgeMargin; |
| 73 GetParent()->GetLocalBounds().bottom() - views::kButtonVEdgeMargin; | |
| 74 int x = kPanelHorizMargin; | 73 int x = kPanelHorizMargin; |
| 75 | 74 |
| 76 for (size_t i = 0; i < arraysize(buttons); ++i) { | 75 for (size_t i = 0; i < arraysize(buttons); ++i) { |
| 77 gfx::Size pref = buttons[i]->GetPreferredSize(); | 76 gfx::Size pref = buttons[i]->GetPreferredSize(); |
| 78 buttons[i]->SetBounds(x, max_y - pref.height(), pref.width(), | 77 buttons[i]->SetBounds(x, max_y - pref.height(), pref.width(), |
| 79 pref.height()); | 78 pref.height()); |
| 80 x += pref.width() + kRelatedControlHorizontalSpacing; | 79 x += pref.width() + kRelatedControlHorizontalSpacing; |
| 81 } | 80 } |
| 82 | 81 |
| 83 // Lay out the rest of this view. | 82 // Lay out the rest of this view. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 | 135 |
| 137 remove_button_ = new views::NativeButton( | 136 remove_button_ = new views::NativeButton( |
| 138 this, | 137 this, |
| 139 UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON))); | 138 UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON))); |
| 140 remove_button_->set_tag(IDS_EXCEPTIONS_REMOVE_BUTTON); | 139 remove_button_->set_tag(IDS_EXCEPTIONS_REMOVE_BUTTON); |
| 141 remove_all_button_ = new views::NativeButton( | 140 remove_all_button_ = new views::NativeButton( |
| 142 this, | 141 this, |
| 143 UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVEALL_BUTTON))); | 142 UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVEALL_BUTTON))); |
| 144 remove_all_button_->set_tag(IDS_EXCEPTIONS_REMOVEALL_BUTTON); | 143 remove_all_button_->set_tag(IDS_EXCEPTIONS_REMOVEALL_BUTTON); |
| 145 | 144 |
| 146 View* parent = GetParent(); | 145 parent()->AddChildView(remove_button_); |
| 147 parent->AddChildView(remove_button_); | 146 parent()->AddChildView(remove_all_button_); |
| 148 parent->AddChildView(remove_all_button_); | |
| 149 | 147 |
| 150 GridLayout* layout = new GridLayout(this); | 148 GridLayout* layout = new GridLayout(this); |
| 151 layout->SetInsets(kExceptionsViewInsetSize, kExceptionsViewInsetSize, | 149 layout->SetInsets(kExceptionsViewInsetSize, kExceptionsViewInsetSize, |
| 152 kExceptionsViewInsetSize, kExceptionsViewInsetSize); | 150 kExceptionsViewInsetSize, kExceptionsViewInsetSize); |
| 153 SetLayoutManager(layout); | 151 SetLayoutManager(layout); |
| 154 | 152 |
| 155 const int single_column_layout_id = 0; | 153 const int single_column_layout_id = 0; |
| 156 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 154 views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |
| 157 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 155 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |
| 158 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 156 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 182 | 180 |
| 183 void SimpleContentExceptionsView::Remove() { | 181 void SimpleContentExceptionsView::Remove() { |
| 184 model_->RemoveRows(GetSelectedRows()); | 182 model_->RemoveRows(GetSelectedRows()); |
| 185 UpdateButtonState(); | 183 UpdateButtonState(); |
| 186 } | 184 } |
| 187 | 185 |
| 188 void SimpleContentExceptionsView::RemoveAll() { | 186 void SimpleContentExceptionsView::RemoveAll() { |
| 189 model_->RemoveAll(); | 187 model_->RemoveAll(); |
| 190 UpdateButtonState(); | 188 UpdateButtonState(); |
| 191 } | 189 } |
| OLD | NEW |