| 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/exceptions_view.h" |    5 #include "chrome/browser/ui/views/options/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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   76     default: |   76     default: | 
|   77       NOTREACHED(); |   77       NOTREACHED(); | 
|   78   } |   78   } | 
|   79 } |   79 } | 
|   80  |   80  | 
|   81 void ExceptionsView::Layout() { |   81 void ExceptionsView::Layout() { | 
|   82   views::NativeButton* buttons[] = { add_button_, edit_button_, |   82   views::NativeButton* buttons[] = { add_button_, edit_button_, | 
|   83                                      remove_button_, remove_all_button_ }; |   83                                      remove_button_, remove_all_button_ }; | 
|   84  |   84  | 
|   85   // The buttons are placed in the parent, but we need to lay them out. |   85   // The buttons are placed in the parent, but we need to lay them out. | 
|   86   int max_y = |   86   int max_y = parent()->GetLocalBounds().bottom() - views::kButtonVEdgeMargin; | 
|   87       GetParent()->GetLocalBounds().bottom() - views::kButtonVEdgeMargin; |  | 
|   88   int x = kPanelHorizMargin; |   87   int x = kPanelHorizMargin; | 
|   89  |   88  | 
|   90   for (size_t i = 0; i < arraysize(buttons); ++i) { |   89   for (size_t i = 0; i < arraysize(buttons); ++i) { | 
|   91     gfx::Size pref = buttons[i]->GetPreferredSize(); |   90     gfx::Size pref = buttons[i]->GetPreferredSize(); | 
|   92     buttons[i]->SetBounds(x, max_y - pref.height(), pref.width(), |   91     buttons[i]->SetBounds(x, max_y - pref.height(), pref.width(), | 
|   93                           pref.height()); |   92                           pref.height()); | 
|   94     x += pref.width() + kRelatedControlHorizontalSpacing; |   93     x += pref.width() + kRelatedControlHorizontalSpacing; | 
|   95   } |   94   } | 
|   96  |   95  | 
|   97   // Lay out the rest of this view. |   96   // Lay out the rest of this view. | 
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  189   edit_button_->set_tag(IDS_EXCEPTIONS_EDIT_BUTTON); |  188   edit_button_->set_tag(IDS_EXCEPTIONS_EDIT_BUTTON); | 
|  190   remove_button_ = new views::NativeButton( |  189   remove_button_ = new views::NativeButton( | 
|  191       this, |  190       this, | 
|  192       UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON))); |  191       UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVE_BUTTON))); | 
|  193   remove_button_->set_tag(IDS_EXCEPTIONS_REMOVE_BUTTON); |  192   remove_button_->set_tag(IDS_EXCEPTIONS_REMOVE_BUTTON); | 
|  194   remove_all_button_ = new views::NativeButton( |  193   remove_all_button_ = new views::NativeButton( | 
|  195       this, |  194       this, | 
|  196       UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVEALL_BUTTON))); |  195       UTF16ToWide(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_REMOVEALL_BUTTON))); | 
|  197   remove_all_button_->set_tag(IDS_EXCEPTIONS_REMOVEALL_BUTTON); |  196   remove_all_button_->set_tag(IDS_EXCEPTIONS_REMOVEALL_BUTTON); | 
|  198  |  197  | 
|  199   View* parent = GetParent(); |  198   parent()->AddChildView(add_button_); | 
|  200   parent->AddChildView(add_button_); |  199   parent()->AddChildView(edit_button_); | 
|  201   parent->AddChildView(edit_button_); |  200   parent()->AddChildView(remove_button_); | 
|  202   parent->AddChildView(remove_button_); |  201   parent()->AddChildView(remove_all_button_); | 
|  203   parent->AddChildView(remove_all_button_); |  | 
|  204  |  202  | 
|  205   GridLayout* layout = new GridLayout(this); |  203   GridLayout* layout = new GridLayout(this); | 
|  206   layout->SetInsets(kExceptionsViewInsetSize, kExceptionsViewInsetSize, |  204   layout->SetInsets(kExceptionsViewInsetSize, kExceptionsViewInsetSize, | 
|  207                     kExceptionsViewInsetSize, kExceptionsViewInsetSize); |  205                     kExceptionsViewInsetSize, kExceptionsViewInsetSize); | 
|  208   SetLayoutManager(layout); |  206   SetLayoutManager(layout); | 
|  209  |  207  | 
|  210   const int single_column_layout_id = 0; |  208   const int single_column_layout_id = 0; | 
|  211   views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); |  209   views::ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); | 
|  212   column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); |  210   column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); | 
|  213   column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |  211   column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  273   } |  271   } | 
|  274  |  272  | 
|  275   UpdateButtonState(); |  273   UpdateButtonState(); | 
|  276 } |  274 } | 
|  277  |  275  | 
|  278 void ExceptionsView::RemoveAll() { |  276 void ExceptionsView::RemoveAll() { | 
|  279   model_.RemoveAll(); |  277   model_.RemoveAll(); | 
|  280  |  278  | 
|  281   UpdateButtonState(); |  279   UpdateButtonState(); | 
|  282 } |  280 } | 
| OLD | NEW |