Chromium Code Reviews| 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 "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/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 MessageLoop::current()->PostTask( | 58 MessageLoop::current()->PostTask( |
| 59 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id)); | 59 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id)); |
| 60 } | 60 } |
| 61 | 61 |
| 62 class CrashNotificationDelegate : public NotificationDelegate { | 62 class CrashNotificationDelegate : public NotificationDelegate { |
| 63 public: | 63 public: |
| 64 CrashNotificationDelegate(Profile* profile, | 64 CrashNotificationDelegate(Profile* profile, |
| 65 const Extension* extension) | 65 const Extension* extension) |
| 66 : profile_(profile), | 66 : profile_(profile), |
| 67 is_hosted_app_(extension->is_hosted_app()), | 67 is_hosted_app_(extension->is_hosted_app()), |
| 68 is_platform_app_(extension->is_platform_app()), | |
| 68 extension_id_(extension->id()) { | 69 extension_id_(extension->id()) { |
| 69 } | 70 } |
| 70 | 71 |
| 71 virtual void Display() OVERRIDE {} | 72 virtual void Display() OVERRIDE {} |
| 72 | 73 |
| 73 virtual void Error() OVERRIDE {} | 74 virtual void Error() OVERRIDE {} |
| 74 | 75 |
| 75 virtual void Close(bool by_user) OVERRIDE {} | 76 virtual void Close(bool by_user) OVERRIDE {} |
| 76 | 77 |
| 77 virtual void Click() OVERRIDE { | 78 virtual void Click() OVERRIDE { |
| 78 if (is_hosted_app_) { | 79 if (is_hosted_app_) { |
| 79 // There can be a race here: user clicks the balloon, and simultaneously | 80 // There can be a race here: user clicks the balloon, and simultaneously |
| 80 // reloads the sad tab for the app. So we check here to be safe before | 81 // reloads the sad tab for the app. So we check here to be safe before |
| 81 // loading the background page. | 82 // loading the background page. |
| 82 BackgroundContentsService* service = | 83 BackgroundContentsService* service = |
| 83 BackgroundContentsServiceFactory::GetForProfile(profile_); | 84 BackgroundContentsServiceFactory::GetForProfile(profile_); |
| 84 if (!service->GetAppBackgroundContents(ASCIIToUTF16(extension_id_))) | 85 if (!service->GetAppBackgroundContents(ASCIIToUTF16(extension_id_))) |
| 85 service->LoadBackgroundContentsForExtension(profile_, extension_id_); | 86 service->LoadBackgroundContentsForExtension(profile_, extension_id_); |
| 86 } else { | 87 } else { |
|
benwells
2012/12/21 03:48:55
Is this meant to be if (is_platform_app_) {?
koz (OOO until 15th September)
2012/12/21 04:36:50
Yes, yes it is. Done.
| |
| 87 extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 88 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
| 88 ReloadExtension(extension_id_); | 89 ReloadExtensionWithRestartEvent(extension_id_); |
| 89 } | 90 } |
| 90 | 91 |
| 91 // Closing the balloon here should be OK, but it causes a crash on Mac | 92 // Closing the balloon here should be OK, but it causes a crash on Mac |
| 92 // http://crbug.com/78167 | 93 // http://crbug.com/78167 |
| 93 ScheduleCloseBalloon(extension_id_); | 94 ScheduleCloseBalloon(extension_id_); |
| 94 } | 95 } |
| 95 | 96 |
| 96 virtual std::string id() const OVERRIDE { | 97 virtual std::string id() const OVERRIDE { |
| 97 return kNotificationPrefix + extension_id_; | 98 return kNotificationPrefix + extension_id_; |
| 98 } | 99 } |
| 99 | 100 |
| 100 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE { | 101 virtual content::RenderViewHost* GetRenderViewHost() const OVERRIDE { |
| 101 return NULL; | 102 return NULL; |
| 102 } | 103 } |
| 103 | 104 |
| 104 private: | 105 private: |
| 105 virtual ~CrashNotificationDelegate() {} | 106 virtual ~CrashNotificationDelegate() {} |
| 106 | 107 |
| 107 Profile* profile_; | 108 Profile* profile_; |
| 108 bool is_hosted_app_; | 109 bool is_hosted_app_; |
| 110 bool is_platform_app_; | |
| 109 std::string extension_id_; | 111 std::string extension_id_; |
| 110 | 112 |
| 111 DISALLOW_COPY_AND_ASSIGN(CrashNotificationDelegate); | 113 DISALLOW_COPY_AND_ASSIGN(CrashNotificationDelegate); |
| 112 }; | 114 }; |
| 113 | 115 |
| 114 void ShowBalloon(const Extension* extension, Profile* profile) { | 116 void ShowBalloon(const Extension* extension, Profile* profile) { |
| 115 #if defined(ENABLE_NOTIFICATIONS) | 117 #if defined(ENABLE_NOTIFICATIONS) |
| 116 string16 title; // no notifiaction title | 118 string16 title; // no notifiaction title |
| 117 string16 message = l10n_util::GetStringFUTF16( | 119 string16 message = l10n_util::GetStringFUTF16( |
| 118 extension->is_app() ? IDS_BACKGROUND_CRASHED_APP_BALLOON_MESSAGE : | 120 extension->is_app() ? IDS_BACKGROUND_CRASHED_APP_BALLOON_MESSAGE : |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 bool user_gesture, | 627 bool user_gesture, |
| 626 bool* was_blocked) { | 628 bool* was_blocked) { |
| 627 Browser* browser = chrome::FindLastActiveWithProfile( | 629 Browser* browser = chrome::FindLastActiveWithProfile( |
| 628 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 630 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 629 chrome::GetActiveDesktop()); | 631 chrome::GetActiveDesktop()); |
| 630 if (browser) { | 632 if (browser) { |
| 631 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 633 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 632 initial_pos, user_gesture, was_blocked); | 634 initial_pos, user_gesture, was_blocked); |
| 633 } | 635 } |
| 634 } | 636 } |
| OLD | NEW |