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

Side by Side Diff: chrome/browser/background/background_contents_service.cc

Issue 1395093002: Fix system notifications incorrectly marked as type WEB_PAGE (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@timeout
Patch Set: Addressed Peter's review comments Created 5 years, 2 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/background/background_contents_service.h" 5 #include "chrome/browser/background/background_contents_service.h"
6 6
7 #include "apps/app_load_service.h" 7 #include "apps/app_load_service.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "extensions/common/manifest_handlers/background_info.h" 51 #include "extensions/common/manifest_handlers/background_info.h"
52 #include "extensions/common/manifest_handlers/icons_handler.h" 52 #include "extensions/common/manifest_handlers/icons_handler.h"
53 #include "extensions/grit/extensions_browser_resources.h" 53 #include "extensions/grit/extensions_browser_resources.h"
54 #include "ipc/ipc_message.h" 54 #include "ipc/ipc_message.h"
55 #include "ui/base/l10n/l10n_util.h" 55 #include "ui/base/l10n/l10n_util.h"
56 #include "ui/base/resource/resource_bundle.h" 56 #include "ui/base/resource/resource_bundle.h"
57 #include "ui/gfx/image/image.h" 57 #include "ui/gfx/image/image.h"
58 58
59 #if defined(ENABLE_NOTIFICATIONS) 59 #if defined(ENABLE_NOTIFICATIONS)
60 #include "ui/message_center/message_center.h" 60 #include "ui/message_center/message_center.h"
61 #include "ui/message_center/notification_types.h"
62 #include "ui/message_center/notifier_settings.h"
61 #endif 63 #endif
62 64
63 using content::SiteInstance; 65 using content::SiteInstance;
64 using content::WebContents; 66 using content::WebContents;
65 using extensions::BackgroundInfo; 67 using extensions::BackgroundInfo;
66 using extensions::Extension; 68 using extensions::Extension;
67 using extensions::UnloadedExtensionInfo; 69 using extensions::UnloadedExtensionInfo;
68 70
69 namespace { 71 namespace {
70 72
73 const char kNotifierId[] = "app.background.crashed";
Peter Beverloo 2015/10/09 12:55:23 micro nit: alphabetise (you do it elsewhere).
johnme 2015/10/09 14:20:41 Done.
71 const char kNotificationPrefix[] = "app.background.crashed."; 74 const char kNotificationPrefix[] = "app.background.crashed.";
72 bool g_disable_close_balloon_for_testing = false; 75 bool g_disable_close_balloon_for_testing = false;
73 76
74 void CloseBalloon(const std::string& balloon_id, ProfileID profile_id) { 77 void CloseBalloon(const std::string& balloon_id, ProfileID profile_id) {
75 NotificationUIManager* notification_ui_manager = 78 NotificationUIManager* notification_ui_manager =
76 g_browser_process->notification_ui_manager(); 79 g_browser_process->notification_ui_manager();
77 bool cancelled = notification_ui_manager->CancelById(balloon_id, profile_id); 80 bool cancelled = notification_ui_manager->CancelById(balloon_id, profile_id);
78 if (cancelled) { 81 if (cancelled) {
79 #if defined(ENABLE_NOTIFICATIONS) 82 #if defined(ENABLE_NOTIFICATIONS)
80 // TODO(dewittj): Add this functionality to the notification UI manager's 83 // TODO(dewittj): Add this functionality to the notification UI manager's
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 const gfx::Image& icon) { 166 const gfx::Image& icon) {
164 gfx::Image notification_icon(icon); 167 gfx::Image notification_icon(icon);
165 if (notification_icon.IsEmpty()) { 168 if (notification_icon.IsEmpty()) {
166 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 169 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
167 notification_icon = rb.GetImageNamed(IDR_EXTENSION_DEFAULT_ICON); 170 notification_icon = rb.GetImageNamed(IDR_EXTENSION_DEFAULT_ICON);
168 } 171 }
169 172
170 // Origin URL must be different from the crashed extension to avoid the 173 // Origin URL must be different from the crashed extension to avoid the
171 // conflict. NotificationSystemObserver will cancel all notifications from 174 // conflict. NotificationSystemObserver will cancel all notifications from
172 // the same origin when NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED. 175 // the same origin when NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED.
173 Notification notification(GURL("chrome://extension-crash"), 176 Notification notification(message_center::NOTIFICATION_TYPE_SIMPLE,
174 base::string16(), 177 base::string16(),
175 message, 178 message,
176 notification_icon, 179 notification_icon,
180 message_center::NotifierId(
181 message_center::NotifierId::SYSTEM_COMPONENT,
182 kNotifierId),
177 base::string16(), 183 base::string16(),
184 GURL("chrome://extension-crash"),
178 delegate->id(), 185 delegate->id(),
186 message_center::RichNotificationData(),
179 delegate.get()); 187 delegate.get());
180 188
181 g_browser_process->notification_ui_manager()->Add(notification, profile); 189 g_browser_process->notification_ui_manager()->Add(notification, profile);
182 } 190 }
183 #endif 191 #endif
184 192
185 // Show a popup notification balloon with a crash message for a given app/ 193 // Show a popup notification balloon with a crash message for a given app/
186 // extension. 194 // extension.
187 void ShowBalloon(const Extension* extension, Profile* profile) { 195 void ShowBalloon(const Extension* extension, Profile* profile) {
188 #if defined(ENABLE_NOTIFICATIONS) 196 #if defined(ENABLE_NOTIFICATIONS)
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 bool user_gesture, 787 bool user_gesture,
780 bool* was_blocked) { 788 bool* was_blocked) {
781 Browser* browser = chrome::FindLastActiveWithProfile( 789 Browser* browser = chrome::FindLastActiveWithProfile(
782 Profile::FromBrowserContext(new_contents->GetBrowserContext()), 790 Profile::FromBrowserContext(new_contents->GetBrowserContext()),
783 chrome::GetActiveDesktop()); 791 chrome::GetActiveDesktop());
784 if (browser) { 792 if (browser) {
785 chrome::AddWebContents(browser, NULL, new_contents, disposition, 793 chrome::AddWebContents(browser, NULL, new_contents, disposition,
786 initial_rect, user_gesture, was_blocked); 794 initial_rect, user_gesture, was_blocked);
787 } 795 }
788 } 796 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698