Index: chrome/browser/ui/extensions/extension_installed_notification.cc |
diff --git a/chrome/browser/ui/extensions/extension_installed_notification.cc b/chrome/browser/ui/extensions/extension_installed_notification.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9cb711418f9537a059f7d0506380d67da7370401 |
--- /dev/null |
+++ b/chrome/browser/ui/extensions/extension_installed_notification.cc |
@@ -0,0 +1,75 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/ui/extensions/extension_installed_notification.h" |
+ |
+#include "ash/shell.h" |
+#include "ash/system/system_notifier.h" |
+#include "base/strings/utf_string_conversions.h" |
+#include "chrome/browser/browser_process.h" |
+#include "chrome/browser/extensions/extension_util.h" |
+#include "chrome/browser/notifications/notification.h" |
+#include "chrome/browser/notifications/notification_ui_manager.h" |
+#include "chrome/browser/notifications/notifier_state_tracker.h" |
+#include "chrome/browser/notifications/notifier_state_tracker_factory.h" |
+#include "chrome/browser/ui/extensions/app_launch_params.h" |
+#include "chrome/browser/ui/extensions/application_launch.h" |
+#include "content/public/browser/browser_thread.h" |
+#include "grit/generated_resources.h" |
+#include "grit/theme_resources.h" |
+#include "ui/base/l10n/l10n_util.h" |
+#include "ui/base/resource/resource_bundle.h" |
+#include "ui/message_center/notification.h" |
+ |
+namespace { |
+const char* kNotificationOriginUrl = "http://origin/"; |
benwells
2016/05/20 00:17:29
What is this all about? This seems really weird.
yoshiki
2016/05/24 16:25:17
Sorry I forgot to upload the latest patchset. Fixe
|
+const char* kNotificationId = "rigin"; |
+} |
+ |
+using content::BrowserThread; |
+ |
+// static |
+void ExtensionInstalledNotification::Show( |
+ const extensions::Extension* extension, Profile* profile) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::UI); |
+ DCHECK(g_browser_process->notification_ui_manager()); |
+ |
+ // The instance is self-owned (and ref-counted). It's lifetime will be managed |
+ // by ancestor NotificationDelegate, or be released soon by myself. |
benwells
2016/05/20 00:17:29
You probably shouldn't use 'myself' in a comment.
yoshiki
2016/05/24 16:25:18
Done.
|
+ new ExtensionInstalledNotification(extension, profile); |
+} |
+ |
+ExtensionInstalledNotification::ExtensionInstalledNotification( |
+ const extensions::Extension* extension, Profile* profile) |
+ : extension_(extension), profile_(profile) { |
+ |
benwells
2016/05/20 00:17:29
Nit: no blank line here
yoshiki
2016/05/24 16:25:18
Done.
|
+ message_center::RichNotificationData optional_field; |
+ std::unique_ptr<Notification> notification(new Notification( |
+ message_center::NOTIFICATION_TYPE_SIMPLE, |
+ base::UTF8ToUTF16(extension_->name()), |
+ l10n_util::GetStringUTF16(IDS_EXTENSION_NOTIFICATION_INSTALLED), |
+ ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
+ IDR_NOTIFICATION_EXTENSION_INSTALLED), |
+ message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT, |
+ ash::system_notifier::kNotifierScreenshot), |
benwells
2016/05/20 00:17:29
What's this got to do with screenshots?
yoshiki
2016/05/24 16:25:18
Fixed.
|
+ base::string16() /* display source */, GURL(kNotificationOriginUrl), |
+ kNotificationId, optional_field, this)); |
+ g_browser_process->notification_ui_manager()->Add(*notification, profile_); |
+} |
+ |
+ExtensionInstalledNotification::~ExtensionInstalledNotification() {} |
+ |
+void ExtensionInstalledNotification::Click() { |
+ if (!extensions::util::IsAppLaunchable(extension_->id(), profile_)) |
+ return; |
+ |
+ AppLaunchParams params = CreateAppLaunchParamsUserContainer( |
+ profile_, extension_.get(), |
+ NEW_FOREGROUND_TAB, extensions::SOURCE_TEST); |
benwells
2016/05/20 00:17:29
why SOURCE_TEST?
yoshiki
2016/05/24 16:25:18
Fixed.
|
+ OpenApplication(params); |
+} |
+ |
+std::string ExtensionInstalledNotification::id() const { |
+ return kNotificationId; |
+} |