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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 #if defined(OS_CHROMEOS) | 64 #if defined(OS_CHROMEOS) |
65 #include "chrome/browser/chromeos/login/user_flow.h" | 65 #include "chrome/browser/chromeos/login/user_flow.h" |
66 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 66 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
67 #endif | 67 #endif |
68 | 68 |
69 using content::SiteInstance; | 69 using content::SiteInstance; |
70 using content::WebContents; | 70 using content::WebContents; |
71 using extensions::BackgroundInfo; | 71 using extensions::BackgroundInfo; |
72 using extensions::Extension; | 72 using extensions::Extension; |
73 using extensions::UnloadedExtensionInfo; | 73 using extensions::UnloadedExtensionReason; |
74 | 74 |
75 namespace { | 75 namespace { |
76 | 76 |
77 const char kNotificationPrefix[] = "app.background.crashed."; | 77 const char kNotificationPrefix[] = "app.background.crashed."; |
78 const char kNotifierId[] = "app.background.crashed"; | 78 const char kNotifierId[] = "app.background.crashed"; |
79 bool g_disable_close_balloon_for_testing = false; | 79 bool g_disable_close_balloon_for_testing = false; |
80 | 80 |
81 void CloseBalloon(const std::string& balloon_id, ProfileID profile_id) { | 81 void CloseBalloon(const std::string& balloon_id, ProfileID profile_id) { |
82 NotificationUIManager* notification_ui_manager = | 82 NotificationUIManager* notification_ui_manager = |
83 g_browser_process->notification_ui_manager(); | 83 g_browser_process->notification_ui_manager(); |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 } | 502 } |
503 | 503 |
504 // Close the crash notification balloon for the app/extension, if any. | 504 // Close the crash notification balloon for the app/extension, if any. |
505 ScheduleCloseBalloon(extension->id(), profile); | 505 ScheduleCloseBalloon(extension->id(), profile); |
506 SendChangeNotification(profile); | 506 SendChangeNotification(profile); |
507 } | 507 } |
508 | 508 |
509 void BackgroundContentsService::OnExtensionUnloaded( | 509 void BackgroundContentsService::OnExtensionUnloaded( |
510 content::BrowserContext* browser_context, | 510 content::BrowserContext* browser_context, |
511 const extensions::Extension* extension, | 511 const extensions::Extension* extension, |
512 extensions::UnloadedExtensionInfo::Reason reason) { | 512 extensions::UnloadedExtensionReason reason) { |
513 switch (reason) { | 513 switch (reason) { |
514 case UnloadedExtensionInfo::REASON_DISABLE: // Fall through. | 514 case UnloadedExtensionReason::REASON_DISABLE: // Fall through. |
515 case UnloadedExtensionInfo::REASON_TERMINATE: // Fall through. | 515 case UnloadedExtensionReason::REASON_TERMINATE: // Fall through. |
516 case UnloadedExtensionInfo::REASON_UNINSTALL: // Fall through. | 516 case UnloadedExtensionReason::REASON_UNINSTALL: // Fall through. |
517 case UnloadedExtensionInfo::REASON_BLACKLIST: // Fall through. | 517 case UnloadedExtensionReason::REASON_BLACKLIST: // Fall through. |
518 case UnloadedExtensionInfo::REASON_LOCK_ALL: // Fall through. | 518 case UnloadedExtensionReason::REASON_LOCK_ALL: // Fall through. |
519 case UnloadedExtensionInfo::REASON_MIGRATED_TO_COMPONENT: // Fall through. | 519 case UnloadedExtensionReason::REASON_MIGRATED_TO_COMPONENT: // Fall |
520 case UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN: | 520 // through. |
| 521 case UnloadedExtensionReason::REASON_PROFILE_SHUTDOWN: |
521 ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16(extension->id())); | 522 ShutdownAssociatedBackgroundContents(base::ASCIIToUTF16(extension->id())); |
522 SendChangeNotification(Profile::FromBrowserContext(browser_context)); | 523 SendChangeNotification(Profile::FromBrowserContext(browser_context)); |
523 return; | 524 return; |
524 case UnloadedExtensionInfo::REASON_UPDATE: { | 525 case UnloadedExtensionReason::REASON_UPDATE: { |
525 // If there is a manifest specified background page, then shut it down | 526 // If there is a manifest specified background page, then shut it down |
526 // here, since if the updated extension still has the background page, | 527 // here, since if the updated extension still has the background page, |
527 // then it will be loaded from LOADED callback. Otherwise, leave | 528 // then it will be loaded from LOADED callback. Otherwise, leave |
528 // BackgroundContents in place. | 529 // BackgroundContents in place. |
529 // We don't call SendChangeNotification here - it will be generated | 530 // We don't call SendChangeNotification here - it will be generated |
530 // from the LOADED callback. | 531 // from the LOADED callback. |
531 if (BackgroundInfo::HasBackgroundPage(extension)) { | 532 if (BackgroundInfo::HasBackgroundPage(extension)) { |
532 ShutdownAssociatedBackgroundContents( | 533 ShutdownAssociatedBackgroundContents( |
533 base::ASCIIToUTF16(extension->id())); | 534 base::ASCIIToUTF16(extension->id())); |
534 } | 535 } |
535 return; | 536 return; |
536 case UnloadedExtensionInfo::REASON_UNDEFINED: | 537 case UnloadedExtensionReason::REASON_UNDEFINED: |
537 // Fall through to undefined case. | 538 // Fall through to undefined case. |
538 break; | 539 break; |
539 } | 540 } |
540 } | 541 } |
541 NOTREACHED() << "Undefined case " << reason; | 542 NOTREACHED() << "Undefined case " << reason; |
542 return ShutdownAssociatedBackgroundContents( | 543 return ShutdownAssociatedBackgroundContents( |
543 base::ASCIIToUTF16(extension->id())); | 544 base::ASCIIToUTF16(extension->id())); |
544 } | 545 } |
545 | 546 |
546 void BackgroundContentsService::OnExtensionUninstalled( | 547 void BackgroundContentsService::OnExtensionUninstalled( |
547 content::BrowserContext* browser_context, | 548 content::BrowserContext* browser_context, |
548 const extensions::Extension* extension, | 549 const extensions::Extension* extension, |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 const gfx::Rect& initial_rect, | 863 const gfx::Rect& initial_rect, |
863 bool user_gesture, | 864 bool user_gesture, |
864 bool* was_blocked) { | 865 bool* was_blocked) { |
865 Browser* browser = chrome::FindLastActiveWithProfile( | 866 Browser* browser = chrome::FindLastActiveWithProfile( |
866 Profile::FromBrowserContext(new_contents->GetBrowserContext())); | 867 Profile::FromBrowserContext(new_contents->GetBrowserContext())); |
867 if (browser) { | 868 if (browser) { |
868 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 869 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
869 initial_rect, user_gesture, was_blocked); | 870 initial_rect, user_gesture, was_blocked); |
870 } | 871 } |
871 } | 872 } |
OLD | NEW |