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

Side by Side Diff: extensions/browser/process_manager.cc

Issue 2149953002: Enable login screen apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Devlin and Maksim feedback Created 3 years, 9 months 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "extensions/browser/process_manager.h" 5 #include "extensions/browser/process_manager.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 bool ProcessManager::CreateBackgroundHost(const Extension* extension, 358 bool ProcessManager::CreateBackgroundHost(const Extension* extension,
359 const GURL& url) { 359 const GURL& url) {
360 // Hosted apps are taken care of from BackgroundContentsService. Ignore them 360 // Hosted apps are taken care of from BackgroundContentsService. Ignore them
361 // here. 361 // here.
362 if (extension->is_hosted_app()) 362 if (extension->is_hosted_app())
363 return false; 363 return false;
364 364
365 // Don't create hosts if the embedder doesn't allow it. 365 // Don't create hosts if the embedder doesn't allow it.
366 ProcessManagerDelegate* delegate = 366 ProcessManagerDelegate* delegate =
367 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate(); 367 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate();
368 if (delegate && !delegate->IsBackgroundPageAllowed(browser_context_)) 368 if (delegate &&
369 !delegate->IsBackgroundPageAllowed(browser_context_, extension))
Devlin 2017/03/13 19:39:35 We check this in three different places now, makin
achuithb 2017/03/15 00:40:25 It does seem that way :/ What would you propose?
369 return false; 370 return false;
370 371
371 // Don't create multiple background hosts for an extension. 372 // Don't create multiple background hosts for an extension.
372 if (GetBackgroundHostForExtension(extension->id())) 373 if (GetBackgroundHostForExtension(extension->id()))
373 return true; // TODO(kalman): return false here? It might break things... 374 return true; // TODO(kalman): return false here? It might break things...
374 375
375 ExtensionHost* host = 376 ExtensionHost* host =
376 new ExtensionHost(extension, GetSiteInstanceForURL(url).get(), url, 377 new ExtensionHost(extension, GetSiteInstanceForURL(url).get(), url,
377 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE); 378 VIEW_TYPE_EXTENSION_BACKGROUND_PAGE);
378 host->CreateRenderViewSoon(); 379 host->CreateRenderViewSoon();
379 OnBackgroundHostCreated(host); 380 OnBackgroundHostCreated(host);
380 return true; 381 return true;
381 } 382 }
382 383
383 void ProcessManager::MaybeCreateStartupBackgroundHosts() { 384 void ProcessManager::MaybeCreateStartupBackgroundHosts() {
384 if (startup_background_hosts_created_) 385 if (startup_background_hosts_created_)
385 return; 386 return;
386 387
387 // The embedder might disallow background pages entirely. 388 // The embedder might disallow background pages entirely.
388 ProcessManagerDelegate* delegate = 389 ProcessManagerDelegate* delegate =
389 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate(); 390 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate();
390 if (delegate && !delegate->IsBackgroundPageAllowed(browser_context_)) 391 if (delegate && !delegate->IsBackgroundPageAllowed(browser_context_, nullptr))
achuithb 2017/03/15 00:40:25 We could potentially drop this check since we chec
Devlin 2017/03/17 16:37:23 This one is somewhat beneficial, since it helps us
achuithb 2017/03/22 00:15:53 Done.
391 return; 392 return;
392 393
393 // The embedder might want to defer background page loading. For example, 394 // The embedder might want to defer background page loading. For example,
394 // Chrome defers background page loading when it is launched to show the app 395 // Chrome defers background page loading when it is launched to show the app
395 // list, then triggers a load later when a browser window opens. 396 // list, then triggers a load later when a browser window opens.
396 if (delegate && 397 if (delegate &&
397 delegate->DeferCreatingStartupBackgroundHosts(browser_context_)) 398 delegate->DeferCreatingStartupBackgroundHosts(browser_context_))
398 return; 399 return;
399 400
400 CreateStartupBackgroundHosts(); 401 CreateStartupBackgroundHosts();
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 const Extension* extension, 697 const Extension* extension,
697 UnloadedExtensionInfo::Reason reason) { 698 UnloadedExtensionInfo::Reason reason) {
698 ExtensionHost* host = GetBackgroundHostForExtension(extension->id()); 699 ExtensionHost* host = GetBackgroundHostForExtension(extension->id());
699 if (host != nullptr) 700 if (host != nullptr)
700 CloseBackgroundHost(host); 701 CloseBackgroundHost(host);
701 UnregisterExtension(extension->id()); 702 UnregisterExtension(extension->id());
702 } 703 }
703 704
704 void ProcessManager::CreateStartupBackgroundHosts() { 705 void ProcessManager::CreateStartupBackgroundHosts() {
705 DCHECK(!startup_background_hosts_created_); 706 DCHECK(!startup_background_hosts_created_);
707 ProcessManagerDelegate* delegate =
708 ExtensionsBrowserClient::Get()->GetProcessManagerDelegate();
706 for (const scoped_refptr<const Extension>& extension : 709 for (const scoped_refptr<const Extension>& extension :
707 extension_registry_->enabled_extensions()) { 710 extension_registry_->enabled_extensions()) {
708 CreateBackgroundHostForExtensionLoad(this, extension.get()); 711 if (delegate &&
712 delegate->IsBackgroundPageAllowed(browser_context_, extension.get()))
Devlin 2017/03/17 16:37:23 This one should be able to be avoided - we'll chec
achuithb 2017/03/22 00:15:53 Done.
713 CreateBackgroundHostForExtensionLoad(this, extension.get());
709 for (auto& observer : observer_list_) 714 for (auto& observer : observer_list_)
710 observer.OnBackgroundHostStartup(extension.get()); 715 observer.OnBackgroundHostStartup(extension.get());
711 } 716 }
712 } 717 }
713 718
714 void ProcessManager::OnBackgroundHostCreated(ExtensionHost* host) { 719 void ProcessManager::OnBackgroundHostCreated(ExtensionHost* host) {
715 DCHECK_EQ(browser_context_, host->browser_context()); 720 DCHECK_EQ(browser_context_, host->browser_context());
716 background_hosts_.insert(host); 721 background_hosts_.insert(host);
717 722
718 if (BackgroundInfo::HasLazyBackgroundPage(host->extension())) { 723 if (BackgroundInfo::HasLazyBackgroundPage(host->extension())) {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
990 if (extension && !IncognitoInfo::IsSplitMode(extension)) { 995 if (extension && !IncognitoInfo::IsSplitMode(extension)) {
991 BrowserContext* original_context = 996 BrowserContext* original_context =
992 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context()); 997 ExtensionsBrowserClient::Get()->GetOriginalContext(browser_context());
993 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url); 998 return ProcessManager::Get(original_context)->GetSiteInstanceForURL(url);
994 } 999 }
995 1000
996 return ProcessManager::GetSiteInstanceForURL(url); 1001 return ProcessManager::GetSiteInstanceForURL(url);
997 } 1002 }
998 1003
999 } // namespace extensions 1004 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698