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 "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 class CrashNotificationDelegate : public NotificationDelegate { | 97 class CrashNotificationDelegate : public NotificationDelegate { |
98 public: | 98 public: |
99 CrashNotificationDelegate(Profile* profile, | 99 CrashNotificationDelegate(Profile* profile, |
100 const Extension* extension) | 100 const Extension* extension) |
101 : profile_(profile), | 101 : profile_(profile), |
102 is_hosted_app_(extension->is_hosted_app()), | 102 is_hosted_app_(extension->is_hosted_app()), |
103 is_platform_app_(extension->is_platform_app()), | 103 is_platform_app_(extension->is_platform_app()), |
104 extension_id_(extension->id()) { | 104 extension_id_(extension->id()) { |
105 } | 105 } |
106 | 106 |
107 virtual void Display() override {} | 107 void Display() override {} |
108 | 108 |
109 virtual void Error() override {} | 109 void Error() override {} |
110 | 110 |
111 virtual void Close(bool by_user) override {} | 111 void Close(bool by_user) override {} |
112 | 112 |
113 virtual void Click() override { | 113 void Click() override { |
114 // http://crbug.com/247790 involves a crash notification balloon being | 114 // http://crbug.com/247790 involves a crash notification balloon being |
115 // clicked while the extension isn't in the TERMINATED state. In that case, | 115 // clicked while the extension isn't in the TERMINATED state. In that case, |
116 // any of the "reload" methods called below can unload the extension, which | 116 // any of the "reload" methods called below can unload the extension, which |
117 // indirectly destroys *this, invalidating all the member variables, so we | 117 // indirectly destroys *this, invalidating all the member variables, so we |
118 // copy the extension ID before using it. | 118 // copy the extension ID before using it. |
119 std::string copied_extension_id = extension_id_; | 119 std::string copied_extension_id = extension_id_; |
120 if (is_hosted_app_) { | 120 if (is_hosted_app_) { |
121 // There can be a race here: user clicks the balloon, and simultaneously | 121 // There can be a race here: user clicks the balloon, and simultaneously |
122 // reloads the sad tab for the app. So we check here to be safe before | 122 // reloads the sad tab for the app. So we check here to be safe before |
123 // loading the background page. | 123 // loading the background page. |
(...skipping 10 matching lines...) Expand all Loading... |
134 } else { | 134 } else { |
135 extensions::ExtensionSystem::Get(profile_)->extension_service()-> | 135 extensions::ExtensionSystem::Get(profile_)->extension_service()-> |
136 ReloadExtension(copied_extension_id); | 136 ReloadExtension(copied_extension_id); |
137 } | 137 } |
138 | 138 |
139 // Closing the crash notification balloon for the app/extension here should | 139 // Closing the crash notification balloon for the app/extension here should |
140 // be OK, but it causes a crash on Mac, see: http://crbug.com/78167 | 140 // be OK, but it causes a crash on Mac, see: http://crbug.com/78167 |
141 ScheduleCloseBalloon(copied_extension_id, profile_); | 141 ScheduleCloseBalloon(copied_extension_id, profile_); |
142 } | 142 } |
143 | 143 |
144 virtual bool HasClickedListener() override { return true; } | 144 bool HasClickedListener() override { return true; } |
145 | 145 |
146 virtual std::string id() const override { | 146 std::string id() const override { |
147 return kNotificationPrefix + extension_id_; | 147 return kNotificationPrefix + extension_id_; |
148 } | 148 } |
149 | 149 |
150 private: | 150 private: |
151 virtual ~CrashNotificationDelegate() {} | 151 ~CrashNotificationDelegate() override {} |
152 | 152 |
153 Profile* profile_; | 153 Profile* profile_; |
154 bool is_hosted_app_; | 154 bool is_hosted_app_; |
155 bool is_platform_app_; | 155 bool is_platform_app_; |
156 std::string extension_id_; | 156 std::string extension_id_; |
157 | 157 |
158 DISALLOW_COPY_AND_ASSIGN(CrashNotificationDelegate); | 158 DISALLOW_COPY_AND_ASSIGN(CrashNotificationDelegate); |
159 }; | 159 }; |
160 | 160 |
161 #if defined(ENABLE_NOTIFICATIONS) | 161 #if defined(ENABLE_NOTIFICATIONS) |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 bool user_gesture, | 776 bool user_gesture, |
777 bool* was_blocked) { | 777 bool* was_blocked) { |
778 Browser* browser = chrome::FindLastActiveWithProfile( | 778 Browser* browser = chrome::FindLastActiveWithProfile( |
779 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 779 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
780 chrome::GetActiveDesktop()); | 780 chrome::GetActiveDesktop()); |
781 if (browser) { | 781 if (browser) { |
782 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 782 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
783 initial_pos, user_gesture, was_blocked); | 783 initial_pos, user_gesture, was_blocked); |
784 } | 784 } |
785 } | 785 } |
OLD | NEW |