| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <iterator> | 10 #include <iterator> |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, | 348 registrar_.Add(this, chrome::NOTIFICATION_APP_TERMINATING, |
| 349 content::NotificationService::AllBrowserContextsAndSources()); | 349 content::NotificationService::AllBrowserContextsAndSources()); |
| 350 registrar_.Add(this, | 350 registrar_.Add(this, |
| 351 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 351 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| 352 content::NotificationService::AllBrowserContextsAndSources()); | 352 content::NotificationService::AllBrowserContextsAndSources()); |
| 353 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 353 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 354 content::NotificationService::AllBrowserContextsAndSources()); | 354 content::NotificationService::AllBrowserContextsAndSources()); |
| 355 registrar_.Add(this, | 355 registrar_.Add(this, |
| 356 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, | 356 chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, |
| 357 content::Source<Profile>(profile_)); | 357 content::Source<Profile>(profile_)); |
| 358 #if defined(OS_CHROMEOS) | |
| 359 // Sign in profile extension service should observe session start - when the | |
| 360 // session is started, the context's process map should be updated to consider | |
| 361 // extension scripts to run in lock screen context (as the sign-in profile | |
| 362 // will be used to host lock screen apps from that point). | |
| 363 // TODO(tbarzic): Consider introducing a profile dedicated to lock screen apps | |
| 364 // so the process map's 'is lock screen context' flag does not have to be | |
| 365 // changed when the user session starts. | |
| 366 if (chromeos::ProfileHelper::IsSigninProfile(profile_)) { | |
| 367 registrar_.Add(this, chrome::NOTIFICATION_SESSION_STARTED, | |
| 368 content::NotificationService::AllSources()); | |
| 369 } | |
| 370 #endif | |
| 371 | 358 |
| 372 UpgradeDetector::GetInstance()->AddObserver(this); | 359 UpgradeDetector::GetInstance()->AddObserver(this); |
| 373 | 360 |
| 374 extensions::ExtensionManagementFactory::GetForBrowserContext(profile_) | 361 extensions::ExtensionManagementFactory::GetForBrowserContext(profile_) |
| 375 ->AddObserver(this); | 362 ->AddObserver(this); |
| 376 | 363 |
| 377 // Set up the ExtensionUpdater. | 364 // Set up the ExtensionUpdater. |
| 378 if (autoupdate_enabled) { | 365 if (autoupdate_enabled) { |
| 379 int update_frequency = extensions::kDefaultUpdateFrequencySeconds; | 366 int update_frequency = extensions::kDefaultUpdateFrequencySeconds; |
| 380 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { | 367 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 TRACE_EVENT0("browser,startup", "ExtensionService::Init"); | 445 TRACE_EVENT0("browser,startup", "ExtensionService::Init"); |
| 459 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.ExtensionServiceInitTime"); | 446 SCOPED_UMA_HISTOGRAM_TIMER("Extensions.ExtensionServiceInitTime"); |
| 460 | 447 |
| 461 DCHECK(!is_ready()); // Can't redo init. | 448 DCHECK(!is_ready()); // Can't redo init. |
| 462 DCHECK_EQ(registry_->enabled_extensions().size(), 0u); | 449 DCHECK_EQ(registry_->enabled_extensions().size(), 0u); |
| 463 | 450 |
| 464 component_loader_->LoadAll(); | 451 component_loader_->LoadAll(); |
| 465 bool load_saved_extensions = true; | 452 bool load_saved_extensions = true; |
| 466 bool load_command_line_extensions = extensions_enabled_; | 453 bool load_command_line_extensions = extensions_enabled_; |
| 467 #if defined(OS_CHROMEOS) | 454 #if defined(OS_CHROMEOS) |
| 468 if (chromeos::ProfileHelper::IsSigninProfile(profile_)) { | 455 if (chromeos::ProfileHelper::IsSigninProfile(profile_) || |
| 456 chromeos::ProfileHelper::IsLockScreenAppProfile(profile_)) { |
| 469 load_saved_extensions = false; | 457 load_saved_extensions = false; |
| 470 load_command_line_extensions = false; | 458 load_command_line_extensions = false; |
| 471 } | 459 } |
| 472 #endif | 460 #endif |
| 473 if (load_saved_extensions) | 461 if (load_saved_extensions) |
| 474 extensions::InstalledLoader(this).LoadAllExtensions(); | 462 extensions::InstalledLoader(this).LoadAllExtensions(); |
| 475 | 463 |
| 476 OnInstalledExtensionsLoaded(); | 464 OnInstalledExtensionsLoaded(); |
| 477 | 465 |
| 478 LoadExtensionsFromCommandLineFlag(switches::kDisableExtensionsExcept); | 466 LoadExtensionsFromCommandLineFlag(switches::kDisableExtensionsExcept); |
| (...skipping 1781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2260 BrowserThread::PostTask( | 2248 BrowserThread::PostTask( |
| 2261 BrowserThread::IO, FROM_HERE, | 2249 BrowserThread::IO, FROM_HERE, |
| 2262 base::BindOnce(&extensions::InfoMap::UnregisterAllExtensionsInProcess, | 2250 base::BindOnce(&extensions::InfoMap::UnregisterAllExtensionsInProcess, |
| 2263 system_->info_map(), process->GetID())); | 2251 system_->info_map(), process->GetID())); |
| 2264 break; | 2252 break; |
| 2265 } | 2253 } |
| 2266 case chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED: { | 2254 case chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED: { |
| 2267 OnProfileDestructionStarted(); | 2255 OnProfileDestructionStarted(); |
| 2268 break; | 2256 break; |
| 2269 } | 2257 } |
| 2270 #if defined(OS_CHROMEOS) | |
| 2271 case chrome::NOTIFICATION_SESSION_STARTED: { | |
| 2272 DCHECK(chromeos::ProfileHelper::IsSigninProfile(profile_)); | |
| 2273 | |
| 2274 // When the user session starts, mark the signin context as lock screen | |
| 2275 // context, as it will be used to host apps on lock screen. | |
| 2276 extensions::ProcessMap::Get(profile_)->set_is_lock_screen_context(true); | |
| 2277 BrowserThread::PostTask( | |
| 2278 BrowserThread::IO, FROM_HERE, | |
| 2279 base::BindOnce(&extensions::InfoMap::SetIsLockScreenContext, | |
| 2280 system_->info_map(), true)); | |
| 2281 break; | |
| 2282 } | |
| 2283 #endif | |
| 2284 | 2258 |
| 2285 default: | 2259 default: |
| 2286 NOTREACHED() << "Unexpected notification type."; | 2260 NOTREACHED() << "Unexpected notification type."; |
| 2287 } | 2261 } |
| 2288 } | 2262 } |
| 2289 | 2263 |
| 2290 int ExtensionService::GetDisableReasonsOnInstalled(const Extension* extension) { | 2264 int ExtensionService::GetDisableReasonsOnInstalled(const Extension* extension) { |
| 2291 bool is_update_from_same_type = false; | 2265 bool is_update_from_same_type = false; |
| 2292 { | 2266 { |
| 2293 const Extension* existing_extension = | 2267 const Extension* existing_extension = |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2605 | 2579 |
| 2606 if (!has_orphaned_dev_tools && !is_component_extension) | 2580 if (!has_orphaned_dev_tools && !is_component_extension) |
| 2607 return; | 2581 return; |
| 2608 | 2582 |
| 2609 // Wake up the event page by posting a dummy task. | 2583 // Wake up the event page by posting a dummy task. |
| 2610 extensions::LazyBackgroundTaskQueue* queue = | 2584 extensions::LazyBackgroundTaskQueue* queue = |
| 2611 extensions::LazyBackgroundTaskQueue::Get(profile_); | 2585 extensions::LazyBackgroundTaskQueue::Get(profile_); |
| 2612 queue->AddPendingTask(profile_, extension->id(), | 2586 queue->AddPendingTask(profile_, extension->id(), |
| 2613 base::Bind(&DoNothingWithExtensionHost)); | 2587 base::Bind(&DoNothingWithExtensionHost)); |
| 2614 } | 2588 } |
| OLD | NEW |