| 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/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 private: | 91 private: |
| 92 Profile* profile_; | 92 Profile* profile_; |
| 93 bool is_hosted_app_; | 93 bool is_hosted_app_; |
| 94 std::string extension_id_; | 94 std::string extension_id_; |
| 95 | 95 |
| 96 DISALLOW_COPY_AND_ASSIGN(CrashNotificationDelegate); | 96 DISALLOW_COPY_AND_ASSIGN(CrashNotificationDelegate); |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 void ShowBalloon(const Extension* extension, Profile* profile) { | 99 void ShowBalloon(const Extension* extension, Profile* profile) { |
| 100 string16 message = l10n_util::GetStringFUTF16( | 100 string16 message = l10n_util::GetStringFUTF16( |
| 101 extension->is_hosted_app() ? IDS_BACKGROUND_CRASHED_APP_BALLOON_MESSAGE : | 101 extension->is_app() ? IDS_BACKGROUND_CRASHED_APP_BALLOON_MESSAGE : |
| 102 IDS_BACKGROUND_CRASHED_EXTENSION_BALLOON_MESSAGE, | 102 IDS_BACKGROUND_CRASHED_EXTENSION_BALLOON_MESSAGE, |
| 103 UTF8ToUTF16(extension->name())); | 103 UTF8ToUTF16(extension->name())); |
| 104 string16 content_url = DesktopNotificationService::CreateDataUrl( | 104 string16 content_url = DesktopNotificationService::CreateDataUrl( |
| 105 extension->GetIconURL(Extension::EXTENSION_ICON_SMALLISH, | 105 extension->GetIconURL(Extension::EXTENSION_ICON_SMALLISH, |
| 106 ExtensionIconSet::MATCH_BIGGER), | 106 ExtensionIconSet::MATCH_BIGGER), |
| 107 string16(), message, WebKit::WebTextDirectionDefault); | 107 string16(), message, WebKit::WebTextDirectionDefault); |
| 108 Notification notification( | 108 Notification notification( |
| 109 extension->url(), GURL(content_url), string16(), string16(), | 109 extension->url(), GURL(content_url), string16(), string16(), |
| 110 new CrashNotificationDelegate(profile, extension)); | 110 new CrashNotificationDelegate(profile, extension)); |
| 111 g_browser_process->notification_ui_manager()->Add(notification, profile); | 111 g_browser_process->notification_ui_manager()->Add(notification, profile); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // an EXTENSION_UNLOADED notification. This UNLOADED signal causes all the | 292 // an EXTENSION_UNLOADED notification. This UNLOADED signal causes all the |
| 293 // notifications for this extension to be cancelled by | 293 // notifications for this extension to be cancelled by |
| 294 // DesktopNotificationService. For this reason, instead of showing the | 294 // DesktopNotificationService. For this reason, instead of showing the |
| 295 // balloon right now, we schedule it to show a little later. | 295 // balloon right now, we schedule it to show a little later. |
| 296 MessageLoop::current()->PostTask( | 296 MessageLoop::current()->PostTask( |
| 297 FROM_HERE, base::Bind(&ShowBalloon, extension, profile)); | 297 FROM_HERE, base::Bind(&ShowBalloon, extension, profile)); |
| 298 break; | 298 break; |
| 299 } | 299 } |
| 300 case chrome::NOTIFICATION_EXTENSION_UNLOADED: | 300 case chrome::NOTIFICATION_EXTENSION_UNLOADED: |
| 301 switch (content::Details<UnloadedExtensionInfo>(details)->reason) { | 301 switch (content::Details<UnloadedExtensionInfo>(details)->reason) { |
| 302 // Intentionally fall through. | 302 case extension_misc::UNLOAD_REASON_DISABLE: // Fall through. |
| 303 case extension_misc::UNLOAD_REASON_DISABLE: | 303 case extension_misc::UNLOAD_REASON_TERMINATE: // Fall through. |
| 304 case extension_misc::UNLOAD_REASON_UNINSTALL: | 304 case extension_misc::UNLOAD_REASON_UNINSTALL: |
| 305 ShutdownAssociatedBackgroundContents( | 305 ShutdownAssociatedBackgroundContents( |
| 306 ASCIIToUTF16(content::Details<UnloadedExtensionInfo>(details)-> | 306 ASCIIToUTF16(content::Details<UnloadedExtensionInfo>(details)-> |
| 307 extension->id())); | 307 extension->id())); |
| 308 break; | 308 break; |
| 309 case extension_misc::UNLOAD_REASON_UPDATE: { | 309 case extension_misc::UNLOAD_REASON_UPDATE: { |
| 310 // If there is a manifest specified background page, then shut it down | 310 // If there is a manifest specified background page, then shut it down |
| 311 // here, since if the updated extension still has the background page, | 311 // here, since if the updated extension still has the background page, |
| 312 // then it will be loaded from LOADED callback. Otherwise, leave | 312 // then it will be loaded from LOADED callback. Otherwise, leave |
| 313 // BackgroundContents in place. | 313 // BackgroundContents in place. |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 TabContents* new_contents, | 574 TabContents* new_contents, |
| 575 WindowOpenDisposition disposition, | 575 WindowOpenDisposition disposition, |
| 576 const gfx::Rect& initial_pos, | 576 const gfx::Rect& initial_pos, |
| 577 bool user_gesture) { | 577 bool user_gesture) { |
| 578 Browser* browser = BrowserList::GetLastActiveWithProfile( | 578 Browser* browser = BrowserList::GetLastActiveWithProfile( |
| 579 Profile::FromBrowserContext(new_contents->browser_context())); | 579 Profile::FromBrowserContext(new_contents->browser_context())); |
| 580 if (!browser) | 580 if (!browser) |
| 581 return; | 581 return; |
| 582 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); | 582 browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); |
| 583 } | 583 } |
| OLD | NEW |