| 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 "apps/app_load_service.h" | 9 #include "apps/app_load_service.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" | |
| 16 #include "base/metrics/histogram_macros.h" | 15 #include "base/metrics/histogram_macros.h" |
| 17 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
| 21 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 22 #include "base/values.h" | 21 #include "base/values.h" |
| 23 #include "chrome/browser/background/background_contents_service_factory.h" | 22 #include "chrome/browser/background/background_contents_service_factory.h" |
| 24 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/chrome_notification_types.h" | 24 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 // Make sure the extension-crash balloons are removed when the extension is | 516 // Make sure the extension-crash balloons are removed when the extension is |
| 518 // uninstalled/reloaded. We cannot do this from UNLOADED since a crashed | 517 // uninstalled/reloaded. We cannot do this from UNLOADED since a crashed |
| 519 // extension is unloaded immediately after the crash, not when user reloads or | 518 // extension is unloaded immediately after the crash, not when user reloads or |
| 520 // uninstalls the extension. | 519 // uninstalls the extension. |
| 521 ScheduleCloseBalloon(extension->id(), profile); | 520 ScheduleCloseBalloon(extension->id(), profile); |
| 522 } | 521 } |
| 523 | 522 |
| 524 void BackgroundContentsService::RestartForceInstalledExtensionOnCrash( | 523 void BackgroundContentsService::RestartForceInstalledExtensionOnCrash( |
| 525 const Extension* extension, | 524 const Extension* extension, |
| 526 Profile* profile) { | 525 Profile* profile) { |
| 527 base::MessageLoop::current()->PostDelayedTask(FROM_HERE, | 526 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 528 base::Bind(&ReloadExtension, extension->id(), profile), | 527 FROM_HERE, base::Bind(&ReloadExtension, extension->id(), profile), |
| 529 base::TimeDelta::FromMilliseconds(restart_delay_in_ms_)); | 528 base::TimeDelta::FromMilliseconds(restart_delay_in_ms_)); |
| 530 } | 529 } |
| 531 | 530 |
| 532 // Loads all background contents whose urls have been stored in prefs. | 531 // Loads all background contents whose urls have been stored in prefs. |
| 533 void BackgroundContentsService::LoadBackgroundContentsFromPrefs( | 532 void BackgroundContentsService::LoadBackgroundContentsFromPrefs( |
| 534 Profile* profile) { | 533 Profile* profile) { |
| 535 if (!prefs_) | 534 if (!prefs_) |
| 536 return; | 535 return; |
| 537 const base::DictionaryValue* contents = | 536 const base::DictionaryValue* contents = |
| 538 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents); | 537 prefs_->GetDictionary(prefs::kRegisteredBackgroundContents); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 788 const gfx::Rect& initial_rect, | 787 const gfx::Rect& initial_rect, |
| 789 bool user_gesture, | 788 bool user_gesture, |
| 790 bool* was_blocked) { | 789 bool* was_blocked) { |
| 791 Browser* browser = chrome::FindLastActiveWithProfile( | 790 Browser* browser = chrome::FindLastActiveWithProfile( |
| 792 Profile::FromBrowserContext(new_contents->GetBrowserContext())); | 791 Profile::FromBrowserContext(new_contents->GetBrowserContext())); |
| 793 if (browser) { | 792 if (browser) { |
| 794 chrome::AddWebContents(browser, NULL, new_contents, disposition, | 793 chrome::AddWebContents(browser, NULL, new_contents, disposition, |
| 795 initial_rect, user_gesture, was_blocked); | 794 initial_rect, user_gesture, was_blocked); |
| 796 } | 795 } |
| 797 } | 796 } |
| OLD | NEW |