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 virtual void Display() override {} |
108 | 108 |
109 virtual void Error() OVERRIDE {} | 109 virtual void Error() override {} |
110 | 110 |
111 virtual void Close(bool by_user) OVERRIDE {} | 111 virtual void Close(bool by_user) override {} |
112 | 112 |
113 virtual void Click() OVERRIDE { | 113 virtual 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 virtual bool HasClickedListener() override { return true; } |
145 | 145 |
146 virtual std::string id() const OVERRIDE { | 146 virtual std::string id() const override { |
147 return kNotificationPrefix + extension_id_; | 147 return kNotificationPrefix + extension_id_; |
148 } | 148 } |
149 | 149 |
150 virtual content::WebContents* GetWebContents() const OVERRIDE { | 150 virtual content::WebContents* GetWebContents() const override { |
151 return NULL; | 151 return NULL; |
152 } | 152 } |
153 | 153 |
154 private: | 154 private: |
155 virtual ~CrashNotificationDelegate() {} | 155 virtual ~CrashNotificationDelegate() {} |
156 | 156 |
157 Profile* profile_; | 157 Profile* profile_; |
158 bool is_hosted_app_; | 158 bool is_hosted_app_; |
159 bool is_platform_app_; | 159 bool is_platform_app_; |
160 std::string extension_id_; | 160 std::string extension_id_; |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 bool user_gesture, | 780 bool user_gesture, |
781 bool* was_blocked) { | 781 bool* was_blocked) { |
782 Browser* browser = chrome::FindLastActiveWithProfile( | 782 Browser* browser = chrome::FindLastActiveWithProfile( |
783 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 783 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
784 chrome::GetActiveDesktop()); | 784 chrome::GetActiveDesktop()); |
785 if (browser) { | 785 if (browser) { |
786 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 786 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
787 initial_pos, user_gesture, was_blocked); | 787 initial_pos, user_gesture, was_blocked); |
788 } | 788 } |
789 } | 789 } |
OLD | NEW |