| 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_contents_service.h" | 5 #include "chrome/browser/background_contents_service.h" | 
| 6 | 6 | 
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" | 
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" | 
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" | 
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" | 
| 11 #include "base/values.h" | 11 #include "base/values.h" | 
|  | 12 #include "chrome/browser/background_contents_service_factory.h" | 
| 12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" | 
| 13 #include "chrome/browser/extensions/extension_host.h" | 14 #include "chrome/browser/extensions/extension_host.h" | 
| 14 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" | 
| 15 #include "chrome/browser/notifications/desktop_notification_service.h" | 16 #include "chrome/browser/notifications/desktop_notification_service.h" | 
| 16 #include "chrome/browser/notifications/notification.h" | 17 #include "chrome/browser/notifications/notification.h" | 
| 17 #include "chrome/browser/notifications/notification_ui_manager.h" | 18 #include "chrome/browser/notifications/notification_ui_manager.h" | 
| 18 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" | 
| 19 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 20 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" | 
| 21 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" | 
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 57   } | 58   } | 
| 58 | 59 | 
| 59   void Display() {} | 60   void Display() {} | 
| 60 | 61 | 
| 61   void Error() {} | 62   void Error() {} | 
| 62 | 63 | 
| 63   void Close(bool by_user) {} | 64   void Close(bool by_user) {} | 
| 64 | 65 | 
| 65   void Click() { | 66   void Click() { | 
| 66     if (is_hosted_app_) { | 67     if (is_hosted_app_) { | 
| 67       profile_->GetBackgroundContentsService()-> | 68       BackgroundContentsServiceFactory::GetForProfile(profile_)-> | 
| 68           LoadBackgroundContentsForExtension(profile_, extension_id_); | 69           LoadBackgroundContentsForExtension(profile_, extension_id_); | 
| 69     } else { | 70     } else { | 
| 70       profile_->GetExtensionService()->ReloadExtension(extension_id_); | 71       profile_->GetExtensionService()->ReloadExtension(extension_id_); | 
| 71     } | 72     } | 
| 72 | 73 | 
| 73     // Closing the balloon here should be OK, but it causes a crash on Mac | 74     // Closing the balloon here should be OK, but it causes a crash on Mac | 
| 74     // http://crbug.com/78167 | 75     // http://crbug.com/78167 | 
| 75     ScheduleCloseBalloon(extension_id_); | 76     ScheduleCloseBalloon(extension_id_); | 
| 76   } | 77   } | 
| 77 | 78 | 
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 254       ScheduleCloseBalloon(extension->id()); | 255       ScheduleCloseBalloon(extension->id()); | 
| 255       break; | 256       break; | 
| 256     } | 257     } | 
| 257     case NotificationType::EXTENSION_PROCESS_TERMINATED: | 258     case NotificationType::EXTENSION_PROCESS_TERMINATED: | 
| 258     case NotificationType::BACKGROUND_CONTENTS_TERMINATED: { | 259     case NotificationType::BACKGROUND_CONTENTS_TERMINATED: { | 
| 259       Profile* profile = Source<Profile>(source).ptr(); | 260       Profile* profile = Source<Profile>(source).ptr(); | 
| 260       const Extension* extension = NULL; | 261       const Extension* extension = NULL; | 
| 261       if (type.value == NotificationType::BACKGROUND_CONTENTS_TERMINATED) { | 262       if (type.value == NotificationType::BACKGROUND_CONTENTS_TERMINATED) { | 
| 262         BackgroundContents* bg = | 263         BackgroundContents* bg = | 
| 263             Details<BackgroundContents>(details).ptr(); | 264             Details<BackgroundContents>(details).ptr(); | 
| 264         std::string extension_id = UTF16ToASCII(profile-> | 265         std::string extension_id = UTF16ToASCII( | 
| 265             GetBackgroundContentsService()->GetParentApplicationId(bg)); | 266             BackgroundContentsServiceFactory::GetForProfile(profile)-> | 
|  | 267                 GetParentApplicationId(bg)); | 
| 266         extension = | 268         extension = | 
| 267           profile->GetExtensionService()->GetExtensionById(extension_id, false); | 269           profile->GetExtensionService()->GetExtensionById(extension_id, false); | 
| 268       } else { | 270       } else { | 
| 269         ExtensionHost* extension_host = Details<ExtensionHost>(details).ptr(); | 271         ExtensionHost* extension_host = Details<ExtensionHost>(details).ptr(); | 
| 270         extension = extension_host->extension(); | 272         extension = extension_host->extension(); | 
| 271       } | 273       } | 
| 272       if (!extension) | 274       if (!extension) | 
| 273         break; | 275         break; | 
| 274 | 276 | 
| 275       // When an extension crashes, EXTENSION_PROCESS_TERMINATED is followed by | 277       // When an extension crashes, EXTENSION_PROCESS_TERMINATED is followed by | 
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 558     TabContents* new_contents, | 560     TabContents* new_contents, | 
| 559     WindowOpenDisposition disposition, | 561     WindowOpenDisposition disposition, | 
| 560     const gfx::Rect& initial_pos, | 562     const gfx::Rect& initial_pos, | 
| 561     bool user_gesture) { | 563     bool user_gesture) { | 
| 562   Browser* browser = BrowserList::GetLastActiveWithProfile( | 564   Browser* browser = BrowserList::GetLastActiveWithProfile( | 
| 563       new_contents->profile()); | 565       new_contents->profile()); | 
| 564   if (!browser) | 566   if (!browser) | 
| 565     return; | 567     return; | 
| 566   browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); | 568   browser->AddTabContents(new_contents, disposition, initial_pos, user_gesture); | 
| 567 } | 569 } | 
| OLD | NEW | 
|---|