OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/worker_host/worker_process_host.h" | 5 #include "content/browser/worker_host/worker_process_host.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/extensions/extension_info_map.h" | |
16 #include "content/browser/appcache/appcache_dispatcher_host.h" | 15 #include "content/browser/appcache/appcache_dispatcher_host.h" |
17 #include "content/browser/browser_thread.h" | 16 #include "content/browser/browser_thread.h" |
18 #include "content/browser/child_process_security_policy.h" | 17 #include "content/browser/child_process_security_policy.h" |
19 #include "content/browser/content_browser_client.h" | 18 #include "content/browser/content_browser_client.h" |
20 #include "content/browser/file_system/file_system_dispatcher_host.h" | 19 #include "content/browser/file_system/file_system_dispatcher_host.h" |
21 #include "content/browser/mime_registry_message_filter.h" | 20 #include "content/browser/mime_registry_message_filter.h" |
22 #include "content/browser/renderer_host/blob_message_filter.h" | 21 #include "content/browser/renderer_host/blob_message_filter.h" |
23 #include "content/browser/renderer_host/database_message_filter.h" | 22 #include "content/browser/renderer_host/database_message_filter.h" |
24 #include "content/browser/renderer_host/file_utilities_message_filter.h" | 23 #include "content/browser/renderer_host/file_utilities_message_filter.h" |
25 #include "content/browser/renderer_host/render_view_host.h" | 24 #include "content/browser/renderer_host/render_view_host.h" |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 } | 449 } |
451 } | 450 } |
452 | 451 |
453 bool WorkerProcessHost::CanShutdown() { | 452 bool WorkerProcessHost::CanShutdown() { |
454 return instances_.empty(); | 453 return instances_.empty(); |
455 } | 454 } |
456 | 455 |
457 void WorkerProcessHost::UpdateTitle() { | 456 void WorkerProcessHost::UpdateTitle() { |
458 std::set<std::string> titles; | 457 std::set<std::string> titles; |
459 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { | 458 for (Instances::iterator i = instances_.begin(); i != instances_.end(); ++i) { |
460 std::string title = | 459 // Allow the embedder first crack at special casing the title. |
461 net::RegistryControlledDomainService::GetDomainAndRegistry(i->url()); | 460 std::string title = content::GetContentClient()->browser()-> |
| 461 GetWorkerProcessTitle(i->url(), *resource_context_); |
| 462 |
| 463 if (title.empty()) { |
| 464 title = net::RegistryControlledDomainService::GetDomainAndRegistry( |
| 465 i->url()); |
| 466 } |
| 467 |
462 // Use the host name if the domain is empty, i.e. localhost or IP address. | 468 // Use the host name if the domain is empty, i.e. localhost or IP address. |
463 if (title.empty()) | 469 if (title.empty()) |
464 title = i->url().host(); | 470 title = i->url().host(); |
465 | 471 |
466 // Check if it's an extension-created worker, in which case we want to use | |
467 // the name of the extension. | |
468 // TODO(mpcomplete): move out of content. http:://crbug.com/76789 | |
469 const Extension* extension = | |
470 resource_context_->extension_info_map()->extensions().GetByID(title); | |
471 if (extension) { | |
472 titles.insert(extension->name()); | |
473 continue; | |
474 } | |
475 | |
476 // If the host name is empty, i.e. file url, use the path. | 472 // If the host name is empty, i.e. file url, use the path. |
477 if (title.empty()) | 473 if (title.empty()) |
478 title = i->url().path(); | 474 title = i->url().path(); |
479 titles.insert(title); | 475 titles.insert(title); |
480 } | 476 } |
481 | 477 |
482 std::string display_title; | 478 std::string display_title; |
483 for (std::set<std::string>::iterator i = titles.begin(); | 479 for (std::set<std::string>::iterator i = titles.begin(); |
484 i != titles.end(); ++i) { | 480 i != titles.end(); ++i) { |
485 if (!display_title.empty()) | 481 if (!display_title.empty()) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 } | 629 } |
634 } | 630 } |
635 return false; | 631 return false; |
636 } | 632 } |
637 | 633 |
638 WorkerProcessHost::WorkerInstance::FilterInfo | 634 WorkerProcessHost::WorkerInstance::FilterInfo |
639 WorkerProcessHost::WorkerInstance::GetFilter() const { | 635 WorkerProcessHost::WorkerInstance::GetFilter() const { |
640 DCHECK(NumFilters() == 1); | 636 DCHECK(NumFilters() == 1); |
641 return *filters_.begin(); | 637 return *filters_.begin(); |
642 } | 638 } |
OLD | NEW |