| 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" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/location.h" |
| 12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 13 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
| 15 #include "base/prefs/scoped_user_pref_update.h" | 16 #include "base/prefs/scoped_user_pref_update.h" |
| 17 #include "base/single_thread_task_runner.h" |
| 16 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 19 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/thread_task_runner_handle.h" |
| 18 #include "base/time/time.h" | 21 #include "base/time/time.h" |
| 19 #include "base/values.h" | 22 #include "base/values.h" |
| 20 #include "chrome/browser/background/background_contents_service_factory.h" | 23 #include "chrome/browser/background/background_contents_service_factory.h" |
| 21 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/chrome_notification_types.h" | 25 #include "chrome/browser/chrome_notification_types.h" |
| 23 #include "chrome/browser/extensions/extension_service.h" | 26 #include "chrome/browser/extensions/extension_service.h" |
| 24 #include "chrome/browser/notifications/desktop_notification_service.h" | 27 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 25 #include "chrome/browser/notifications/notification.h" | 28 #include "chrome/browser/notifications/notification.h" |
| 26 #include "chrome/browser/notifications/notification_delegate.h" | 29 #include "chrome/browser/notifications/notification_delegate.h" |
| 27 #include "chrome/browser/notifications/notification_ui_manager.h" | 30 #include "chrome/browser/notifications/notification_ui_manager.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 g_browser_process->message_center()->SetVisibility( | 83 g_browser_process->message_center()->SetVisibility( |
| 81 message_center::VISIBILITY_TRANSIENT); | 84 message_center::VISIBILITY_TRANSIENT); |
| 82 #endif | 85 #endif |
| 83 } | 86 } |
| 84 } | 87 } |
| 85 | 88 |
| 86 // Closes the crash notification balloon for the app/extension with this id. | 89 // Closes the crash notification balloon for the app/extension with this id. |
| 87 void ScheduleCloseBalloon(const std::string& extension_id, Profile* profile) { | 90 void ScheduleCloseBalloon(const std::string& extension_id, Profile* profile) { |
| 88 if (g_disable_close_balloon_for_testing) | 91 if (g_disable_close_balloon_for_testing) |
| 89 return; | 92 return; |
| 90 base::MessageLoop::current()->PostTask( | 93 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 91 FROM_HERE, | 94 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id, |
| 92 base::Bind(&CloseBalloon, | 95 NotificationUIManager::GetProfileID(profile))); |
| 93 kNotificationPrefix + extension_id, | |
| 94 NotificationUIManager::GetProfileID(profile))); | |
| 95 } | 96 } |
| 96 | 97 |
| 97 // Delegate for the app/extension crash notification balloon. Restarts the | 98 // Delegate for the app/extension crash notification balloon. Restarts the |
| 98 // app/extension when the balloon is clicked. | 99 // app/extension when the balloon is clicked. |
| 99 class CrashNotificationDelegate : public NotificationDelegate { | 100 class CrashNotificationDelegate : public NotificationDelegate { |
| 100 public: | 101 public: |
| 101 CrashNotificationDelegate(Profile* profile, | 102 CrashNotificationDelegate(Profile* profile, |
| 102 const Extension* extension) | 103 const Extension* extension) |
| 103 : profile_(profile), | 104 : profile_(profile), |
| 104 is_hosted_app_(extension->is_hosted_app()), | 105 is_hosted_app_(extension->is_hosted_app()), |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 779 bool user_gesture, | 780 bool user_gesture, |
| 780 bool* was_blocked) { | 781 bool* was_blocked) { |
| 781 Browser* browser = chrome::FindLastActiveWithProfile( | 782 Browser* browser = chrome::FindLastActiveWithProfile( |
| 782 Profile::FromBrowserContext(new_contents->GetBrowserContext()), | 783 Profile::FromBrowserContext(new_contents->GetBrowserContext()), |
| 783 chrome::GetActiveDesktop()); | 784 chrome::GetActiveDesktop()); |
| 784 if (browser) { | 785 if (browser) { |
| 785 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 786 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 786 initial_rect, user_gesture, was_blocked); | 787 initial_rect, user_gesture, was_blocked); |
| 787 } | 788 } |
| 788 } | 789 } |
| OLD | NEW |