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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 | 451 |
452 void BackgroundContentsService::OnExtensionUnloaded( | 452 void BackgroundContentsService::OnExtensionUnloaded( |
453 content::BrowserContext* browser_context, | 453 content::BrowserContext* browser_context, |
454 const extensions::Extension* extension, | 454 const extensions::Extension* extension, |
455 extensions::UnloadedExtensionInfo::Reason reason) { | 455 extensions::UnloadedExtensionInfo::Reason reason) { |
456 switch (reason) { | 456 switch (reason) { |
457 case UnloadedExtensionInfo::REASON_DISABLE: // Fall through. | 457 case UnloadedExtensionInfo::REASON_DISABLE: // Fall through. |
458 case UnloadedExtensionInfo::REASON_TERMINATE: // Fall through. | 458 case UnloadedExtensionInfo::REASON_TERMINATE: // Fall through. |
459 case UnloadedExtensionInfo::REASON_UNINSTALL: // Fall through. | 459 case UnloadedExtensionInfo::REASON_UNINSTALL: // Fall through. |
460 case UnloadedExtensionInfo::REASON_BLACKLIST: // Fall through. | 460 case UnloadedExtensionInfo::REASON_BLACKLIST: // Fall through. |
| 461 case UnloadedExtensionInfo::REASON_LOCK_ALL: // Fall through. |
461 case UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN: | 462 case UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN: |
462 ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16(extension->id())); | 463 ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16(extension->id())); |
463 SendChangeNotification(Profile::FromBrowserContext(browser_context)); | 464 SendChangeNotification(Profile::FromBrowserContext(browser_context)); |
464 break; | 465 return; |
465 case UnloadedExtensionInfo::REASON_UPDATE: { | 466 case UnloadedExtensionInfo::REASON_UPDATE: { |
466 // If there is a manifest specified background page, then shut it down | 467 // If there is a manifest specified background page, then shut it down |
467 // here, since if the updated extension still has the background page, | 468 // here, since if the updated extension still has the background page, |
468 // then it will be loaded from LOADED callback. Otherwise, leave | 469 // then it will be loaded from LOADED callback. Otherwise, leave |
469 // BackgroundContents in place. | 470 // BackgroundContents in place. |
470 // We don't call SendChangeNotification here - it will be generated | 471 // We don't call SendChangeNotification here - it will be generated |
471 // from the LOADED callback. | 472 // from the LOADED callback. |
472 if (BackgroundInfo::HasBackgroundPage(extension)) { | 473 if (BackgroundInfo::HasBackgroundPage(extension)) { |
473 ShutdownAssociatedBackgroundContents( | 474 ShutdownAssociatedBackgroundContents( |
474 base::ASCIIToUTF16(extension->id())); | 475 base::ASCIIToUTF16(extension->id())); |
475 } | 476 } |
| 477 return; |
| 478 case UnloadedExtensionInfo::REASON_UNDEFINED: |
| 479 // Fall through to undefined case. |
476 break; | 480 break; |
477 } | 481 } |
478 default: | |
479 NOTREACHED(); | |
480 ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16(extension->id())); | |
481 break; | |
482 } | 482 } |
| 483 NOTREACHED() << "Undefined case " << reason; |
| 484 return ShutdownAssociatedBackgroundContents( |
| 485 base::ASCIIToUTF16(extension->id())); |
483 } | 486 } |
484 | 487 |
485 void BackgroundContentsService::OnExtensionUninstalled( | 488 void BackgroundContentsService::OnExtensionUninstalled( |
486 content::BrowserContext* browser_context, | 489 content::BrowserContext* browser_context, |
487 const extensions::Extension* extension, | 490 const extensions::Extension* extension, |
488 extensions::UninstallReason reason) { | 491 extensions::UninstallReason reason) { |
489 Profile* profile = Profile::FromBrowserContext(browser_context); | 492 Profile* profile = Profile::FromBrowserContext(browser_context); |
490 // Make sure the extension-crash balloons are removed when the extension is | 493 // Make sure the extension-crash balloons are removed when the extension is |
491 // uninstalled/reloaded. We cannot do this from UNLOADED since a crashed | 494 // uninstalled/reloaded. We cannot do this from UNLOADED since a crashed |
492 // extension is unloaded immediately after the crash, not when user reloads or | 495 // extension is unloaded immediately after the crash, not when user reloads or |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 bool user_gesture, | 768 bool user_gesture, |
766 bool* was_blocked) { | 769 bool* was_blocked) { |
767 Browser* browser = chrome::FindLastActiveWithProfile( | 770 Browser* browser = chrome::FindLastActiveWithProfile( |
768 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 771 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
769 chrome::GetActiveDesktop()); | 772 chrome::GetActiveDesktop()); |
770 if (browser) { | 773 if (browser) { |
771 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 774 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
772 initial_pos, user_gesture, was_blocked); | 775 initial_pos, user_gesture, was_blocked); |
773 } | 776 } |
774 } | 777 } |
OLD | NEW |