OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Represents the browser side of the browser <--> renderer communication | 5 // Represents the browser side of the browser <--> renderer communication |
6 // channel. There will be one RenderProcessHost per renderer process. | 6 // channel. There will be one RenderProcessHost per renderer process. |
7 | 7 |
8 #include "chrome/browser/renderer_host/browser_render_process_host.h" | 8 #include "chrome/browser/renderer_host/browser_render_process_host.h" |
9 | 9 |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <sstream> | 13 #include <sstream> |
14 #include <vector> | 14 #include <vector> |
15 | 15 |
16 #include "base/command_line.h" | 16 #include "base/command_line.h" |
17 #include "base/debug_util.h" | 17 #include "base/debug_util.h" |
18 #include "base/file_util.h" | 18 #include "base/file_util.h" |
19 #include "base/logging.h" | 19 #include "base/logging.h" |
20 #include "base/path_service.h" | 20 #include "base/path_service.h" |
21 #include "base/process_util.h" | 21 #include "base/process_util.h" |
22 #include "base/shared_memory.h" | 22 #include "base/shared_memory.h" |
23 #include "base/singleton.h" | 23 #include "base/singleton.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 #include "base/thread.h" | 25 #include "base/thread.h" |
26 #include "chrome/app/result_codes.h" | 26 #include "chrome/app/result_codes.h" |
27 #include "chrome/browser/browser_process.h" | 27 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/cache_manager_host.h" | 28 #include "chrome/browser/cache_manager_host.h" |
29 #include "chrome/browser/extensions/user_script_master.h" | 29 #include "chrome/browser/extensions/user_script_master.h" |
30 #if defined(OS_WIN) | |
31 #include "chrome/browser/history/history.h" | 30 #include "chrome/browser/history/history.h" |
32 #else | |
33 // TODO(port): remove scaffolding, use history.h for both POSIX and WIN. | |
34 #include "chrome/common/temp_scaffolding_stubs.h" | |
35 #endif // !defined(OS_WIN) | |
36 | |
37 #include "chrome/browser/plugin_service.h" | 31 #include "chrome/browser/plugin_service.h" |
38 #include "chrome/browser/renderer_host/render_widget_helper.h" | 32 #include "chrome/browser/renderer_host/render_widget_helper.h" |
39 #include "chrome/browser/renderer_host/renderer_security_policy.h" | 33 #include "chrome/browser/renderer_host/renderer_security_policy.h" |
40 #include "chrome/browser/resource_message_filter.h" | 34 #include "chrome/browser/resource_message_filter.h" |
41 #if defined(OS_MACOSX) | |
42 // TODO(port): Enable when we finish porting spellchecker to os x. | |
43 #else | |
44 #include "chrome/browser/spellchecker.h" | 35 #include "chrome/browser/spellchecker.h" |
45 #endif // !defined(OS_WIN) | |
46 #include "chrome/browser/visitedlink_master.h" | 36 #include "chrome/browser/visitedlink_master.h" |
47 #include "chrome/common/chrome_paths.h" | 37 #include "chrome/common/chrome_paths.h" |
48 #include "chrome/common/chrome_switches.h" | 38 #include "chrome/common/chrome_switches.h" |
49 #include "chrome/common/debug_flags.h" | 39 #include "chrome/common/debug_flags.h" |
50 #include "chrome/common/l10n_util.h" | 40 #include "chrome/common/l10n_util.h" |
51 #include "chrome/common/logging_chrome.h" | 41 #include "chrome/common/logging_chrome.h" |
52 #include "chrome/common/pref_names.h" | 42 #include "chrome/common/pref_names.h" |
53 #include "chrome/common/pref_service.h" | 43 #include "chrome/common/pref_service.h" |
54 #include "chrome/common/process_watcher.h" | 44 #include "chrome/common/process_watcher.h" |
55 #include "chrome/renderer/render_process.h" | 45 #include "chrome/renderer/render_process.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 DCHECK(backgrounded_ == (visible_widgets_ == 0)); | 463 DCHECK(backgrounded_ == (visible_widgets_ == 0)); |
474 visible_widgets_--; | 464 visible_widgets_--; |
475 DCHECK(visible_widgets_ >= 0); | 465 DCHECK(visible_widgets_ >= 0); |
476 if (visible_widgets_ == 0) { | 466 if (visible_widgets_ == 0) { |
477 DCHECK(!backgrounded_); | 467 DCHECK(!backgrounded_); |
478 SetBackgrounded(true); | 468 SetBackgrounded(true); |
479 } | 469 } |
480 } | 470 } |
481 | 471 |
482 void BrowserRenderProcessHost::AddWord(const std::wstring& word) { | 472 void BrowserRenderProcessHost::AddWord(const std::wstring& word) { |
483 #if defined(OS_MACOSX) | |
484 // TODO(port): reimplement when we get the spell checker up and running on | |
485 // OS X. | |
486 NOTIMPLEMENTED(); | |
487 #else | |
488 base::Thread* io_thread = g_browser_process->io_thread(); | 473 base::Thread* io_thread = g_browser_process->io_thread(); |
489 if (profile()->GetSpellChecker()) { | 474 if (profile()->GetSpellChecker()) { |
490 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 475 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
491 profile()->GetSpellChecker(), &SpellChecker::AddWord, word)); | 476 profile()->GetSpellChecker(), &SpellChecker::AddWord, word)); |
492 } | 477 } |
493 #endif // !defined(OS_MACOSX) | |
494 } | 478 } |
495 | 479 |
496 base::ProcessHandle BrowserRenderProcessHost::GetRendererProcessHandle() { | 480 base::ProcessHandle BrowserRenderProcessHost::GetRendererProcessHandle() { |
497 if (run_renderer_in_process()) | 481 if (run_renderer_in_process()) |
498 return base::Process::Current().handle(); | 482 return base::Process::Current().handle(); |
499 return process_.handle(); | 483 return process_.handle(); |
500 } | 484 } |
501 | 485 |
502 void BrowserRenderProcessHost::InitVisitedLinks() { | 486 void BrowserRenderProcessHost::InitVisitedLinks() { |
503 VisitedLinkMaster* visitedlink_master = profile()->GetVisitedLinkMaster(); | 487 VisitedLinkMaster* visitedlink_master = profile()->GetVisitedLinkMaster(); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 // child processes determine the pid of the parent. | 783 // child processes determine the pid of the parent. |
800 // Build the channel ID. This is composed of a unique identifier for the | 784 // Build the channel ID. This is composed of a unique identifier for the |
801 // parent browser process, an identifier for the renderer/plugin instance, | 785 // parent browser process, an identifier for the renderer/plugin instance, |
802 // and a random component. We use a random component so that a hacked child | 786 // and a random component. We use a random component so that a hacked child |
803 // process can't cause denial of service by causing future named pipe creation | 787 // process can't cause denial of service by causing future named pipe creation |
804 // to fail. | 788 // to fail. |
805 return StringPrintf(L"%d.%x.%d", | 789 return StringPrintf(L"%d.%x.%d", |
806 base::GetCurrentProcId(), instance, | 790 base::GetCurrentProcId(), instance, |
807 base::RandInt(0, std::numeric_limits<int>::max())); | 791 base::RandInt(0, std::numeric_limits<int>::max())); |
808 } | 792 } |
OLD | NEW |