OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/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" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/background/background_contents_service_factory.h" | 12 #include "chrome/browser/background/background_contents_service_factory.h" |
13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
14 #include "chrome/browser/extensions/extension_host.h" | 14 #include "chrome/browser/extensions/extension_host.h" |
15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
16 #include "chrome/browser/notifications/desktop_notification_service.h" | 16 #include "chrome/browser/notifications/desktop_notification_service.h" |
17 #include "chrome/browser/notifications/notification.h" | 17 #include "chrome/browser/notifications/notification.h" |
18 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
20 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 20 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
21 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
23 #include "chrome/browser/ui/browser_list.h" | 23 #include "chrome/browser/ui/browser_list.h" |
24 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/extensions/extension.h" | 26 #include "chrome/common/extensions/extension.h" |
| 27 #include "chrome/common/extensions/extension_constants.h" |
27 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
28 #include "content/browser/renderer_host/render_view_host.h" | 29 #include "content/browser/renderer_host/render_view_host.h" |
29 #include "content/browser/site_instance.h" | 30 #include "content/browser/site_instance.h" |
30 #include "content/browser/tab_contents/tab_contents.h" | 31 #include "content/browser/tab_contents/tab_contents.h" |
31 #include "content/common/notification_service.h" | 32 #include "content/common/notification_service.h" |
32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
33 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
34 | 35 |
35 namespace { | 36 namespace { |
36 | 37 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // an EXTENSION_UNLOADED notification. This UNLOADED signal causes all the | 286 // an EXTENSION_UNLOADED notification. This UNLOADED signal causes all the |
286 // notifications for this extension to be cancelled by | 287 // notifications for this extension to be cancelled by |
287 // DesktopNotificationService. For this reason, instead of showing the | 288 // DesktopNotificationService. For this reason, instead of showing the |
288 // balloon right now, we schedule it to show a little later. | 289 // balloon right now, we schedule it to show a little later. |
289 MessageLoop::current()->PostTask(FROM_HERE, | 290 MessageLoop::current()->PostTask(FROM_HERE, |
290 NewRunnableFunction(&ShowBalloon, extension, profile)); | 291 NewRunnableFunction(&ShowBalloon, extension, profile)); |
291 break; | 292 break; |
292 } | 293 } |
293 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 294 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
294 switch (Details<UnloadedExtensionInfo>(details)->reason) { | 295 switch (Details<UnloadedExtensionInfo>(details)->reason) { |
295 case UnloadedExtensionInfo::DISABLE: // Intentionally fall through. | 296 // Intentionally fall through. |
296 case UnloadedExtensionInfo::UNINSTALL: | 297 case extension_misc::UNLOAD_REASON_DISABLE: |
| 298 case extension_misc::UNLOAD_REASON_UNINSTALL: |
297 ShutdownAssociatedBackgroundContents( | 299 ShutdownAssociatedBackgroundContents( |
298 ASCIIToUTF16( | 300 ASCIIToUTF16( |
299 Details<UnloadedExtensionInfo>(details)->extension->id())); | 301 Details<UnloadedExtensionInfo>(details)->extension->id())); |
300 break; | 302 break; |
301 case UnloadedExtensionInfo::UPDATE: { | 303 case extension_misc::UNLOAD_REASON_UPDATE: { |
302 // If there is a manifest specified background page, then shut it down | 304 // If there is a manifest specified background page, then shut it down |
303 // here, since if the updated extension still has the background page, | 305 // here, since if the updated extension still has the background page, |
304 // then it will be loaded from LOADED callback. Otherwise, leave | 306 // then it will be loaded from LOADED callback. Otherwise, leave |
305 // BackgroundContents in place. | 307 // BackgroundContents in place. |
306 const Extension* extension = | 308 const Extension* extension = |
307 Details<UnloadedExtensionInfo>(details)->extension; | 309 Details<UnloadedExtensionInfo>(details)->extension; |
308 if (extension->background_url().is_valid()) | 310 if (extension->background_url().is_valid()) |
309 ShutdownAssociatedBackgroundContents(ASCIIToUTF16(extension->id())); | 311 ShutdownAssociatedBackgroundContents(ASCIIToUTF16(extension->id())); |
310 break; | 312 break; |
311 } | 313 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 TabContents* new_contents, | 573 TabContents* new_contents, |
572 WindowOpenDisposition disposition, | 574 WindowOpenDisposition disposition, |
573 const gfx::Rect& initial_pos, | 575 const gfx::Rect& initial_pos, |
574 bool user_gesture) { | 576 bool user_gesture) { |
575 Browser* browser = BrowserList::GetLastActiveWithProfile( | 577 Browser* browser = BrowserList::GetLastActiveWithProfile( |
576 Profile::FromBrowserContext(new_contents->browser_context())); | 578 Profile::FromBrowserContext(new_contents->browser_context())); |
577 if (!browser) | 579 if (!browser) |
578 return; | 580 return; |
579 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); | 581 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); |
580 } | 582 } |
OLD | NEW |