| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_contents_service.h" | 5 #include "chrome/browser/background_contents_service.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 BackgroundContentsShutdown(Details<BackgroundContents>(details).ptr()); | 106 BackgroundContentsShutdown(Details<BackgroundContents>(details).ptr()); |
| 107 break; | 107 break; |
| 108 case NotificationType::BACKGROUND_CONTENTS_CLOSED: | 108 case NotificationType::BACKGROUND_CONTENTS_CLOSED: |
| 109 DCHECK(IsTracked(Details<BackgroundContents>(details).ptr())); | 109 DCHECK(IsTracked(Details<BackgroundContents>(details).ptr())); |
| 110 UnregisterBackgroundContents(Details<BackgroundContents>(details).ptr()); | 110 UnregisterBackgroundContents(Details<BackgroundContents>(details).ptr()); |
| 111 break; | 111 break; |
| 112 case NotificationType::BACKGROUND_CONTENTS_NAVIGATED: | 112 case NotificationType::BACKGROUND_CONTENTS_NAVIGATED: |
| 113 DCHECK(IsTracked(Details<BackgroundContents>(details).ptr())); | 113 DCHECK(IsTracked(Details<BackgroundContents>(details).ptr())); |
| 114 RegisterBackgroundContents(Details<BackgroundContents>(details).ptr()); | 114 RegisterBackgroundContents(Details<BackgroundContents>(details).ptr()); |
| 115 break; | 115 break; |
| 116 case NotificationType::EXTENSION_UNLOADED: | 116 case NotificationType::EXTENSION_UNLOADED: |
| 117 ShutdownAssociatedBackgroundContents( | 117 switch (Details<UnloadedExtensionInfo>(details)->reason) { |
| 118 ASCIIToUTF16( | 118 case UnloadedExtensionInfo::DISABLE: // Intentionally fall through. |
| 119 Details<UnloadedExtensionInfo>(details)->extension->id())); | 119 case UnloadedExtensionInfo::UNINSTALL: |
| 120 ShutdownAssociatedBackgroundContents( |
| 121 ASCIIToUTF16( |
| 122 Details<UnloadedExtensionInfo>(details)->extension->id())); |
| 123 break; |
| 124 case UnloadedExtensionInfo::UPDATE: |
| 125 // Leave BackgroundContents in place |
| 126 break; |
| 127 default: |
| 128 NOTREACHED(); |
| 129 ShutdownAssociatedBackgroundContents( |
| 130 ASCIIToUTF16( |
| 131 Details<UnloadedExtensionInfo>(details)->extension->id())); |
| 132 break; |
| 133 } |
| 120 break; | 134 break; |
| 121 default: | 135 default: |
| 122 NOTREACHED(); | 136 NOTREACHED(); |
| 123 break; | 137 break; |
| 124 } | 138 } |
| 125 } | 139 } |
| 126 | 140 |
| 127 // Loads all background contents whose urls have been stored in prefs. | 141 // Loads all background contents whose urls have been stored in prefs. |
| 128 void BackgroundContentsService::LoadBackgroundContentsFromPrefs( | 142 void BackgroundContentsService::LoadBackgroundContentsFromPrefs( |
| 129 Profile* profile) { | 143 Profile* profile) { |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 TabContents* new_contents, | 322 TabContents* new_contents, |
| 309 WindowOpenDisposition disposition, | 323 WindowOpenDisposition disposition, |
| 310 const gfx::Rect& initial_pos, | 324 const gfx::Rect& initial_pos, |
| 311 bool user_gesture) { | 325 bool user_gesture) { |
| 312 Browser* browser = BrowserList::GetLastActiveWithProfile( | 326 Browser* browser = BrowserList::GetLastActiveWithProfile( |
| 313 new_contents->profile()); | 327 new_contents->profile()); |
| 314 if (!browser) | 328 if (!browser) |
| 315 return; | 329 return; |
| 316 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); | 330 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); |
| 317 } | 331 } |
| OLD | NEW |