Commit 613c9776 authored by Tina Wang's avatar Tina Wang Committed by Commit Bot

[SendTabToSelf] Add icon to Windows notification

Previously the notification on Windows doesn't have an image on the left.
Add Chrome logo to be the image.

Previous: https://screenshot.googleplex.com/czHKUPwf9Bu
Now(image will change base on channel):
https://screenshot.googleplex.com/p3oeicKOEf5

Bug: 952428
Change-Id: Ibc972b977806d8f8c2e4b44fa852f12dd40a0827
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1565448
Commit-Queue: Tina Wang <tinazwang@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Reviewed-by: default avatarsebsg <sebsg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#651798}
parent fc5a7c58
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "chrome/browser/notifications/notification_display_service.h" #include "chrome/browser/notifications/notification_display_service.h"
#include "chrome/browser/notifications/notification_display_service_factory.h" #include "chrome/browser/notifications/notification_display_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/send_tab_to_self/send_tab_to_self_desktop_util.h"
#include "chrome/browser/sync/send_tab_to_self_sync_service_factory.h" #include "chrome/browser/sync/send_tab_to_self_sync_service_factory.h"
#include "chrome/browser/ui/browser_navigator.h" #include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_navigator_params.h" #include "chrome/browser/ui/browser_navigator_params.h"
...@@ -74,9 +75,9 @@ void DesktopNotificationHandler::DisplayNewEntries( ...@@ -74,9 +75,9 @@ void DesktopNotificationHandler::DisplayNewEntries(
// Declare a notification // Declare a notification
message_center::Notification notification( message_center::Notification notification(
message_center::NOTIFICATION_TYPE_SIMPLE, entry->GetGUID(), message_center::NOTIFICATION_TYPE_SIMPLE, entry->GetGUID(),
base::UTF8ToUTF16(entry->GetTitle()), device_info, gfx::Image(), base::UTF8ToUTF16(entry->GetTitle()), device_info,
base::UTF8ToUTF16(url.host()), url, message_center::NotifierId(url), GetImageForNotification(), base::UTF8ToUTF16(url.host()), url,
optional_fields, /*delegate=*/nullptr); message_center::NotifierId(url), optional_fields, /*delegate=*/nullptr);
NotificationDisplayServiceFactory::GetForProfile(profile_)->Display( NotificationDisplayServiceFactory::GetForProfile(profile_)->Display(
NotificationHandler::Type::SEND_TAB_TO_SELF, notification, NotificationHandler::Type::SEND_TAB_TO_SELF, notification,
/*metadata=*/nullptr); /*metadata=*/nullptr);
...@@ -140,7 +141,7 @@ void DesktopNotificationHandler::DisplaySendingConfirmation( ...@@ -140,7 +141,7 @@ void DesktopNotificationHandler::DisplaySendingConfirmation(
kDesktopNotificationSharedPrefix + entry.GetGUID(), kDesktopNotificationSharedPrefix + entry.GetGUID(),
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS), IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_SUCCESS),
base::UTF8ToUTF16(entry.GetTitle()), gfx::Image(), base::UTF8ToUTF16(entry.GetTitle()), GetImageForNotification(),
base::UTF8ToUTF16(url.host()), url, message_center::NotifierId(url), base::UTF8ToUTF16(url.host()), url, message_center::NotifierId(url),
message_center::RichNotificationData(), /*delegate=*/nullptr); message_center::RichNotificationData(), /*delegate=*/nullptr);
NotificationDisplayServiceFactory::GetForProfile(profile_)->Display( NotificationDisplayServiceFactory::GetForProfile(profile_)->Display(
...@@ -156,7 +157,7 @@ void DesktopNotificationHandler::DisplayFailureMessage(const GURL& url) { ...@@ -156,7 +157,7 @@ void DesktopNotificationHandler::DisplayFailureMessage(const GURL& url) {
IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_FAILURE_TITLE), IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_FAILURE_TITLE),
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_FAILURE_MESSAGE), IDS_MESSAGE_NOTIFICATION_SEND_TAB_TO_SELF_CONFIRMATION_FAILURE_MESSAGE),
gfx::Image(), base::UTF8ToUTF16(url.host()), url, GetImageForNotification(), base::UTF8ToUTF16(url.host()), url,
message_center::NotifierId(url), message_center::RichNotificationData(), message_center::NotifierId(url), message_center::RichNotificationData(),
/*delegate=*/nullptr); /*delegate=*/nullptr);
NotificationDisplayServiceFactory::GetForProfile(profile_)->Display( NotificationDisplayServiceFactory::GetForProfile(profile_)->Display(
......
...@@ -9,11 +9,15 @@ ...@@ -9,11 +9,15 @@
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/send_tab_to_self/desktop_notification_handler.h" #include "chrome/browser/send_tab_to_self/desktop_notification_handler.h"
#include "chrome/browser/sync/send_tab_to_self_sync_service_factory.h" #include "chrome/browser/sync/send_tab_to_self_sync_service_factory.h"
#include "chrome/common/channel_info.h"
#include "chrome/grit/theme_resources.h"
#include "components/send_tab_to_self/send_tab_to_self_model.h" #include "components/send_tab_to_self/send_tab_to_self_model.h"
#include "components/send_tab_to_self/send_tab_to_self_sync_service.h" #include "components/send_tab_to_self/send_tab_to_self_sync_service.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/navigation_entry.h" #include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/base/resource/resource_bundle.h" #include "ui/base/resource/resource_bundle.h"
...@@ -68,6 +72,43 @@ gfx::ImageSkia* GetImageSkia() { ...@@ -68,6 +72,43 @@ gfx::ImageSkia* GetImageSkia() {
return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id); return ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
} }
const gfx::Image GetImageForNotification() {
#if defined(OS_WIN)
// Set image to be chrome logo on window.
// Otherwise there will be a void area on the left side of the
// notification on Windows.
int resource_id;
switch (chrome::GetChannel()) {
#if defined(GOOGLE_CHROME_BUILD)
case version_info::Channel::CANARY:
resource_id = IDR_PRODUCT_LOGO_32_CANARY;
break;
case version_info::Channel::DEV:
resource_id = IDR_PRODUCT_LOGO_32_DEV;
break;
case version_info::Channel::BETA:
resource_id = IDR_PRODUCT_LOGO_32_BETA;
break;
case version_info::Channel::STABLE:
resource_id = IDR_PRODUCT_LOGO_32;
break;
#else
case version_info::Channel::CANARY:
case version_info::Channel::DEV:
case version_info::Channel::BETA:
case version_info::Channel::STABLE:
NOTREACHED();
FALLTHROUGH;
#endif
case version_info::Channel::UNKNOWN:
resource_id = IDR_PRODUCT_LOGO_32;
break;
}
return ui::ResourceBundle::GetSharedInstance().GetImageNamed(resource_id);
#endif
return gfx::Image();
}
void RecordSendTabToSelfClickResult(std::string context_menu, void RecordSendTabToSelfClickResult(std::string context_menu,
SendTabToSelfClickResult state) { SendTabToSelfClickResult state) {
base::UmaHistogramEnumeration( base::UmaHistogramEnumeration(
......
...@@ -15,6 +15,7 @@ class WebContents; ...@@ -15,6 +15,7 @@ class WebContents;
} }
namespace gfx { namespace gfx {
class Image;
class ImageSkia; class ImageSkia;
} }
...@@ -41,6 +42,9 @@ void CreateNewEntry(content::WebContents* tab, const GURL& link_url = GURL()); ...@@ -41,6 +42,9 @@ void CreateNewEntry(content::WebContents* tab, const GURL& link_url = GURL());
// Get the icon for send tab to self menu item. // Get the icon for send tab to self menu item.
gfx::ImageSkia* GetImageSkia(); gfx::ImageSkia* GetImageSkia();
// Get the image for send tab to self notification.
const gfx::Image GetImageForNotification();
// Record whether the user click to send a tab or link when send tab to self // Record whether the user click to send a tab or link when send tab to self
// entry point is shown in the context menu. // entry point is shown in the context menu.
void RecordSendTabToSelfClickResult(std::string context_menu, void RecordSendTabToSelfClickResult(std::string context_menu,
......
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