| 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(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 learn_more_->SetFocusBehavior(FocusBehavior::ALWAYS); |
| 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 notifier_group_selector_->SetFocusBehavior(FocusBehavior::ALWAYS); |
| 587 contents_title_view->AddChildView(notifier_group_selector_); | 587 contents_title_view->AddChildView(notifier_group_selector_); |
| 588 } | 588 } |
| 589 | 589 |
| 590 contents_view->AddChildView(contents_title_view); | 590 contents_view->AddChildView(contents_title_view); |
| 591 | 591 |
| 592 size_t notifier_count = notifiers.size(); | 592 size_t notifier_count = notifiers.size(); |
| 593 for (size_t i = 0; i < notifier_count; ++i) { | 593 for (size_t i = 0; i < notifier_count; ++i) { |
| 594 NotifierButton* button = new NotifierButton(provider_, notifiers[i], this); | 594 NotifierButton* button = new NotifierButton(provider_, notifiers[i], this); |
| 595 EntryView* entry = new EntryView(button); | 595 EntryView* entry = new EntryView(button); |
| 596 | 596 |
| 597 // This code emulates separators using borders. We will create an invisible | 597 // 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. | 598 // border on the last notifier, as the spec leaves a space for it. |
| 599 std::unique_ptr<views::Border> entry_border; | 599 std::unique_ptr<views::Border> entry_border; |
| 600 if (i == notifier_count - 1) { | 600 if (i == notifier_count - 1) { |
| 601 entry_border = views::Border::CreateEmptyBorder( | 601 entry_border = views::Border::CreateEmptyBorder( |
| 602 0, 0, settings::kEntrySeparatorHeight, 0); | 602 0, 0, settings::kEntrySeparatorHeight, 0); |
| 603 } else { | 603 } else { |
| 604 entry_border = | 604 entry_border = |
| 605 views::Border::CreateSolidSidedBorder(0, | 605 views::Border::CreateSolidSidedBorder(0, |
| 606 0, | 606 0, |
| 607 settings::kEntrySeparatorHeight, | 607 settings::kEntrySeparatorHeight, |
| 608 0, | 608 0, |
| 609 settings::kEntrySeparatorColor); | 609 settings::kEntrySeparatorColor); |
| 610 } | 610 } |
| 611 entry->SetBorder(std::move(entry_border)); | 611 entry->SetBorder(std::move(entry_border)); |
| 612 entry->SetFocusable(true); | 612 entry->SetFocusBehavior(FocusBehavior::ALWAYS); |
| 613 contents_view->AddChildView(entry); | 613 contents_view->AddChildView(entry); |
| 614 buttons_.insert(button); | 614 buttons_.insert(button); |
| 615 } | 615 } |
| 616 | 616 |
| 617 scroller_->SetContents(contents_view); | 617 scroller_->SetContents(contents_view); |
| 618 | 618 |
| 619 contents_view->SetBoundsRect(gfx::Rect(contents_view->GetPreferredSize())); | 619 contents_view->SetBoundsRect(gfx::Rect(contents_view->GetPreferredSize())); |
| 620 InvalidateLayout(); | 620 InvalidateLayout(); |
| 621 } | 621 } |
| 622 | 622 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 notifier_group_selector_, | 701 notifier_group_selector_, |
| 702 menu_anchor, | 702 menu_anchor, |
| 703 views::MENU_ANCHOR_BUBBLE_ABOVE, | 703 views::MENU_ANCHOR_BUBBLE_ABOVE, |
| 704 ui::MENU_SOURCE_MOUSE)) | 704 ui::MENU_SOURCE_MOUSE)) |
| 705 return; | 705 return; |
| 706 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); | 706 MessageCenterView* center_view = static_cast<MessageCenterView*>(parent()); |
| 707 center_view->OnSettingsChanged(); | 707 center_view->OnSettingsChanged(); |
| 708 } | 708 } |
| 709 | 709 |
| 710 } // namespace message_center | 710 } // namespace message_center |
| OLD | NEW |