| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/background/background_contents_service_factory.h" | 14 #include "chrome/browser/background/background_contents_service_factory.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/extensions/extension_host.h" | 16 #include "chrome/browser/extensions/extension_host.h" |
| 17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/notifications/desktop_notification_service.h" | 19 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 20 #include "chrome/browser/notifications/notification.h" | 20 #include "chrome/browser/notifications/notification.h" |
| 21 #include "chrome/browser/notifications/notification_ui_manager.h" | 21 #include "chrome/browser/notifications/notification_ui_manager.h" |
| 22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 23 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/browser/ui/browser_finder.h" | 26 #include "chrome/browser/ui/browser_finder.h" |
| 27 #include "chrome/browser/ui/browser_tabstrip.h" | 27 #include "chrome/browser/ui/browser_tabstrip.h" |
| 28 #include "chrome/browser/ui/host_desktop.h" | 28 #include "chrome/browser/ui/host_desktop.h" |
| 29 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 31 #include "chrome/common/extensions/extension.h" | 32 #include "chrome/common/extensions/extension.h" |
| 32 #include "chrome/common/extensions/extension_icon_set.h" | 33 #include "chrome/common/extensions/extension_icon_set.h" |
| 33 #include "chrome/common/extensions/extension_constants.h" | 34 #include "chrome/common/extensions/extension_constants.h" |
| 34 #include "chrome/common/pref_names.h" | 35 #include "chrome/common/pref_names.h" |
| 35 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
| 36 #include "content/public/browser/site_instance.h" | 37 #include "content/public/browser/site_instance.h" |
| 37 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
| 38 #include "grit/generated_resources.h" | 39 #include "grit/generated_resources.h" |
| 39 #include "ipc/ipc_message.h" | 40 #include "ipc/ipc_message.h" |
| 40 #include "ui/base/l10n/l10n_util.h" | 41 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 DISALLOW_COPY_AND_ASSIGN(CrashNotificationDelegate); | 112 DISALLOW_COPY_AND_ASSIGN(CrashNotificationDelegate); |
| 112 }; | 113 }; |
| 113 | 114 |
| 114 void ShowBalloon(const Extension* extension, Profile* profile) { | 115 void ShowBalloon(const Extension* extension, Profile* profile) { |
| 115 #if defined(ENABLE_NOTIFICATIONS) | 116 #if defined(ENABLE_NOTIFICATIONS) |
| 116 string16 title; // no notifiaction title | 117 string16 title; // no notifiaction title |
| 117 string16 message = l10n_util::GetStringFUTF16( | 118 string16 message = l10n_util::GetStringFUTF16( |
| 118 extension->is_app() ? IDS_BACKGROUND_CRASHED_APP_BALLOON_MESSAGE : | 119 extension->is_app() ? IDS_BACKGROUND_CRASHED_APP_BALLOON_MESSAGE : |
| 119 IDS_BACKGROUND_CRASHED_EXTENSION_BALLOON_MESSAGE, | 120 IDS_BACKGROUND_CRASHED_EXTENSION_BALLOON_MESSAGE, |
| 120 UTF8ToUTF16(extension->name())); | 121 UTF8ToUTF16(extension->name())); |
| 121 GURL icon_url(extension->GetIconURL(extension_misc::EXTENSION_ICON_SMALLISH, | 122 GURL icon_url(extensions::IconsInfo::GetIconURL( |
| 122 ExtensionIconSet::MATCH_BIGGER)); | 123 extension, |
| 124 extension_misc::EXTENSION_ICON_SMALLISH, |
| 125 ExtensionIconSet::MATCH_BIGGER)); |
| 123 DesktopNotificationService::AddNotification( | 126 DesktopNotificationService::AddNotification( |
| 124 extension->url(), title, message, icon_url, string16(), | 127 extension->url(), title, message, icon_url, string16(), |
| 125 new CrashNotificationDelegate(profile, extension), profile); | 128 new CrashNotificationDelegate(profile, extension), profile); |
| 126 #endif | 129 #endif |
| 127 } | 130 } |
| 128 | 131 |
| 129 } | 132 } |
| 130 | 133 |
| 131 // Keys for the information we store about individual BackgroundContents in | 134 // Keys for the information we store about individual BackgroundContents in |
| 132 // prefs. There is one top-level DictionaryValue (stored at | 135 // prefs. There is one top-level DictionaryValue (stored at |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 bool user_gesture, | 628 bool user_gesture, |
| 626 bool* was_blocked) { | 629 bool* was_blocked) { |
| 627 Browser* browser = chrome::FindLastActiveWithProfile( | 630 Browser* browser = chrome::FindLastActiveWithProfile( |
| 628 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 631 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 629 chrome::GetActiveDesktop()); | 632 chrome::GetActiveDesktop()); |
| 630 if (browser) { | 633 if (browser) { |
| 631 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 634 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 632 initial_pos, user_gesture, was_blocked); | 635 initial_pos, user_gesture, was_blocked); |
| 633 } | 636 } |
| 634 } | 637 } |
| OLD | NEW |