| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/message_center/views/notifier_settings_view.h" | 5 #include "ui/message_center/views/notifier_settings_view.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // The view to guarantee the 48px height and place the contents at the | 115 // The view to guarantee the 48px height and place the contents at the |
| 116 // middle. It also guarantee the left margin. | 116 // middle. It also guarantee the left margin. |
| 117 class EntryView : public views::View { | 117 class EntryView : public views::View { |
| 118 public: | 118 public: |
| 119 explicit EntryView(views::View* contents); | 119 explicit EntryView(views::View* contents); |
| 120 ~EntryView() override; | 120 ~EntryView() override; |
| 121 | 121 |
| 122 // views::View: | 122 // views::View: |
| 123 void Layout() override; | 123 void Layout() override; |
| 124 gfx::Size GetPreferredSize() const override; | 124 gfx::Size GetPreferredSize() const override; |
| 125 void GetAccessibleState(ui::AXViewState* state) override; | 125 void GetAccessibleNodeData(ui::AXNodeData* node_data) override; |
| 126 void OnFocus() override; | 126 void OnFocus() override; |
| 127 bool OnKeyPressed(const ui::KeyEvent& event) override; | 127 bool OnKeyPressed(const ui::KeyEvent& event) override; |
| 128 bool OnKeyReleased(const ui::KeyEvent& event) override; | 128 bool OnKeyReleased(const ui::KeyEvent& event) override; |
| 129 void OnPaint(gfx::Canvas* canvas) override; | 129 void OnPaint(gfx::Canvas* canvas) override; |
| 130 void OnBlur() override; | 130 void OnBlur() override; |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 std::unique_ptr<views::Painter> focus_painter_; | 133 std::unique_ptr<views::Painter> focus_painter_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(EntryView); | 135 DISALLOW_COPY_AND_ASSIGN(EntryView); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 151 content->SetBounds(0, y, content_width, content_height); | 151 content->SetBounds(0, y, content_width, content_height); |
| 152 } | 152 } |
| 153 | 153 |
| 154 gfx::Size EntryView::GetPreferredSize() const { | 154 gfx::Size EntryView::GetPreferredSize() const { |
| 155 DCHECK_EQ(1, child_count()); | 155 DCHECK_EQ(1, child_count()); |
| 156 gfx::Size size = child_at(0)->GetPreferredSize(); | 156 gfx::Size size = child_at(0)->GetPreferredSize(); |
| 157 size.SetToMax(gfx::Size(kWidth, settings::kEntryHeight)); | 157 size.SetToMax(gfx::Size(kWidth, settings::kEntryHeight)); |
| 158 return size; | 158 return size; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void EntryView::GetAccessibleState(ui::AXViewState* state) { | 161 void EntryView::GetAccessibleNodeData(ui::AXNodeData* node_data) { |
| 162 DCHECK_EQ(1, child_count()); | 162 DCHECK_EQ(1, child_count()); |
| 163 child_at(0)->GetAccessibleState(state); | 163 child_at(0)->GetAccessibleNodeData(node_data); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void EntryView::OnFocus() { | 166 void EntryView::OnFocus() { |
| 167 views::View::OnFocus(); | 167 views::View::OnFocus(); |
| 168 ScrollRectToVisible(GetLocalBounds()); | 168 ScrollRectToVisible(GetLocalBounds()); |
| 169 // We render differently when focused. | 169 // We render differently when focused. |
| 170 SchedulePaint(); | 170 SchedulePaint(); |
| 171 } | 171 } |
| 172 | 172 |
| 173 bool EntryView::OnKeyPressed(const ui::KeyEvent& event) { | 173 bool EntryView::OnKeyPressed(const ui::KeyEvent& event) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // back to the previous state. | 339 // back to the previous state. |
| 340 checkbox_->SetChecked(!checkbox_->checked()); | 340 checkbox_->SetChecked(!checkbox_->checked()); |
| 341 CustomButton::NotifyClick(event); | 341 CustomButton::NotifyClick(event); |
| 342 } else if (button == learn_more_) { | 342 } else if (button == learn_more_) { |
| 343 DCHECK(provider_); | 343 DCHECK(provider_); |
| 344 provider_->OnNotifierAdvancedSettingsRequested(notifier_->notifier_id, | 344 provider_->OnNotifierAdvancedSettingsRequested(notifier_->notifier_id, |
| 345 nullptr); | 345 nullptr); |
| 346 } | 346 } |
| 347 } | 347 } |
| 348 | 348 |
| 349 void NotifierSettingsView::NotifierButton::GetAccessibleState( | 349 void NotifierSettingsView::NotifierButton::GetAccessibleNodeData( |
| 350 ui::AXViewState* state) { | 350 ui::AXNodeData* node_data) { |
| 351 static_cast<views::View*>(checkbox_)->GetAccessibleState(state); | 351 static_cast<views::View*>(checkbox_)->GetAccessibleNodeData(node_data); |
| 352 } | 352 } |
| 353 | 353 |
| 354 bool NotifierSettingsView::NotifierButton::ShouldHaveLearnMoreButton() const { | 354 bool NotifierSettingsView::NotifierButton::ShouldHaveLearnMoreButton() const { |
| 355 if (!provider_) | 355 if (!provider_) |
| 356 return false; | 356 return false; |
| 357 | 357 |
| 358 return provider_->NotifierHasAdvancedSettings(notifier_->notifier_id); | 358 return provider_->NotifierHasAdvancedSettings(notifier_->notifier_id); |
| 359 } | 359 } |
| 360 | 360 |
| 361 void NotifierSettingsView::NotifierButton::GridChanged(bool has_learn_more, | 361 void NotifierSettingsView::NotifierButton::GridChanged(bool has_learn_more, |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 provider_->SetNotifierEnabled((*iter)->notifier(), (*iter)->checked()); | 634 provider_->SetNotifierEnabled((*iter)->notifier(), (*iter)->checked()); |
| 635 } | 635 } |
| 636 | 636 |
| 637 void NotifierSettingsView::OnPerformAction(views::Combobox* combobox) { | 637 void NotifierSettingsView::OnPerformAction(views::Combobox* combobox) { |
| 638 provider_->SwitchToNotifierGroup(combobox->selected_index()); | 638 provider_->SwitchToNotifierGroup(combobox->selected_index()); |
| 639 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); | 639 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); |
| 640 center_view->OnSettingsChanged(); | 640 center_view->OnSettingsChanged(); |
| 641 } | 641 } |
| 642 | 642 |
| 643 } // namespace message_center | 643 } // namespace message_center |
| OLD | NEW |