Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Side by Side Diff: chrome/browser/background/background_mode_manager.cc

Issue 8539043: Refactor ProfileInfoCache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 321
322 void BackgroundModeManager::OnApplicationListChanged(Profile* profile) { 322 void BackgroundModeManager::OnApplicationListChanged(Profile* profile) {
323 if (!IsBackgroundModePrefEnabled()) 323 if (!IsBackgroundModePrefEnabled())
324 return; 324 return;
325 325
326 // Figure out what just happened based on the count of background apps. 326 // Figure out what just happened based on the count of background apps.
327 int count = GetBackgroundAppCount(); 327 int count = GetBackgroundAppCount();
328 328
329 // Update the profile cache with the fact whether background apps are running 329 // Update the profile cache with the fact whether background apps are running
330 // for this profile. 330 // for this profile.
331 size_t profile_index = profile_cache_->GetIndexOfProfileWithPath( 331 ProfileInfoEntry entry;
332 profile->GetPath()); 332 if (profile_cache_->GetInfoForProfile(profile->GetPath(), &entry)) {
333 if (profile_index != std::string::npos) { 333 entry.set_is_running_background_apps(
334 profile_cache_->SetBackgroundStatusOfProfileAtIndex( 334 GetBackgroundAppCountForProfile(profile) != 0);
335 profile_index, GetBackgroundAppCountForProfile(profile) != 0); 335 profile_cache_->SetInfoForProfile(entry);
336 } 336 }
337 337
338 if (count == 0) { 338 if (count == 0) {
339 // We've uninstalled our last background app, make sure we exit background 339 // We've uninstalled our last background app, make sure we exit background
340 // mode and no longer launch on startup. 340 // mode and no longer launch on startup.
341 EnableLaunchOnStartup(false); 341 EnableLaunchOnStartup(false);
342 EndBackgroundMode(); 342 EndBackgroundMode();
343 } else { 343 } else {
344 // We have at least one background app running - make sure we're in 344 // We have at least one background app running - make sure we're in
345 // background mode. 345 // background mode.
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 command_line->HasSwitch(switches::kDisableExtensions); 650 command_line->HasSwitch(switches::kDisableExtensions);
651 return background_mode_disabled; 651 return background_mode_disabled;
652 #endif 652 #endif
653 } 653 }
654 654
655 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { 655 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const {
656 PrefService* service = g_browser_process->local_state(); 656 PrefService* service = g_browser_process->local_state();
657 DCHECK(service); 657 DCHECK(service);
658 return service->GetBoolean(prefs::kBackgroundModeEnabled); 658 return service->GetBoolean(prefs::kBackgroundModeEnabled);
659 } 659 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.cc ('k') | chrome/browser/profiles/avatar_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698