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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 g_browser_process->message_center()->SetVisibility( | 83 g_browser_process->message_center()->SetVisibility( |
84 message_center::VISIBILITY_TRANSIENT); | 84 message_center::VISIBILITY_TRANSIENT); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 // Closes the crash notification balloon for the app/extension with this id. | 88 // Closes the crash notification balloon for the app/extension with this id. |
89 void ScheduleCloseBalloon(const std::string& extension_id, Profile* profile) { | 89 void ScheduleCloseBalloon(const std::string& extension_id, Profile* profile) { |
90 if (g_disable_close_balloon_for_testing) | 90 if (g_disable_close_balloon_for_testing) |
91 return; | 91 return; |
92 base::ThreadTaskRunnerHandle::Get()->PostTask( | 92 base::ThreadTaskRunnerHandle::Get()->PostTask( |
93 FROM_HERE, base::Bind(&CloseBalloon, kNotificationPrefix + extension_id, | 93 FROM_HERE, |
94 NotificationUIManager::GetProfileID(profile))); | 94 base::BindOnce(&CloseBalloon, kNotificationPrefix + extension_id, |
| 95 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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 474 |
474 // If there is an existing BackoffEntry for the extension, clear it if | 475 // If there is an existing BackoffEntry for the extension, clear it if |
475 // the component extension stays loaded for 60 seconds. This avoids the | 476 // the component extension stays loaded for 60 seconds. This avoids the |
476 // situation of effectively disabling an extension for the entire browser | 477 // situation of effectively disabling an extension for the entire browser |
477 // session if there was a periodic crash (sometimes caused by another source). | 478 // session if there was a periodic crash (sometimes caused by another source). |
478 if (extensions::Manifest::IsComponentLocation(extension->location())) { | 479 if (extensions::Manifest::IsComponentLocation(extension->location())) { |
479 ComponentExtensionBackoffEntryMap::const_iterator it = | 480 ComponentExtensionBackoffEntryMap::const_iterator it = |
480 component_backoff_map_.find(extension->id()); | 481 component_backoff_map_.find(extension->id()); |
481 if (it != component_backoff_map_.end()) { | 482 if (it != component_backoff_map_.end()) { |
482 net::BackoffEntry* entry = component_backoff_map_[extension->id()].get(); | 483 net::BackoffEntry* entry = component_backoff_map_[extension->id()].get(); |
483 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, | 484 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
484 base::Bind(&BackgroundContentsService::MaybeClearBackoffEntry, | 485 FROM_HERE, |
485 weak_ptr_factory_.GetWeakPtr(), extension->id(), | 486 base::BindOnce(&BackgroundContentsService::MaybeClearBackoffEntry, |
486 entry->failure_count()), | 487 weak_ptr_factory_.GetWeakPtr(), extension->id(), |
| 488 entry->failure_count()), |
487 base::TimeDelta::FromSeconds(60)); | 489 base::TimeDelta::FromSeconds(60)); |
488 } | 490 } |
489 } | 491 } |
490 | 492 |
491 // Close the crash notification balloon for the app/extension, if any. | 493 // Close the crash notification balloon for the app/extension, if any. |
492 ScheduleCloseBalloon(extension->id(), profile); | 494 ScheduleCloseBalloon(extension->id(), profile); |
493 SendChangeNotification(profile); | 495 SendChangeNotification(profile); |
494 } | 496 } |
495 | 497 |
496 void BackgroundContentsService::OnExtensionUnloaded( | 498 void BackgroundContentsService::OnExtensionUnloaded( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 std::unique_ptr<net::BackoffEntry>>( | 565 std::unique_ptr<net::BackoffEntry>>( |
564 extension->id(), std::move(backoff_entry))); | 566 extension->id(), std::move(backoff_entry))); |
565 } | 567 } |
566 | 568 |
567 net::BackoffEntry* entry = component_backoff_map_[extension->id()].get(); | 569 net::BackoffEntry* entry = component_backoff_map_[extension->id()].get(); |
568 entry->InformOfRequest(false); | 570 entry->InformOfRequest(false); |
569 restart_delay = entry->GetTimeUntilRelease().InMilliseconds(); | 571 restart_delay = entry->GetTimeUntilRelease().InMilliseconds(); |
570 } | 572 } |
571 | 573 |
572 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 574 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
573 FROM_HERE, base::Bind(&ReloadExtension, extension->id(), profile), | 575 FROM_HERE, base::BindOnce(&ReloadExtension, extension->id(), profile), |
574 base::TimeDelta::FromMilliseconds(restart_delay)); | 576 base::TimeDelta::FromMilliseconds(restart_delay)); |
575 } | 577 } |
576 | 578 |
577 // Loads all background contents whose urls have been stored in prefs. | 579 // Loads all background contents whose urls have been stored in prefs. |
578 void BackgroundContentsService::LoadBackgroundContentsFromPrefs( | 580 void BackgroundContentsService::LoadBackgroundContentsFromPrefs( |
579 Profile* profile) { | 581 Profile* profile) { |
580 if (!prefs_) | 582 if (!prefs_) |
581 return; | 583 return; |
582 const base::DictionaryValue* contents = | 584 const base::DictionaryValue* contents = |
583 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents); | 585 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
849 const gfx::Rect& initial_rect, | 851 const gfx::Rect& initial_rect, |
850 bool user_gesture, | 852 bool user_gesture, |
851 bool* was_blocked) { | 853 bool* was_blocked) { |
852 Browser* browser = chrome::FindLastActiveWithProfile( | 854 Browser* browser = chrome::FindLastActiveWithProfile( |
853 Profile::FromBrowserContext(new_contents->GetBrowserContext())); | 855 Profile::FromBrowserContext(new_contents->GetBrowserContext())); |
854 if (browser) { | 856 if (browser) { |
855 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 857 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
856 initial_rect, user_gesture, was_blocked); | 858 initial_rect, user_gesture, was_blocked); |
857 } | 859 } |
858 } | 860 } |
OLD | NEW |