| 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 <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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 // If we're adding a new profile and running in multi-profile mode, this new | 258 // If we're adding a new profile and running in multi-profile mode, this new |
| 258 // profile should be added to the status icon if one currently exists. | 259 // profile should be added to the status icon if one currently exists. |
| 259 if (in_background_mode_ && status_icon_) | 260 if (in_background_mode_ && status_icon_) |
| 260 UpdateStatusTrayIconContextMenu(); | 261 UpdateStatusTrayIconContextMenu(); |
| 261 } | 262 } |
| 262 | 263 |
| 263 // static | 264 // static |
| 264 void BackgroundModeManager::LaunchBackgroundApplication( | 265 void BackgroundModeManager::LaunchBackgroundApplication( |
| 265 Profile* profile, | 266 Profile* profile, |
| 266 const Extension* extension) { | 267 const Extension* extension) { |
| 267 ExtensionService* service = profile->GetExtensionService(); | 268 ExtensionService* service = extensions::ExtensionSystem::Get(profile)-> |
| 269 extension_service(); |
| 268 extension_misc::LaunchContainer launch_container = | 270 extension_misc::LaunchContainer launch_container = |
| 269 service->extension_prefs()->GetLaunchContainer( | 271 service->extension_prefs()->GetLaunchContainer( |
| 270 extension, extensions::ExtensionPrefs::LAUNCH_REGULAR); | 272 extension, extensions::ExtensionPrefs::LAUNCH_REGULAR); |
| 271 application_launch::OpenApplication(application_launch::LaunchParams( | 273 application_launch::OpenApplication(application_launch::LaunchParams( |
| 272 profile, extension, launch_container, NEW_FOREGROUND_TAB)); | 274 profile, extension, launch_container, NEW_FOREGROUND_TAB)); |
| 273 } | 275 } |
| 274 | 276 |
| 275 bool BackgroundModeManager::IsBackgroundModeActiveForTest() { | 277 bool BackgroundModeManager::IsBackgroundModeActiveForTest() { |
| 276 return in_background_mode_; | 278 return in_background_mode_; |
| 277 } | 279 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 293 EndKeepAliveForStartup(); | 295 EndKeepAliveForStartup(); |
| 294 break; | 296 break; |
| 295 | 297 |
| 296 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 298 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
| 297 Extension* extension = content::Details<Extension>(details).ptr(); | 299 Extension* extension = content::Details<Extension>(details).ptr(); |
| 298 Profile* profile = content::Source<Profile>(source).ptr(); | 300 Profile* profile = content::Source<Profile>(source).ptr(); |
| 299 if (BackgroundApplicationListModel::IsBackgroundApp( | 301 if (BackgroundApplicationListModel::IsBackgroundApp( |
| 300 *extension, profile)) { | 302 *extension, profile)) { |
| 301 // Extensions loaded after the ExtensionsService is ready should be | 303 // Extensions loaded after the ExtensionsService is ready should be |
| 302 // treated as new installs. | 304 // treated as new installs. |
| 303 if (profile->GetExtensionService()->is_ready()) | 305 if (extensions::ExtensionSystem::Get(profile)->extension_service()-> |
| 306 is_ready()) { |
| 304 OnBackgroundAppInstalled(extension); | 307 OnBackgroundAppInstalled(extension); |
| 308 } |
| 305 } | 309 } |
| 306 } | 310 } |
| 307 break; | 311 break; |
| 308 case chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED: { | 312 case chrome::NOTIFICATION_EXTENSION_PERMISSIONS_UPDATED: { |
| 309 UpdatedExtensionPermissionsInfo* info = | 313 UpdatedExtensionPermissionsInfo* info = |
| 310 content::Details<UpdatedExtensionPermissionsInfo>(details).ptr(); | 314 content::Details<UpdatedExtensionPermissionsInfo>(details).ptr(); |
| 311 if (info->permissions->HasAPIPermission( | 315 if (info->permissions->HasAPIPermission( |
| 312 extensions::APIPermission::kBackground) && | 316 extensions::APIPermission::kBackground) && |
| 313 info->reason == UpdatedExtensionPermissionsInfo::ADDED) { | 317 info->reason == UpdatedExtensionPermissionsInfo::ADDED) { |
| 314 // Turned on background permission, so treat this as a new install. | 318 // Turned on background permission, so treat this as a new install. |
| (...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 } | 773 } |
| 770 } | 774 } |
| 771 return profile_it; | 775 return profile_it; |
| 772 } | 776 } |
| 773 | 777 |
| 774 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { | 778 bool BackgroundModeManager::IsBackgroundModePrefEnabled() const { |
| 775 PrefService* service = g_browser_process->local_state(); | 779 PrefService* service = g_browser_process->local_state(); |
| 776 DCHECK(service); | 780 DCHECK(service); |
| 777 return service->GetBoolean(prefs::kBackgroundModeEnabled); | 781 return service->GetBoolean(prefs::kBackgroundModeEnabled); |
| 778 } | 782 } |
| OLD | NEW |