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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 learn_more_(NULL) { | 292 learn_more_(NULL) { |
293 DCHECK(provider); | 293 DCHECK(provider); |
294 DCHECK(notifier); | 294 DCHECK(notifier); |
295 | 295 |
296 // Since there may never be an icon (but that could change at a later time), | 296 // Since there may never be an icon (but that could change at a later time), |
297 // we own the icon view here. | 297 // we own the icon view here. |
298 icon_view_->set_owned_by_client(); | 298 icon_view_->set_owned_by_client(); |
299 | 299 |
300 checkbox_->SetChecked(notifier_->enabled); | 300 checkbox_->SetChecked(notifier_->enabled); |
301 checkbox_->set_listener(this); | 301 checkbox_->set_listener(this); |
302 checkbox_->SetFocusable(false); | 302 checkbox_->SetFocusBehavior(views::View::FocusBehavior::NEVER); |
303 checkbox_->SetAccessibleName(notifier_->name); | 303 checkbox_->SetAccessibleName(notifier_->name); |
304 | 304 |
305 if (ShouldHaveLearnMoreButton()) { | 305 if (ShouldHaveLearnMoreButton()) { |
306 // Create a more-info button that will be right-aligned. | 306 // Create a more-info button that will be right-aligned. |
307 learn_more_ = new views::ImageButton(this); | 307 learn_more_ = new views::ImageButton(this); |
308 learn_more_->SetFocusPainter(CreateFocusPainter()); | 308 learn_more_->SetFocusPainter(CreateFocusPainter()); |
309 learn_more_->set_request_focus_on_press(false); | 309 learn_more_->set_request_focus_on_press(false); |
310 learn_more_->SetFocusable(true); | 310 views::Button::ConfigureDefaultFocus(learn_more_); |
311 | 311 |
312 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 312 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
313 learn_more_->SetImage( | 313 learn_more_->SetImage( |
314 views::Button::STATE_NORMAL, | 314 views::Button::STATE_NORMAL, |
315 rb.GetImageSkiaNamed(IDR_NOTIFICATION_ADVANCED_SETTINGS)); | 315 rb.GetImageSkiaNamed(IDR_NOTIFICATION_ADVANCED_SETTINGS)); |
316 learn_more_->SetImage( | 316 learn_more_->SetImage( |
317 views::Button::STATE_HOVERED, | 317 views::Button::STATE_HOVERED, |
318 rb.GetImageSkiaNamed(IDR_NOTIFICATION_ADVANCED_SETTINGS_HOVER)); | 318 rb.GetImageSkiaNamed(IDR_NOTIFICATION_ADVANCED_SETTINGS_HOVER)); |
319 learn_more_->SetImage( | 319 learn_more_->SetImage( |
320 views::Button::STATE_PRESSED, | 320 views::Button::STATE_PRESSED, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 NotifierSettingsView::NotifierSettingsView(NotifierSettingsProvider* provider) | 470 NotifierSettingsView::NotifierSettingsView(NotifierSettingsProvider* provider) |
471 : title_arrow_(NULL), | 471 : title_arrow_(NULL), |
472 title_label_(NULL), | 472 title_label_(NULL), |
473 notifier_group_selector_(NULL), | 473 notifier_group_selector_(NULL), |
474 scroller_(NULL), | 474 scroller_(NULL), |
475 provider_(provider) { | 475 provider_(provider) { |
476 // |provider_| may be NULL in tests. | 476 // |provider_| may be NULL in tests. |
477 if (provider_) | 477 if (provider_) |
478 provider_->AddObserver(this); | 478 provider_->AddObserver(this); |
479 | 479 |
480 SetFocusable(true); | 480 SetFocusBehavior(FocusBehavior::ALWAYS); |
481 set_background( | 481 set_background( |
482 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); | 482 views::Background::CreateSolidBackground(kMessageCenterBackgroundColor)); |
483 SetPaintToLayer(true); | 483 SetPaintToLayer(true); |
484 | 484 |
485 title_label_ = new views::Label( | 485 title_label_ = new views::Label( |
486 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL), | 486 l10n_util::GetStringUTF16(IDS_MESSAGE_CENTER_SETTINGS_BUTTON_LABEL), |
487 ui::ResourceBundle::GetSharedInstance().GetFontList( | 487 ui::ResourceBundle::GetSharedInstance().GetFontList( |
488 ui::ResourceBundle::MediumFont)); | 488 ui::ResourceBundle::MediumFont)); |
489 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 489 title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
490 title_label_->SetMultiLine(true); | 490 title_label_->SetMultiLine(true); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
576 if (need_account_switcher) { | 576 if (need_account_switcher) { |
577 const NotifierGroup& active_group = provider_->GetActiveNotifierGroup(); | 577 const NotifierGroup& active_group = provider_->GetActiveNotifierGroup(); |
578 base::string16 notifier_group_text = active_group.login_info.empty() ? | 578 base::string16 notifier_group_text = active_group.login_info.empty() ? |
579 active_group.name : active_group.login_info; | 579 active_group.name : active_group.login_info; |
580 notifier_group_selector_ = | 580 notifier_group_selector_ = |
581 new views::MenuButton(notifier_group_text, this, true); | 581 new views::MenuButton(notifier_group_text, this, true); |
582 notifier_group_selector_->SetBorder(std::unique_ptr<views::Border>( | 582 notifier_group_selector_->SetBorder(std::unique_ptr<views::Border>( |
583 new views::LabelButtonAssetBorder(views::Button::STYLE_BUTTON))); | 583 new views::LabelButtonAssetBorder(views::Button::STYLE_BUTTON))); |
584 notifier_group_selector_->SetFocusPainter(nullptr); | 584 notifier_group_selector_->SetFocusPainter(nullptr); |
585 notifier_group_selector_->set_animate_on_state_change(false); | 585 notifier_group_selector_->set_animate_on_state_change(false); |
586 notifier_group_selector_->SetFocusable(true); | 586 |
| 587 views::Button::ConfigureDefaultFocus(notifier_group_selector_); |
587 contents_title_view->AddChildView(notifier_group_selector_); | 588 contents_title_view->AddChildView(notifier_group_selector_); |
588 } | 589 } |
589 | 590 |
590 contents_view->AddChildView(contents_title_view); | 591 contents_view->AddChildView(contents_title_view); |
591 | 592 |
592 size_t notifier_count = notifiers.size(); | 593 size_t notifier_count = notifiers.size(); |
593 for (size_t i = 0; i < notifier_count; ++i) { | 594 for (size_t i = 0; i < notifier_count; ++i) { |
594 NotifierButton* button = new NotifierButton(provider_, notifiers[i], this); | 595 NotifierButton* button = new NotifierButton(provider_, notifiers[i], this); |
595 EntryView* entry = new EntryView(button); | 596 EntryView* entry = new EntryView(button); |
596 | 597 |
597 // This code emulates separators using borders. We will create an invisible | 598 // This code emulates separators using borders. We will create an invisible |
598 // border on the last notifier, as the spec leaves a space for it. | 599 // border on the last notifier, as the spec leaves a space for it. |
599 std::unique_ptr<views::Border> entry_border; | 600 std::unique_ptr<views::Border> entry_border; |
600 if (i == notifier_count - 1) { | 601 if (i == notifier_count - 1) { |
601 entry_border = views::Border::CreateEmptyBorder( | 602 entry_border = views::Border::CreateEmptyBorder( |
602 0, 0, settings::kEntrySeparatorHeight, 0); | 603 0, 0, settings::kEntrySeparatorHeight, 0); |
603 } else { | 604 } else { |
604 entry_border = | 605 entry_border = |
605 views::Border::CreateSolidSidedBorder(0, | 606 views::Border::CreateSolidSidedBorder(0, |
606 0, | 607 0, |
607 settings::kEntrySeparatorHeight, | 608 settings::kEntrySeparatorHeight, |
608 0, | 609 0, |
609 settings::kEntrySeparatorColor); | 610 settings::kEntrySeparatorColor); |
610 } | 611 } |
611 entry->SetBorder(std::move(entry_border)); | 612 entry->SetBorder(std::move(entry_border)); |
612 entry->SetFocusable(true); | 613 entry->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); |
613 contents_view->AddChildView(entry); | 614 contents_view->AddChildView(entry); |
614 buttons_.insert(button); | 615 buttons_.insert(button); |
615 } | 616 } |
616 | 617 |
617 scroller_->SetContents(contents_view); | 618 scroller_->SetContents(contents_view); |
618 | 619 |
619 contents_view->SetBoundsRect(gfx::Rect(contents_view->GetPreferredSize())); | 620 contents_view->SetBoundsRect(gfx::Rect(contents_view->GetPreferredSize())); |
620 InvalidateLayout(); | 621 InvalidateLayout(); |
621 } | 622 } |
622 | 623 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 notifier_group_selector_, | 702 notifier_group_selector_, |
702 menu_anchor, | 703 menu_anchor, |
703 views::MENU_ANCHOR_BUBBLE_ABOVE, | 704 views::MENU_ANCHOR_BUBBLE_ABOVE, |
704 ui::MENU_SOURCE_MOUSE)) | 705 ui::MENU_SOURCE_MOUSE)) |
705 return; | 706 return; |
706 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); | 707 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); |
707 center_view->OnSettingsChanged(); | 708 center_view->OnSettingsChanged(); |
708 } | 709 } |
709 | 710 |
710 } // namespace message_center | 711 } // namespace message_center |
OLD | NEW |