| 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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 bool user_gesture, | 773 bool user_gesture, |
| 771 bool* was_blocked) { | 774 bool* was_blocked) { |
| 772 Browser* browser = chrome::FindLastActiveWithProfile( | 775 Browser* browser = chrome::FindLastActiveWithProfile( |
| 773 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 776 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 774 chrome::GetActiveDesktop()); | 777 chrome::GetActiveDesktop()); |
| 775 if (browser) { | 778 if (browser) { |
| 776 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 779 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 777 initial_pos, user_gesture, was_blocked); | 780 initial_pos, user_gesture, was_blocked); |
| 778 } | 781 } |
| 779 } | 782 } |
| OLD | NEW |