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

Side by Side Diff: chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc

Issue 468033002: Remove worker process related codes from ContentBrowserClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chrome_content_browser_client_extensions_par t.h" 5 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par t.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 content::ResourceContext* resource_context, 328 content::ResourceContext* resource_context,
329 const GURL& current_url, 329 const GURL& current_url,
330 const GURL& new_url) { 330 const GURL& new_url) {
331 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 331 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
332 return CrossesExtensionProcessBoundary( 332 return CrossesExtensionProcessBoundary(
333 io_data->GetExtensionInfoMap()->extensions(), 333 io_data->GetExtensionInfoMap()->extensions(),
334 current_url, new_url, false); 334 current_url, new_url, false);
335 } 335 }
336 336
337 // static 337 // static
338 std::string ChromeContentBrowserClientExtensionsPart::GetWorkerProcessTitle(
339 const GURL& url, content::ResourceContext* context) {
340 // Check if it's an extension-created worker, in which case we want to use
341 // the name of the extension.
342 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
343 const Extension* extension =
344 io_data->GetExtensionInfoMap()->extensions().GetByID(url.host());
345 return extension ? extension->name() : std::string();
346 }
347
348 // static
349 bool ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL( 338 bool ChromeContentBrowserClientExtensionsPart::ShouldAllowOpenURL(
350 content::SiteInstance* site_instance, 339 content::SiteInstance* site_instance,
351 const GURL& from_url, 340 const GURL& from_url,
352 const GURL& to_url, 341 const GURL& to_url,
353 bool* result) { 342 bool* result) {
354 DCHECK(result); 343 DCHECK(result);
355 344
356 // Do not allow pages from the web or other extensions navigate to 345 // Do not allow pages from the web or other extensions navigate to
357 // non-web-accessible extension resources. 346 // non-web-accessible extension resources.
358 if (to_url.SchemeIs(kExtensionScheme) && 347 if (to_url.SchemeIs(kExtensionScheme) &&
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 448
460 BrowserThread::PostTask(BrowserThread::IO, 449 BrowserThread::PostTask(BrowserThread::IO,
461 FROM_HERE, 450 FROM_HERE,
462 base::Bind(&InfoMap::UnregisterExtensionProcess, 451 base::Bind(&InfoMap::UnregisterExtensionProcess,
463 ExtensionSystem::Get(profile)->info_map(), 452 ExtensionSystem::Get(profile)->info_map(),
464 extension->id(), 453 extension->id(),
465 site_instance->GetProcess()->GetID(), 454 site_instance->GetProcess()->GetID(),
466 site_instance->GetId())); 455 site_instance->GetId()));
467 } 456 }
468 457
469 void ChromeContentBrowserClientExtensionsPart::WorkerProcessCreated(
470 SiteInstance* site_instance,
471 int worker_process_id) {
472 ExtensionRegistry* extension_registry =
473 ExtensionRegistry::Get(site_instance->GetBrowserContext());
474 if (!extension_registry)
475 return;
476 const Extension* extension =
477 extension_registry->enabled_extensions().GetExtensionOrAppByURL(
478 site_instance->GetSiteURL());
479 if (!extension)
480 return;
481 ExtensionSystem* extension_system =
482 ExtensionSystem::Get(site_instance->GetBrowserContext());
483 extension_system->info_map()->RegisterExtensionWorkerProcess(
484 extension->id(), worker_process_id, site_instance->GetId());
485 }
486
487 void ChromeContentBrowserClientExtensionsPart::WorkerProcessTerminated(
488 SiteInstance* site_instance,
489 int worker_process_id) {
490 ExtensionSystem* extension_system =
491 ExtensionSystem::Get(site_instance->GetBrowserContext());
492 extension_system->info_map()->UnregisterExtensionWorkerProcess(
493 worker_process_id);
494 }
495
496 void ChromeContentBrowserClientExtensionsPart::OverrideWebkitPrefs( 458 void ChromeContentBrowserClientExtensionsPart::OverrideWebkitPrefs(
497 RenderViewHost* rvh, 459 RenderViewHost* rvh,
498 const GURL& url, 460 const GURL& url,
499 WebPreferences* web_prefs) { 461 WebPreferences* web_prefs) {
500 Profile* profile = 462 Profile* profile =
501 Profile::FromBrowserContext(rvh->GetProcess()->GetBrowserContext()); 463 Profile::FromBrowserContext(rvh->GetProcess()->GetBrowserContext());
502 464
503 ExtensionService* service = 465 ExtensionService* service =
504 ExtensionSystem::Get(profile)->extension_service(); 466 ExtensionSystem::Get(profile)->extension_service();
505 if (!service) 467 if (!service)
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 content::RenderProcessHost* process, 524 content::RenderProcessHost* process,
563 Profile* profile) { 525 Profile* profile) {
564 if (!process) 526 if (!process)
565 return; 527 return;
566 DCHECK(profile); 528 DCHECK(profile);
567 if (ProcessMap::Get(profile)->Contains(process->GetID())) 529 if (ProcessMap::Get(profile)->Contains(process->GetID()))
568 command_line->AppendSwitch(switches::kExtensionProcess); 530 command_line->AppendSwitch(switches::kExtensionProcess);
569 } 531 }
570 532
571 } // namespace extensions 533 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698