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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/bind.h" |
8 #include "base/command_line.h" | 9 #include "base/command_line.h" |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
11 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/background/background_application_list_model.h" | 13 #include "chrome/browser/background/background_application_list_model.h" |
13 #include "chrome/browser/background/background_mode_manager.h" | 14 #include "chrome/browser/background/background_mode_manager.h" |
14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 | 420 |
420 /////////////////////////////////////////////////////////////////////////////// | 421 /////////////////////////////////////////////////////////////////////////////// |
421 // BackgroundModeManager, private | 422 // BackgroundModeManager, private |
422 void BackgroundModeManager::EndKeepAliveForStartup() { | 423 void BackgroundModeManager::EndKeepAliveForStartup() { |
423 if (keep_alive_for_startup_) { | 424 if (keep_alive_for_startup_) { |
424 keep_alive_for_startup_ = false; | 425 keep_alive_for_startup_ = false; |
425 // We call this via the message queue to make sure we don't try to end | 426 // We call this via the message queue to make sure we don't try to end |
426 // keep-alive (which can shutdown Chrome) before the message loop has | 427 // keep-alive (which can shutdown Chrome) before the message loop has |
427 // started. | 428 // started. |
428 MessageLoop::current()->PostTask( | 429 MessageLoop::current()->PostTask( |
429 FROM_HERE, NewRunnableFunction(BrowserList::EndKeepAlive)); | 430 FROM_HERE, base::Bind(&BrowserList::EndKeepAlive)); |
430 } | 431 } |
431 } | 432 } |
432 | 433 |
433 void BackgroundModeManager::StartBackgroundMode() { | 434 void BackgroundModeManager::StartBackgroundMode() { |
434 // Don't bother putting ourselves in background mode if we're already there | 435 // Don't bother putting ourselves in background mode if we're already there |
435 // or if background mode is disabled. | 436 // or if background mode is disabled. |
436 if (in_background_mode_ || | 437 if (in_background_mode_ || |
437 (!IsBackgroundModePrefEnabled() && !keep_alive_for_test_)) | 438 (!IsBackgroundModePrefEnabled() && !keep_alive_for_test_)) |
438 return; | 439 return; |
439 | 440 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
649 command_line->HasSwitch(switches::kDisableExtensions); | 650 command_line->HasSwitch(switches::kDisableExtensions); |
650 return background_mode_disabled; | 651 return background_mode_disabled; |
651 #endif | 652 #endif |
652 } | 653 } |
653 | 654 |
654 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 655 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
655 PrefService* service = g_browser_process->local_state(); | 656 PrefService* service = g_browser_process->local_state(); |
656 DCHECK(service); | 657 DCHECK(service); |
657 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 658 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
658 } | 659 } |
OLD | NEW |