| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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 = | 
| 73       GetParent()->GetContentsBounds().bottom() - views::kButtonVEdgeMargin; | 73       parent()->GetContentsBounds().bottom() - views::kButtonVEdgeMargin; | 
| 74   int x = kPanelHorizMargin; | 74   int x = kPanelHorizMargin; | 
| 75 | 75 | 
| 76   for (size_t i = 0; i < arraysize(buttons); ++i) { | 76   for (size_t i = 0; i < arraysize(buttons); ++i) { | 
| 77     gfx::Size pref = buttons[i]->GetPreferredSize(); | 77     gfx::Size pref = buttons[i]->GetPreferredSize(); | 
| 78     buttons[i]->SetBounds(x, max_y - pref.height(), pref.width(), | 78     buttons[i]->SetBounds(x, max_y - pref.height(), pref.width(), | 
| 79                           pref.height()); | 79                           pref.height()); | 
| 80     x += pref.width() + kRelatedControlHorizontalSpacing; | 80     x += pref.width() + kRelatedControlHorizontalSpacing; | 
| 81   } | 81   } | 
| 82 | 82 | 
| 83   // Lay out the rest of this view. | 83   // Lay out the rest of this view. | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 136 | 136 | 
| 137   remove_button_ = new views::NativeButton( | 137   remove_button_ = new views::NativeButton( | 
| 138       this, | 138       this, | 
| 139       UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON))); | 139       UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON))); | 
| 140   remove_button_->set_tag(IDS_EXCEPTIONS_REMOVE_BUTTON); | 140   remove_button_->set_tag(IDS_EXCEPTIONS_REMOVE_BUTTON); | 
| 141   remove_all_button_ = new views::NativeButton( | 141   remove_all_button_ = new views::NativeButton( | 
| 142       this, | 142       this, | 
| 143       UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVEALL_BUTTON))); | 143       UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVEALL_BUTTON))); | 
| 144   remove_all_button_->set_tag(IDS_EXCEPTIONS_REMOVEALL_BUTTON); | 144   remove_all_button_->set_tag(IDS_EXCEPTIONS_REMOVEALL_BUTTON); | 
| 145 | 145 | 
| 146   View* parent = GetParent(); | 146   parent()->AddChildView(remove_button_); | 
| 147   parent->AddChildView(remove_button_); | 147   parent()->AddChildView(remove_all_button_); | 
| 148   parent->AddChildView(remove_all_button_); |  | 
| 149 | 148 | 
| 150   GridLayout* layout = new GridLayout(this); | 149   GridLayout* layout = new GridLayout(this); | 
| 151   layout->SetInsets(kExceptionsViewInsetSize, kExceptionsViewInsetSize, | 150   layout->SetInsets(kExceptionsViewInsetSize, kExceptionsViewInsetSize, | 
| 152                     kExceptionsViewInsetSize, kExceptionsViewInsetSize); | 151                     kExceptionsViewInsetSize, kExceptionsViewInsetSize); | 
| 153   SetLayoutManager(layout); | 152   SetLayoutManager(layout); | 
| 154 | 153 | 
| 155   const int single_column_layout_id = 0; | 154   const int single_column_layout_id = 0; | 
| 156   views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 155   views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 
| 157   column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 156   column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 
| 158   column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 157   column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
| 182 | 181 | 
| 183 void SimpleContentExceptionsView::Remove() { | 182 void SimpleContentExceptionsView::Remove() { | 
| 184   model_->RemoveRows(GetSelectedRows()); | 183   model_->RemoveRows(GetSelectedRows()); | 
| 185   UpdateButtonState(); | 184   UpdateButtonState(); | 
| 186 } | 185 } | 
| 187 | 186 | 
| 188 void SimpleContentExceptionsView::RemoveAll() { | 187 void SimpleContentExceptionsView::RemoveAll() { | 
| 189   model_->RemoveAll(); | 188   model_->RemoveAll(); | 
| 190   UpdateButtonState(); | 189   UpdateButtonState(); | 
| 191 } | 190 } | 
| OLD | NEW | 
|---|