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

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

Issue 11365181: Remove GetExtensionService from Profile. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: replace missing extension_system include Created 8 years 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
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.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/logging.h" 12 #include "base/logging.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "chrome/app/chrome_command_ids.h" 14 #include "chrome/app/chrome_command_ids.h"
15 #include "chrome/browser/background/background_application_list_model.h" 15 #include "chrome/browser/background/background_application_list_model.h"
16 #include "chrome/browser/background/background_mode_manager.h" 16 #include "chrome/browser/background/background_mode_manager.h"
17 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/browser_shutdown.h" 18 #include "chrome/browser/browser_shutdown.h"
19 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_system.h"
20 #include "chrome/browser/lifetime/application_lifetime.h" 21 #include "chrome/browser/lifetime/application_lifetime.h"
21 #include "chrome/browser/prefs/pref_service.h" 22 #include "chrome/browser/prefs/pref_service.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/profiles/profile_info_cache.h" 24 #include "chrome/browser/profiles/profile_info_cache.h"
24 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/browser/status_icons/status_icon.h" 26 #include "chrome/browser/status_icons/status_icon.h"
26 #include "chrome/browser/status_icons/status_tray.h" 27 #include "chrome/browser/status_icons/status_tray.h"
27 #include "chrome/browser/ui/browser.h" 28 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/browser_commands.h" 29 #include "chrome/browser/ui/browser_commands.h"
29 #include "chrome/browser/ui/browser_finder.h" 30 #include "chrome/browser/ui/browser_finder.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 // If we're adding a new profile and running in multi-profile mode, this new 260 // If we're adding a new profile and running in multi-profile mode, this new
260 // profile should be added to the status icon if one currently exists. 261 // profile should be added to the status icon if one currently exists.
261 if (in_background_mode_ && status_icon_) 262 if (in_background_mode_ && status_icon_)
262 UpdateStatusTrayIconContextMenu(); 263 UpdateStatusTrayIconContextMenu();
263 } 264 }
264 265
265 // static 266 // static
266 void BackgroundModeManager::LaunchBackgroundApplication( 267 void BackgroundModeManager::LaunchBackgroundApplication(
267 Profile* profile, 268 Profile* profile,
268 const Extension* extension) { 269 const Extension* extension) {
269 ExtensionService* service = profile->GetExtensionService(); 270 ExtensionService* service = extensions::ExtensionSystem::Get(profile)->
271 extension_service();
270 extension_misc::LaunchContainer launch_container = 272 extension_misc::LaunchContainer launch_container =
271 service->extension_prefs()->GetLaunchContainer( 273 service->extension_prefs()->GetLaunchContainer(
272 extension, extensions::ExtensionPrefs::LAUNCH_REGULAR); 274 extension, extensions::ExtensionPrefs::LAUNCH_REGULAR);
273 application_launch::OpenApplication(application_launch::LaunchParams( 275 application_launch::OpenApplication(application_launch::LaunchParams(
274 profile, extension, launch_container, NEW_FOREGROUND_TAB)); 276 profile, extension, launch_container, NEW_FOREGROUND_TAB));
275 } 277 }
276 278
277 bool BackgroundModeManager::IsBackgroundModeActiveForTest() { 279 bool BackgroundModeManager::IsBackgroundModeActiveForTest() {
278 return in_background_mode_; 280 return in_background_mode_;
279 } 281 }
(...skipping 15 matching lines...) Expand all
295 EndKeepAliveForStartup(); 297 EndKeepAliveForStartup();
296 break; 298 break;
297 299
298 case chrome::NOTIFICATION_EXTENSION_LOADED: { 300 case chrome::NOTIFICATION_EXTENSION_LOADED: {
299 Extension* extension = content::Details<Extension>(details).ptr(); 301 Extension* extension = content::Details<Extension>(details).ptr();
300 Profile* profile = content::Source<Profile>(source).ptr(); 302 Profile* profile = content::Source<Profile>(source).ptr();
301 if (BackgroundApplicationListModel::IsBackgroundApp( 303 if (BackgroundApplicationListModel::IsBackgroundApp(
302 *extension, profile)) { 304 *extension, profile)) {
303 // Extensions loaded after the ExtensionsService is ready should be 305 // Extensions loaded after the ExtensionsService is ready should be
304 // treated as new installs. 306 // treated as new installs.
305 if (profile->GetExtensionService()->is_ready()) 307 if (extensions::ExtensionSystem::Get(profile)->extension_service()->
308 is_ready()) {
306 OnBackgroundAppInstalled(extension); 309 OnBackgroundAppInstalled(extension);
310 }
307 } 311 }
308 } 312 }
309 break; 313 break;
310 case chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED: { 314 case chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED: {
311 UpdatedExtensionPermissionsInfo* info = 315 UpdatedExtensionPermissionsInfo* info =
312 content::Details<UpdatedExtensionPermissionsInfo>(details).ptr(); 316 content::Details<UpdatedExtensionPermissionsInfo>(details).ptr();
313 if (info->permissions->HasAPIPermission( 317 if (info->permissions->HasAPIPermission(
314 extensions::APIPermission::kBackground) && 318 extensions::APIPermission::kBackground) &&
315 info->reason == UpdatedExtensionPermissionsInfo::ADDED) { 319 info->reason == UpdatedExtensionPermissionsInfo::ADDED) {
316 // Turned on background permission, so treat this as a new install. 320 // Turned on background permission, so treat this as a new install.
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 } 775 }
772 } 776 }
773 return profile_it; 777 return profile_it;
774 } 778 }
775 779
776 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { 780 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const {
777 PrefService* service = g_browser_process->local_state(); 781 PrefService* service = g_browser_process->local_state();
778 DCHECK(service); 782 DCHECK(service);
779 return service->GetBoolean(prefs::kBackgroundModeEnabled); 783 return service->GetBoolean(prefs::kBackgroundModeEnabled);
780 } 784 }
OLDNEW
« no previous file with comments | « chrome/browser/background/background_contents_service.cc ('k') | chrome/browser/chrome_content_browser_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698