Commit 793f7de2 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Whittle away some Chrome dependencies on ui/message_center

Bug: 723882
Change-Id: I47cbb2d5fefeed201117d0f8ccc1d85f67de43da
Reviewed-on: https://chromium-review.googlesource.com/615881
Commit-Queue: Evan Stade <estade@chromium.org>
Reviewed-by: default avatarYoshiki Iguchi <yoshiki@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#496549}
parent f19e0e3d
......@@ -2622,6 +2622,8 @@ split_static_library("browser") {
"metrics/desktop_session_duration/desktop_session_duration_tracker.h",
"net/disk_cache_dir_policy_handler.cc",
"net/disk_cache_dir_policy_handler.h",
"notifications/screen_lock_notification_blocker.cc",
"notifications/screen_lock_notification_blocker.h",
"platform_util.cc",
"policy/cloud/user_policy_signin_service.cc",
"policy/cloud/user_policy_signin_service.h",
......@@ -3380,8 +3382,6 @@ split_static_library("browser") {
"notifications/notifier_source.h",
"notifications/profile_notification.cc",
"notifications/profile_notification.h",
"notifications/screen_lock_notification_blocker.cc",
"notifications/screen_lock_notification_blocker.h",
"notifications/system_component_notifier_source_chromeos.cc",
"notifications/system_component_notifier_source_chromeos.h",
"notifications/web_page_notifier_source.cc",
......
......@@ -947,22 +947,15 @@ Profile* DownloadItemNotification::profile() const {
}
bool DownloadItemNotification::IsNotificationVisible() const {
const std::string& notification_id = watcher()->id();
const std::string& delegate_id = watcher()->id();
const ProfileID profile_id = NotificationUIManager::GetProfileID(profile());
if (!g_browser_process->notification_ui_manager())
return false;
const Notification* notification = g_browser_process->
notification_ui_manager()->FindById(notification_id, profile_id);
const Notification* notification =
g_browser_process->notification_ui_manager()->FindById(delegate_id,
profile_id);
if (!notification)
return false;
const std::string notification_id_in_message_center = notification->id();
message_center::NotificationList::Notifications visible_notifications =
message_center_->GetVisibleNotifications();
for (auto* notification : visible_notifications) {
if (notification->id() == notification_id_in_message_center)
return true;
}
return false;
return !!message_center_->FindVisibleNotificationById(notification->id());
}
......@@ -16,7 +16,6 @@
#include "chrome/browser/notifications/message_center_settings_controller.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/notifications/profile_notification.h"
#include "chrome/browser/notifications/screen_lock_notification_blocker.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
......@@ -32,6 +31,8 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/notifications/login_state_notification_blocker_chromeos.h"
#else
#include "chrome/browser/notifications/screen_lock_notification_blocker.h"
#endif
using message_center::NotifierId;
......
......@@ -21,7 +21,6 @@
#include "content/public/test/test_browser_thread_bundle.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/message_center/fake_message_center_tray_delegate.h"
#include "ui/message_center/message_center_impl.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_types.h"
#include "ui/message_center/notification_types.h"
......
......@@ -53,7 +53,11 @@ bool FakeMessageCenter::HasClickedListener(const std::string& id) {
message_center::Notification* FakeMessageCenter::FindVisibleNotificationById(
const std::string& id) {
return NULL;
for (auto* notification : GetVisibleNotifications()) {
if (id == notification->id())
return notification;
}
return nullptr;
}
const NotificationList::Notifications&
......
......@@ -8,7 +8,6 @@
#include "ui/display/screen.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/views/message_popup_collection.h"
namespace message_center {
......
......@@ -668,26 +668,19 @@ void MessageCenterView::UpdateNotification(const std::string& id) {
if (view_iter == notification_views_.end())
return;
// TODO(dimich): add MessageCenter::GetVisibleNotificationById(id)
MessageView* view = view_iter->second;
const NotificationList::Notifications& notifications =
message_center_->GetVisibleNotifications();
for (NotificationList::Notifications::const_iterator iter =
notifications.begin();
iter != notifications.end(); ++iter) {
if ((*iter)->id() == id) {
int old_width = view->width();
int old_height = view->height();
bool old_pinned = view->GetPinned();
message_list_view_->UpdateNotification(view, **iter);
if (view->GetHeightForWidth(old_width) != old_height) {
Update(true /* animate */);
} else if (view->GetPinned() != old_pinned) {
// Animate flag is false, since the pinned flag transition doesn't need
// animation.
Update(false /* animate */);
}
break;
Notification* notification = message_center_->FindVisibleNotificationById(id);
if (notification) {
int old_width = view->width();
int old_height = view->height();
bool old_pinned = view->GetPinned();
message_list_view_->UpdateNotification(view, *notification);
if (view->GetHeightForWidth(old_width) != old_height) {
Update(true /* animate */);
} else if (view->GetPinned() != old_pinned) {
// Animate flag is false, since the pinned flag transition doesn't need
// animation.
Update(false /* animate */);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment