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

Side by Side Diff: chrome/browser/ui/extensions/extension_installed_notification.cc

Issue 1993583002: Show notification instead of opening app launcher after extension installation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/extensions/extension_installed_notification.h"
6
7 #include "ash/shell.h"
8 #include "ash/system/system_notifier.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/extensions/extension_util.h"
12 #include "chrome/browser/notifications/notification.h"
13 #include "chrome/browser/notifications/notification_ui_manager.h"
14 #include "chrome/browser/notifications/notifier_state_tracker.h"
15 #include "chrome/browser/notifications/notifier_state_tracker_factory.h"
16 #include "chrome/browser/ui/extensions/app_launch_params.h"
17 #include "chrome/browser/ui/extensions/application_launch.h"
18 #include "content/public/browser/browser_thread.h"
19 #include "grit/generated_resources.h"
20 #include "grit/theme_resources.h"
21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/message_center/notification.h"
24
25 namespace {
26 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
27 const char* kNotificationId = "rigin";
28 }
29
30 using content::BrowserThread;
31
32 // static
33 void ExtensionInstalledNotification::Show(
34 const extensions::Extension* extension, Profile* profile) {
35 DCHECK_CURRENTLY_ON(BrowserThread::UI);
36 DCHECK(g_browser_process->notification_ui_manager());
37
38 // The instance is self-owned (and ref-counted). It's lifetime will be managed
39 // 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.
40 new ExtensionInstalledNotification(extension, profile);
41 }
42
43 ExtensionInstalledNotification::ExtensionInstalledNotification(
44 const extensions::Extension* extension, Profile* profile)
45 : extension_(extension), profile_(profile) {
46
benwells 2016/05/20 00:17:29 Nit: no blank line here
yoshiki 2016/05/24 16:25:18 Done.
47 message_center::RichNotificationData optional_field;
48 std::unique_ptr<Notification> notification(new Notification(
49 message_center::NOTIFICATION_TYPE_SIMPLE,
50 base::UTF8ToUTF16(extension_->name()),
51 l10n_util::GetStringUTF16(IDS_EXTENSION_NOTIFICATION_INSTALLED),
52 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
53 IDR_NOTIFICATION_EXTENSION_INSTALLED),
54 message_center::NotifierId(message_center::NotifierId::SYSTEM_COMPONENT,
55 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.
56 base::string16() /* display source */, GURL(kNotificationOriginUrl),
57 kNotificationId, optional_field, this));
58 g_browser_process->notification_ui_manager()->Add(*notification, profile_);
59 }
60
61 ExtensionInstalledNotification::~ExtensionInstalledNotification() {}
62
63 void ExtensionInstalledNotification::Click() {
64 if (!extensions::util::IsAppLaunchable(extension_->id(), profile_))
65 return;
66
67 AppLaunchParams params = CreateAppLaunchParamsUserContainer(
68 profile_, extension_.get(),
69 NEW_FOREGROUND_TAB, extensions::SOURCE_TEST);
benwells 2016/05/20 00:17:29 why SOURCE_TEST?
yoshiki 2016/05/24 16:25:18 Fixed.
70 OpenApplication(params);
71 }
72
73 std::string ExtensionInstalledNotification::id() const {
74 return kNotificationId;
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698