| Index: ui/message_center/views/message_center_view_unittest.cc
 | 
| diff --git a/ui/message_center/views/message_center_view_unittest.cc b/ui/message_center/views/message_center_view_unittest.cc
 | 
| index 268d5bdcd9291d202cb54884e4bdad81e69d9e8a..2ccdbb70756b48b7912a600cf72ef0e1e780978d 100644
 | 
| --- a/ui/message_center/views/message_center_view_unittest.cc
 | 
| +++ b/ui/message_center/views/message_center_view_unittest.cc
 | 
| @@ -10,6 +10,7 @@
 | 
|  
 | 
|  #include "base/logging.h"
 | 
|  #include "base/macros.h"
 | 
| +#include "base/memory/ptr_util.h"
 | 
|  #include "base/run_loop.h"
 | 
|  #include "base/strings/utf_string_conversions.h"
 | 
|  #include "testing/gtest/include/gtest/gtest.h"
 | 
| @@ -121,7 +122,7 @@ class MessageCenterViewTest : public views::ViewsTestBase,
 | 
|                                public MessageCenterController {
 | 
|   public:
 | 
|    // Expose the private enum class MessageCenter::Mode for this test.
 | 
| -  typedef MessageCenterView::Mode Mode;
 | 
| +  using Mode = MessageCenterView::Mode;
 | 
|  
 | 
|    MessageCenterViewTest();
 | 
|    ~MessageCenterViewTest() override;
 | 
| @@ -129,6 +130,7 @@ class MessageCenterViewTest : public views::ViewsTestBase,
 | 
|    void SetUp() override;
 | 
|    void TearDown() override;
 | 
|  
 | 
| +  NotificationList::Notifications Notifications();
 | 
|    MessageCenterView* GetMessageCenterView();
 | 
|    MessageListView* GetMessageListView();
 | 
|    FakeMessageCenterImpl* GetMessageCenter() const;
 | 
| @@ -169,7 +171,8 @@ class MessageCenterViewTest : public views::ViewsTestBase,
 | 
|   private:
 | 
|    views::View* MakeParent(views::View* child1, views::View* child2);
 | 
|  
 | 
| -  NotificationList::Notifications notifications_;
 | 
| +  // The ownership map of notifications; the key is the id.
 | 
| +  std::map<std::string, std::unique_ptr<Notification>> notifications_;
 | 
|    std::unique_ptr<views::Widget> widget_;
 | 
|    std::unique_ptr<MessageCenterView> message_center_view_;
 | 
|    std::unique_ptr<FakeMessageCenterImpl> message_center_;
 | 
| @@ -190,31 +193,32 @@ void MessageCenterViewTest::SetUp() {
 | 
|    message_center_.reset(new FakeMessageCenterImpl());
 | 
|  
 | 
|    // Create a dummy notification.
 | 
| -  Notification* notification1 = new Notification(
 | 
| +  std::unique_ptr<Notification> notification1 = base::MakeUnique<Notification>(
 | 
|        NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1),
 | 
|        base::UTF8ToUTF16("title"), base::UTF8ToUTF16("message1"), gfx::Image(),
 | 
|        base::UTF8ToUTF16("display source"), GURL(),
 | 
|        NotifierId(NotifierId::APPLICATION, "extension_id"),
 | 
| -      message_center::RichNotificationData(), NULL);
 | 
| +      message_center::RichNotificationData(), nullptr);
 | 
|  
 | 
| -  Notification* notification2 = new Notification(
 | 
| +  std::unique_ptr<Notification> notification2 = base::MakeUnique<Notification>(
 | 
|        NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId2),
 | 
|        base::UTF8ToUTF16("title2"), base::UTF8ToUTF16("message2"), gfx::Image(),
 | 
|        base::UTF8ToUTF16("display source"), GURL(),
 | 
|        NotifierId(NotifierId::APPLICATION, "extension_id"),
 | 
| -      message_center::RichNotificationData(), NULL);
 | 
| +      message_center::RichNotificationData(), nullptr);
 | 
|  
 | 
|    // ...and a list for it.
 | 
| -  notifications_.insert(notification1);
 | 
| -  notifications_.insert(notification2);
 | 
| -  message_center_->SetVisibleNotifications(notifications_);
 | 
| +  notifications_[std::string(kNotificationId1)] = std::move(notification1);
 | 
| +  notifications_[std::string(kNotificationId2)] = std::move(notification2);
 | 
| +  NotificationList::Notifications notifications = Notifications();
 | 
| +  message_center_->SetVisibleNotifications(notifications);
 | 
|  
 | 
|    // Then create a new MessageCenterView with that single notification.
 | 
|    message_center_view_.reset(new MessageCenterView(
 | 
|        message_center_.get(), NULL, 100, false, /*top_down =*/false));
 | 
|    GetMessageListView()->quit_message_loop_after_animation_for_test_ = true;
 | 
|    GetMessageCenterView()->SetBounds(0, 0, 380, 600);
 | 
| -  message_center_view_->SetNotifications(notifications_);
 | 
| +  message_center_view_->SetNotifications(notifications);
 | 
|    message_center_view_->set_owned_by_client();
 | 
|  
 | 
|    widget_.reset(new views::Widget());
 | 
| @@ -237,10 +241,18 @@ void MessageCenterViewTest::TearDown() {
 | 
|    widget_->CloseNow();
 | 
|    widget_.reset();
 | 
|    message_center_view_.reset();
 | 
| -  base::STLDeleteElements(¬ifications_);
 | 
| +  notifications_.clear();
 | 
|    views::ViewsTestBase::TearDown();
 | 
|  }
 | 
|  
 | 
| +NotificationList::Notifications MessageCenterViewTest::Notifications() {
 | 
| +  NotificationList::Notifications result;
 | 
| +  for (const auto& notification_pair : notifications_)
 | 
| +    result.insert(notification_pair.second.get());
 | 
| +
 | 
| +  return result;
 | 
| +}
 | 
| +
 | 
|  MessageCenterView* MessageCenterViewTest::GetMessageCenterView() {
 | 
|    return message_center_view_.get();
 | 
|  }
 | 
| @@ -291,39 +303,27 @@ void MessageCenterViewTest::ClickOnNotification(
 | 
|  void MessageCenterViewTest::AddNotification(
 | 
|      std::unique_ptr<Notification> notification) {
 | 
|    std::string notification_id = notification->id();
 | 
| -  notifications_.insert(notification.release());
 | 
| -  message_center_->SetVisibleNotifications(notifications_);
 | 
| +  notifications_[notification_id] = std::move(notification);
 | 
| +  message_center_->SetVisibleNotifications(Notifications());
 | 
|    message_center_view_->OnNotificationAdded(notification_id);
 | 
|  }
 | 
|  
 | 
|  void MessageCenterViewTest::UpdateNotification(
 | 
|      const std::string& notification_id,
 | 
|      std::unique_ptr<Notification> notification) {
 | 
| -  for (auto it = notifications_.begin(); it != notifications_.end(); it++) {
 | 
| -    if ((*it)->id() == notification_id) {
 | 
| -      delete *it;
 | 
| -      notifications_.erase(it);
 | 
| -      break;
 | 
| -    }
 | 
| -  }
 | 
| -  // |notifications| is a "set" container so we don't need to be aware the
 | 
| -  // order.
 | 
| -  notifications_.insert(notification.release());
 | 
| -  message_center_->SetVisibleNotifications(notifications_);
 | 
| +  DCHECK_EQ(notification_id, notification->id());
 | 
| +  notifications_[notification_id] = std::move(notification);
 | 
| +
 | 
| +  message_center_->SetVisibleNotifications(Notifications());
 | 
|    message_center_view_->OnNotificationUpdated(notification_id);
 | 
|  }
 | 
|  
 | 
|  void MessageCenterViewTest::RemoveNotification(
 | 
|      const std::string& notification_id,
 | 
|      bool by_user) {
 | 
| -  for (auto it = notifications_.begin(); it != notifications_.end(); it++) {
 | 
| -    if ((*it)->id() == notification_id) {
 | 
| -      delete *it;
 | 
| -      notifications_.erase(it);
 | 
| -      break;
 | 
| -    }
 | 
| -  }
 | 
| -  message_center_->SetVisibleNotifications(notifications_);
 | 
| +  notifications_.erase(notification_id);
 | 
| +
 | 
| +  message_center_->SetVisibleNotifications(Notifications());
 | 
|    message_center_view_->OnNotificationRemoved(notification_id, by_user);
 | 
|  }
 | 
|  
 | 
| @@ -419,13 +419,13 @@ TEST_F(MessageCenterViewTest, SizeAfterUpdate) {
 | 
|    int width =
 | 
|        GetMessageListView()->width() - GetMessageListView()->GetInsets().width();
 | 
|  
 | 
| -  std::unique_ptr<Notification> notification(new Notification(
 | 
| +  std::unique_ptr<Notification> notification = base::MakeUnique<Notification>(
 | 
|        NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId2),
 | 
|        base::UTF8ToUTF16("title2"),
 | 
|        base::UTF8ToUTF16("message\nwhich\nis\nvertically\nlong\n."),
 | 
|        gfx::Image(), base::UTF8ToUTF16("display source"), GURL(),
 | 
|        NotifierId(NotifierId::APPLICATION, "extension_id"),
 | 
| -      message_center::RichNotificationData(), NULL));
 | 
| +      message_center::RichNotificationData(), nullptr);
 | 
|  
 | 
|    EXPECT_EQ(
 | 
|        GetMessageListView()->height(),
 | 
| @@ -487,13 +487,13 @@ TEST_F(MessageCenterViewTest, PositionAfterUpdate) {
 | 
|    GetMessageListView()->SetRepositionTargetForTest(
 | 
|        GetNotificationView(kNotificationId1)->bounds());
 | 
|  
 | 
| -  std::unique_ptr<Notification> notification(new Notification(
 | 
| +  std::unique_ptr<Notification> notification = base::MakeUnique<Notification>(
 | 
|        NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId2),
 | 
|        base::UTF8ToUTF16("title2"),
 | 
|        base::UTF8ToUTF16("message\nwhich\nis\nvertically\nlong\n."),
 | 
|        gfx::Image(), base::UTF8ToUTF16("display source"), GURL(),
 | 
|        NotifierId(NotifierId::APPLICATION, "extension_id"),
 | 
| -      message_center::RichNotificationData(), NULL));
 | 
| +      message_center::RichNotificationData(), nullptr);
 | 
|    UpdateNotification(kNotificationId2, std::move(notification));
 | 
|  
 | 
|    // Wait until the animation finishes if available.
 | 
| @@ -613,32 +613,28 @@ TEST_F(MessageCenterViewTest, CloseButtonEnablity) {
 | 
|        message_center::RichNotificationData(), NULL);
 | 
|    pinned_notification2.set_pinned(true);
 | 
|  
 | 
| -  AddNotification(
 | 
| -      std::unique_ptr<Notification>(new Notification(normal_notification1)));
 | 
| +  AddNotification(base::MakeUnique<Notification>(normal_notification1));
 | 
|  
 | 
|    // There should be 1 non-pinned notification.
 | 
|    EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size());
 | 
|    EXPECT_TRUE(close_button->enabled());
 | 
|  
 | 
| -  UpdateNotification(
 | 
| -      kNotificationId1,
 | 
| -      std::unique_ptr<Notification>(new Notification(pinned_notification1)));
 | 
| +  UpdateNotification(kNotificationId1,
 | 
| +                     base::MakeUnique<Notification>(pinned_notification1));
 | 
|  
 | 
|    // There should be 1 pinned notification.
 | 
|    EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size());
 | 
|    EXPECT_FALSE(close_button->enabled());
 | 
|  
 | 
|    // Adds 1 pinned notification.
 | 
| -  AddNotification(
 | 
| -      std::unique_ptr<Notification>(new Notification(pinned_notification2)));
 | 
| +  AddNotification(base::MakeUnique<Notification>(pinned_notification2));
 | 
|  
 | 
|    // There should be 1 pinned notification.
 | 
|    EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size());
 | 
|    EXPECT_FALSE(close_button->enabled());
 | 
|  
 | 
| -  UpdateNotification(
 | 
| -      kNotificationId1,
 | 
| -      std::unique_ptr<Notification>(new Notification(normal_notification1)));
 | 
| +  UpdateNotification(kNotificationId1,
 | 
| +                     base::MakeUnique<Notification>(normal_notification1));
 | 
|  
 | 
|    // There should be 1 normal notification and 1 pinned notification.
 | 
|    EXPECT_EQ(2u, GetMessageCenter()->GetVisibleNotifications().size());
 | 
| @@ -656,8 +652,7 @@ TEST_F(MessageCenterViewTest, CloseButtonEnablity) {
 | 
|    EXPECT_EQ(0u, GetMessageCenter()->GetVisibleNotifications().size());
 | 
|    EXPECT_FALSE(close_button->enabled());
 | 
|  
 | 
| -  AddNotification(
 | 
| -      std::unique_ptr<Notification>(new Notification(pinned_notification2)));
 | 
| +  AddNotification(base::MakeUnique<Notification>(pinned_notification2));
 | 
|  
 | 
|    // There should be 1 pinned notification.
 | 
|    EXPECT_EQ(1u, GetMessageCenter()->GetVisibleNotifications().size());
 | 
| @@ -685,15 +680,13 @@ TEST_F(MessageCenterViewTest, CheckModeWithRemovingAndAddingNotifications) {
 | 
|    EXPECT_EQ(Mode::BUTTONS_ONLY, GetMessageCenterViewInternalMode());
 | 
|  
 | 
|    // Add a notification.
 | 
| -  Notification normal_notification(
 | 
| +  AddNotification(base::MakeUnique<Notification>(
 | 
|        NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1),
 | 
|        base::UTF8ToUTF16("title2"),
 | 
|        base::UTF8ToUTF16("message\nwhich\nis\nvertically\nlong\n."),
 | 
|        gfx::Image(), base::UTF8ToUTF16("display source"), GURL(),
 | 
|        NotifierId(NotifierId::APPLICATION, "extension_id"),
 | 
| -      message_center::RichNotificationData(), NULL);
 | 
| -  AddNotification(
 | 
| -      std::unique_ptr<Notification>(new Notification(normal_notification)));
 | 
| +      message_center::RichNotificationData(), nullptr));
 | 
|    EXPECT_EQ(Mode::NOTIFICATIONS, GetMessageCenterViewInternalMode());
 | 
|  }
 | 
|  
 | 
| @@ -742,15 +735,13 @@ TEST_F(MessageCenterViewTest,
 | 
|    EXPECT_EQ(Mode::SETTINGS, GetMessageCenterViewInternalMode());
 | 
|  
 | 
|    // Add a notification during settings is visible.
 | 
| -  Notification normal_notification(
 | 
| +  AddNotification(base::MakeUnique<Notification>(
 | 
|        NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1),
 | 
|        base::UTF8ToUTF16("title2"),
 | 
|        base::UTF8ToUTF16("message\nwhich\nis\nvertically\nlong\n."),
 | 
|        gfx::Image(), base::UTF8ToUTF16("display source"), GURL(),
 | 
|        NotifierId(NotifierId::APPLICATION, "extension_id"),
 | 
| -      message_center::RichNotificationData(), NULL);
 | 
| -  AddNotification(
 | 
| -      std::unique_ptr<Notification>(new Notification(normal_notification)));
 | 
| +      message_center::RichNotificationData(), nullptr));
 | 
|    EXPECT_EQ(Mode::SETTINGS, GetMessageCenterViewInternalMode());
 | 
|  
 | 
|    // Hide the settings.
 | 
| @@ -783,13 +774,12 @@ TEST_F(MessageCenterViewTest, LockScreen) {
 | 
|    GetMessageCenterView()->SizeToPreferredSize();
 | 
|    EXPECT_EQ(kLockedMessageCenterViewHeight, GetMessageCenterView()->height());
 | 
|  
 | 
| -  AddNotification(std::unique_ptr<Notification>(new Notification(
 | 
| +  AddNotification(base::MakeUnique<Notification>(
 | 
|        NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1),
 | 
| -      base::UTF8ToUTF16("title1"),
 | 
| -      base::UTF8ToUTF16("message"),
 | 
| -      gfx::Image(), base::UTF8ToUTF16("display source"), GURL(),
 | 
| +      base::UTF8ToUTF16("title1"), base::UTF8ToUTF16("message"), gfx::Image(),
 | 
| +      base::UTF8ToUTF16("display source"), GURL(),
 | 
|        NotifierId(NotifierId::APPLICATION, "extension_id"),
 | 
| -      message_center::RichNotificationData(), NULL)));
 | 
| +      message_center::RichNotificationData(), nullptr));
 | 
|    EXPECT_FALSE(GetNotificationView(kNotificationId1)->IsDrawn());
 | 
|  
 | 
|    GetMessageCenterView()->SizeToPreferredSize();
 | 
| @@ -824,13 +814,12 @@ TEST_F(MessageCenterViewTest, NoNotification) {
 | 
|    GetMessageCenterView()->SizeToPreferredSize();
 | 
|    EXPECT_EQ(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height());
 | 
|  
 | 
| -  AddNotification(std::unique_ptr<Notification>(new Notification(
 | 
| +  AddNotification(base::MakeUnique<Notification>(
 | 
|        NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId1),
 | 
| -      base::UTF8ToUTF16("title1"),
 | 
| -      base::UTF8ToUTF16("message"),
 | 
| -      gfx::Image(), base::UTF8ToUTF16("display source"), GURL(),
 | 
| +      base::UTF8ToUTF16("title1"), base::UTF8ToUTF16("message"), gfx::Image(),
 | 
| +      base::UTF8ToUTF16("display source"), GURL(),
 | 
|        NotifierId(NotifierId::APPLICATION, "extension_id"),
 | 
| -      message_center::RichNotificationData(), NULL)));
 | 
| +      message_center::RichNotificationData(), nullptr));
 | 
|  
 | 
|    GetMessageCenterView()->SizeToPreferredSize();
 | 
|    EXPECT_NE(kEmptyMessageCenterViewHeight, GetMessageCenterView()->height());
 | 
| 
 |