Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: ui/message_center/views/notifier_settings_view.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // space included in the title label. 112 // space included in the title label.
113 const int kComputedTitleTopMargin = 113 const int kComputedTitleTopMargin =
114 settings::kTopMargin - kInnateTitleTopMargin; 114 settings::kTopMargin - kInnateTitleTopMargin;
115 115
116 // The switcher has a lot of blank space built in so we should include that when 116 // The switcher has a lot of blank space built in so we should include that when
117 // spacing the title area vertically. 117 // spacing the title area vertically.
118 const int kComputedTitleElementSpacing = 118 const int kComputedTitleElementSpacing =
119 settings::kDescriptionToSwitcherSpace - 6; 119 settings::kDescriptionToSwitcherSpace - 6;
120 120
121 // A function to create a focus border. 121 // A function to create a focus border.
122 scoped_ptr<views::Painter> CreateFocusPainter() { 122 std::unique_ptr<views::Painter> CreateFocusPainter() {
123 return views::Painter::CreateSolidFocusPainter(kFocusBorderColor, 123 return views::Painter::CreateSolidFocusPainter(kFocusBorderColor,
124 gfx::Insets(1, 2, 3, 2)); 124 gfx::Insets(1, 2, 3, 2));
125 } 125 }
126 126
127 // EntryView ------------------------------------------------------------------ 127 // EntryView ------------------------------------------------------------------
128 128
129 // The view to guarantee the 48px height and place the contents at the 129 // The view to guarantee the 48px height and place the contents at the
130 // middle. It also guarantee the left margin. 130 // middle. It also guarantee the left margin.
131 class EntryView : public views::View { 131 class EntryView : public views::View {
132 public: 132 public:
133 explicit EntryView(views::View* contents); 133 explicit EntryView(views::View* contents);
134 ~EntryView() override; 134 ~EntryView() override;
135 135
136 // views::View: 136 // views::View:
137 void Layout() override; 137 void Layout() override;
138 gfx::Size GetPreferredSize() const override; 138 gfx::Size GetPreferredSize() const override;
139 void GetAccessibleState(ui::AXViewState* state) override; 139 void GetAccessibleState(ui::AXViewState* state) override;
140 void OnFocus() override; 140 void OnFocus() override;
141 bool OnKeyPressed(const ui::KeyEvent& event) override; 141 bool OnKeyPressed(const ui::KeyEvent& event) override;
142 bool OnKeyReleased(const ui::KeyEvent& event) override; 142 bool OnKeyReleased(const ui::KeyEvent& event) override;
143 void OnPaint(gfx::Canvas* canvas) override; 143 void OnPaint(gfx::Canvas* canvas) override;
144 void OnBlur() override; 144 void OnBlur() override;
145 145
146 private: 146 private:
147 scoped_ptr<views::Painter> focus_painter_; 147 std::unique_ptr<views::Painter> focus_painter_;
148 148
149 DISALLOW_COPY_AND_ASSIGN(EntryView); 149 DISALLOW_COPY_AND_ASSIGN(EntryView);
150 }; 150 };
151 151
152 EntryView::EntryView(views::View* contents) 152 EntryView::EntryView(views::View* contents)
153 : focus_painter_(CreateFocusPainter()) { 153 : focus_painter_(CreateFocusPainter()) {
154 AddChildView(contents); 154 AddChildView(contents);
155 } 155 }
156 156
157 EntryView::~EntryView() {} 157 EntryView::~EntryView() {}
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 0, 572 0,
573 settings::kTitleMargin + kMenuButtonInnateMargin)); 573 settings::kTitleMargin + kMenuButtonInnateMargin));
574 contents_title_view->AddChildView(top_label); 574 contents_title_view->AddChildView(top_label);
575 575
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(scoped_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_->SetFocusable(true);
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 scoped_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);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « ui/message_center/views/notifier_settings_view.h ('k') | ui/message_center/views/notifier_settings_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698