| 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 "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" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 namespace { | 54 namespace { |
| 55 | 55 |
| 56 const char kNotificationPrefix[] = "app.background.crashed."; | 56 const char kNotificationPrefix[] = "app.background.crashed."; |
| 57 | 57 |
| 58 void CloseBalloon(const std::string id) { | 58 void CloseBalloon(const std::string id) { |
| 59 g_browser_process->notification_ui_manager()->CancelById(id); | 59 g_browser_process->notification_ui_manager()->CancelById(id); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void ScheduleCloseBalloon(const std::string& extension_id) { | 62 void ScheduleCloseBalloon(const std::string& extension_id) { |
| 63 if (!MessageLoop::current()) // For unit_tests | 63 if (!base::MessageLoop::current()) // For unit_tests |
| 64 return; | 64 return; |
| 65 MessageLoop::current()->PostTask( | 65 base::MessageLoop::current()->PostTask( |
| 66 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id)); | 66 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id)); |
| 67 } | 67 } |
| 68 | 68 |
| 69 class CrashNotificationDelegate : public NotificationDelegate { | 69 class CrashNotificationDelegate : public NotificationDelegate { |
| 70 public: | 70 public: |
| 71 CrashNotificationDelegate(Profile* profile, | 71 CrashNotificationDelegate(Profile* profile, |
| 72 const Extension* extension) | 72 const Extension* extension) |
| 73 : profile_(profile), | 73 : profile_(profile), |
| 74 is_hosted_app_(extension->is_hosted_app()), | 74 is_hosted_app_(extension->is_hosted_app()), |
| 75 is_platform_app_(extension->is_platform_app()), | 75 is_platform_app_(extension->is_platform_app()), |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 extension = extension_host->extension(); | 365 extension = extension_host->extension(); |
| 366 } | 366 } |
| 367 if (!extension) | 367 if (!extension) |
| 368 break; | 368 break; |
| 369 | 369 |
| 370 // When an extension crashes, EXTENSION_PROCESS_TERMINATED is followed by | 370 // When an extension crashes, EXTENSION_PROCESS_TERMINATED is followed by |
| 371 // an EXTENSION_UNLOADED notification. This UNLOADED signal causes all the | 371 // an EXTENSION_UNLOADED notification. This UNLOADED signal causes all the |
| 372 // notifications for this extension to be cancelled by | 372 // notifications for this extension to be cancelled by |
| 373 // DesktopNotificationService. For this reason, instead of showing the | 373 // DesktopNotificationService. For this reason, instead of showing the |
| 374 // balloon right now, we schedule it to show a little later. | 374 // balloon right now, we schedule it to show a little later. |
| 375 MessageLoop::current()->PostTask( | 375 base::MessageLoop::current()->PostTask( |
| 376 FROM_HERE, base::Bind(&ShowBalloon, extension, profile)); | 376 FROM_HERE, base::Bind(&ShowBalloon, extension, profile)); |
| 377 break; | 377 break; |
| 378 } | 378 } |
| 379 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 379 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| 380 switch (content::Details<UnloadedExtensionInfo>(details)->reason) { | 380 switch (content::Details<UnloadedExtensionInfo>(details)->reason) { |
| 381 case extension_misc::UNLOAD_REASON_DISABLE: // Fall through. | 381 case extension_misc::UNLOAD_REASON_DISABLE: // Fall through. |
| 382 case extension_misc::UNLOAD_REASON_TERMINATE: // Fall through. | 382 case extension_misc::UNLOAD_REASON_TERMINATE: // Fall through. |
| 383 case extension_misc::UNLOAD_REASON_UNINSTALL: // Fall through. | 383 case extension_misc::UNLOAD_REASON_UNINSTALL: // Fall through. |
| 384 case extension_misc::UNLOAD_REASON_BLACKLIST: | 384 case extension_misc::UNLOAD_REASON_BLACKLIST: |
| 385 ShutdownAssociatedBackgroundContents( | 385 ShutdownAssociatedBackgroundContents( |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 bool user_gesture, | 680 bool user_gesture, |
| 681 bool* was_blocked) { | 681 bool* was_blocked) { |
| 682 Browser* browser = chrome::FindLastActiveWithProfile( | 682 Browser* browser = chrome::FindLastActiveWithProfile( |
| 683 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 683 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 684 chrome::GetActiveDesktop()); | 684 chrome::GetActiveDesktop()); |
| 685 if (browser) { | 685 if (browser) { |
| 686 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 686 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 687 initial_pos, user_gesture, was_blocked); | 687 initial_pos, user_gesture, was_blocked); |
| 688 } | 688 } |
| 689 } | 689 } |
| OLD | NEW |