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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 }; | 159 }; |
160 | 160 |
161 #if defined(ENABLE_NOTIFICATIONS) | 161 #if defined(ENABLE_NOTIFICATIONS) |
162 void NotificationImageReady( | 162 void NotificationImageReady( |
163 const std::string extension_name, | 163 const std::string extension_name, |
164 const base::string16 message, | 164 const base::string16 message, |
165 scoped_refptr<CrashNotificationDelegate> delegate, | 165 scoped_refptr<CrashNotificationDelegate> delegate, |
166 Profile* profile, | 166 Profile* profile, |
167 const gfx::Image& icon) { | 167 const gfx::Image& icon) { |
168 gfx::Image notification_icon(icon); | 168 gfx::Image notification_icon(icon); |
169 if (icon.IsEmpty()) { | 169 if (notification_icon.IsEmpty()) { |
170 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 170 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
171 notification_icon = rb.GetImageNamed(IDR_EXTENSION_DEFAULT_ICON); | 171 notification_icon = rb.GetImageNamed(IDR_EXTENSION_DEFAULT_ICON); |
172 } | 172 } |
173 | 173 |
174 // Origin URL must be different from the crashed extension to avoid the | 174 // Origin URL must be different from the crashed extension to avoid the |
175 // conflict. NotificationSystemObserver will cancel all notifications from | 175 // conflict. NotificationSystemObserver will cancel all notifications from |
176 // the same origin when NOTIFICATION_EXTENSION_UNLOADED. | 176 // the same origin when NOTIFICATION_EXTENSION_UNLOADED. |
177 // TODO(mukai, dewittj): remove this and switch to message center | 177 // TODO(mukai, dewittj): remove this and switch to message center |
178 // notifications. | 178 // notifications. |
179 DesktopNotificationService::AddIconNotification( | 179 DesktopNotificationService::AddIconNotification( |
180 GURL() /* empty origin */, | 180 GURL() /* empty origin */, |
181 base::string16(), | 181 base::string16(), |
182 message, | 182 message, |
183 icon, | 183 notification_icon, |
184 base::string16(), | 184 base::string16(), |
185 delegate.get(), | 185 delegate.get(), |
186 profile); | 186 profile); |
187 } | 187 } |
188 #endif | 188 #endif |
189 | 189 |
190 // Show a popup notification balloon with a crash message for a given app/ | 190 // Show a popup notification balloon with a crash message for a given app/ |
191 // extension. | 191 // extension. |
192 void ShowBalloon(const Extension* extension, Profile* profile) { | 192 void ShowBalloon(const Extension* extension, Profile* profile) { |
193 #if defined(ENABLE_NOTIFICATIONS) | 193 #if defined(ENABLE_NOTIFICATIONS) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 DCHECK(contents_map_.empty()); | 273 DCHECK(contents_map_.empty()); |
274 } | 274 } |
275 | 275 |
276 // static | 276 // static |
277 void BackgroundContentsService:: | 277 void BackgroundContentsService:: |
278 SetRestartDelayForForceInstalledAppsAndExtensionsForTesting( | 278 SetRestartDelayForForceInstalledAppsAndExtensionsForTesting( |
279 int restart_delay_in_ms) { | 279 int restart_delay_in_ms) { |
280 restart_delay_in_ms_ = restart_delay_in_ms; | 280 restart_delay_in_ms_ = restart_delay_in_ms; |
281 } | 281 } |
282 | 282 |
| 283 // static |
| 284 std::string BackgroundContentsService::GetNotificationIdForExtensionForTesting( |
| 285 const std::string& extension_id) { |
| 286 return kNotificationPrefix + extension_id; |
| 287 } |
| 288 |
| 289 // static |
| 290 void BackgroundContentsService::ShowBalloonForTesting( |
| 291 const extensions::Extension* extension, |
| 292 Profile* profile) { |
| 293 ShowBalloon(extension, profile); |
| 294 } |
| 295 |
283 std::vector<BackgroundContents*> | 296 std::vector<BackgroundContents*> |
284 BackgroundContentsService::GetBackgroundContents() const | 297 BackgroundContentsService::GetBackgroundContents() const |
285 { | 298 { |
286 std::vector<BackgroundContents*> contents; | 299 std::vector<BackgroundContents*> contents; |
287 for (BackgroundContentsMap::const_iterator it = contents_map_.begin(); | 300 for (BackgroundContentsMap::const_iterator it = contents_map_.begin(); |
288 it != contents_map_.end(); ++it) | 301 it != contents_map_.end(); ++it) |
289 contents.push_back(it->second.contents); | 302 contents.push_back(it->second.contents); |
290 return contents; | 303 return contents; |
291 } | 304 } |
292 | 305 |
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 bool user_gesture, | 779 bool user_gesture, |
767 bool* was_blocked) { | 780 bool* was_blocked) { |
768 Browser* browser = chrome::FindLastActiveWithProfile( | 781 Browser* browser = chrome::FindLastActiveWithProfile( |
769 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 782 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
770 chrome::GetActiveDesktop()); | 783 chrome::GetActiveDesktop()); |
771 if (browser) { | 784 if (browser) { |
772 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 785 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
773 initial_pos, user_gesture, was_blocked); | 786 initial_pos, user_gesture, was_blocked); |
774 } | 787 } |
775 } | 788 } |
OLD | NEW |