| OLD | NEW |
| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 const gfx::Image& icon) { | 161 const gfx::Image& icon) { |
| 162 gfx::Image notification_icon(icon); | 162 gfx::Image notification_icon(icon); |
| 163 if (notification_icon.IsEmpty()) { | 163 if (notification_icon.IsEmpty()) { |
| 164 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 164 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 165 notification_icon = rb.GetImageNamed(IDR_EXTENSION_DEFAULT_ICON); | 165 notification_icon = rb.GetImageNamed(IDR_EXTENSION_DEFAULT_ICON); |
| 166 } | 166 } |
| 167 | 167 |
| 168 // Origin URL must be different from the crashed extension to avoid the | 168 // Origin URL must be different from the crashed extension to avoid the |
| 169 // conflict. NotificationSystemObserver will cancel all notifications from | 169 // conflict. NotificationSystemObserver will cancel all notifications from |
| 170 // the same origin when NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED. | 170 // the same origin when NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED. |
| 171 // TODO(mukai, dewittj): remove this and switch to message center | 171 Notification notification(GURL("chrome://extension-crash"), |
| 172 // notifications. | 172 base::string16(), |
| 173 DesktopNotificationService::AddIconNotification( | 173 message, |
| 174 GURL("chrome://extension-crash"), // Origin URL. | 174 notification_icon, |
| 175 base::string16(), // Title of notification. | 175 base::string16(), |
| 176 message, | 176 base::UTF8ToUTF16(delegate->id()), |
| 177 notification_icon, | 177 delegate.get()); |
| 178 base::UTF8ToUTF16(delegate->id()), // Replace ID. | 178 |
| 179 delegate.get(), | 179 g_browser_process->notification_ui_manager()->Add(notification, profile); |
| 180 profile); | |
| 181 } | 180 } |
| 182 #endif | 181 #endif |
| 183 | 182 |
| 184 // Show a popup notification balloon with a crash message for a given app/ | 183 // Show a popup notification balloon with a crash message for a given app/ |
| 185 // extension. | 184 // extension. |
| 186 void ShowBalloon(const Extension* extension, Profile* profile) { | 185 void ShowBalloon(const Extension* extension, Profile* profile) { |
| 187 #if defined(ENABLE_NOTIFICATIONS) | 186 #if defined(ENABLE_NOTIFICATIONS) |
| 188 const base::string16 message = l10n_util::GetStringFUTF16( | 187 const base::string16 message = l10n_util::GetStringFUTF16( |
| 189 extension->is_app() ? IDS_BACKGROUND_CRASHED_APP_BALLOON_MESSAGE : | 188 extension->is_app() ? IDS_BACKGROUND_CRASHED_APP_BALLOON_MESSAGE : |
| 190 IDS_BACKGROUND_CRASHED_EXTENSION_BALLOON_MESSAGE, | 189 IDS_BACKGROUND_CRASHED_EXTENSION_BALLOON_MESSAGE, |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 768 bool user_gesture, | 767 bool user_gesture, |
| 769 bool* was_blocked) { | 768 bool* was_blocked) { |
| 770 Browser* browser = chrome::FindLastActiveWithProfile( | 769 Browser* browser = chrome::FindLastActiveWithProfile( |
| 771 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 770 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 772 chrome::GetActiveDesktop()); | 771 chrome::GetActiveDesktop()); |
| 773 if (browser) { | 772 if (browser) { |
| 774 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 773 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 775 initial_pos, user_gesture, was_blocked); | 774 initial_pos, user_gesture, was_blocked); |
| 776 } | 775 } |
| 777 } | 776 } |
| OLD | NEW |