| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/website_settings/permission_selector_row.h" | 5 #include "chrome/browser/ui/views/website_settings/permission_selector_row.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/views/website_settings/non_accessible_image_view.h" | 10 #include "chrome/browser/ui/views/website_settings/non_accessible_image_view.h" |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 else | 286 else |
| 287 InitializeMenuButtonView(layout, permission); | 287 InitializeMenuButtonView(layout, permission); |
| 288 } | 288 } |
| 289 | 289 |
| 290 void PermissionSelectorRow::AddObserver( | 290 void PermissionSelectorRow::AddObserver( |
| 291 PermissionSelectorRowObserver* observer) { | 291 PermissionSelectorRowObserver* observer) { |
| 292 observer_list_.AddObserver(observer); | 292 observer_list_.AddObserver(observer); |
| 293 } | 293 } |
| 294 | 294 |
| 295 void PermissionSelectorRow::ChildPreferredSizeChanged(View* child) { | 295 void PermissionSelectorRow::ChildPreferredSizeChanged(View* child) { |
| 296 SizeToPreferredSize(); | 296 Layout(); |
| 297 // FIXME: The parent is only a plain |View| that is used as a | |
| 298 // container/box/panel. The SizeToPreferredSize method of the parent is | |
| 299 // called here directly in order not to implement a custom |View| class with | |
| 300 // its own implementation of the ChildPreferredSizeChanged method. | |
| 301 parent()->SizeToPreferredSize(); | |
| 302 } | 297 } |
| 303 | 298 |
| 304 PermissionSelectorRow::~PermissionSelectorRow() { | 299 PermissionSelectorRow::~PermissionSelectorRow() { |
| 305 // Gross. On paper the Combobox and the ComboboxModelAdapter are both owned by | 300 // Gross. On paper the Combobox and the ComboboxModelAdapter are both owned by |
| 306 // this class, but actually, the Combobox is owned by View and will be | 301 // this class, but actually, the Combobox is owned by View and will be |
| 307 // destroyed in ~View(), which runs *after* ~PermissionSelectorRow() is done, | 302 // destroyed in ~View(), which runs *after* ~PermissionSelectorRow() is done, |
| 308 // which means the Combobox gets destroyed after its ComboboxModel, which | 303 // which means the Combobox gets destroyed after its ComboboxModel, which |
| 309 // causes an explosion when the Combobox attempts to stop observing the | 304 // causes an explosion when the Combobox attempts to stop observing the |
| 310 // ComboboxModel. This hack ensures the Combobox is deleted before its | 305 // ComboboxModel. This hack ensures the Combobox is deleted before its |
| 311 // ComboboxModel. | 306 // ComboboxModel. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 permission.default_setting, content_settings::SETTING_SOURCE_USER)); | 358 permission.default_setting, content_settings::SETTING_SOURCE_USER)); |
| 364 menu_button_->SizeToPreferredSize(); | 359 menu_button_->SizeToPreferredSize(); |
| 365 } else if (combobox_) { | 360 } else if (combobox_) { |
| 366 bool use_default = permission.setting == CONTENT_SETTING_DEFAULT; | 361 bool use_default = permission.setting == CONTENT_SETTING_DEFAULT; |
| 367 combobox_->UpdateSelectedIndex(use_default); | 362 combobox_->UpdateSelectedIndex(use_default); |
| 368 } | 363 } |
| 369 | 364 |
| 370 for (PermissionSelectorRowObserver& observer : observer_list_) | 365 for (PermissionSelectorRowObserver& observer : observer_list_) |
| 371 observer.OnPermissionChanged(permission); | 366 observer.OnPermissionChanged(permission); |
| 372 } | 367 } |
| OLD | NEW |