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) |
30 #include "chrome/browser/history/history.h" | 31 #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 |
31 #include "chrome/browser/plugin_service.h" | 37 #include "chrome/browser/plugin_service.h" |
32 #include "chrome/browser/renderer_host/render_widget_helper.h" | 38 #include "chrome/browser/renderer_host/render_widget_helper.h" |
33 #include "chrome/browser/renderer_host/renderer_security_policy.h" | 39 #include "chrome/browser/renderer_host/renderer_security_policy.h" |
34 #include "chrome/browser/resource_message_filter.h" | 40 #include "chrome/browser/resource_message_filter.h" |
| 41 #if defined(OS_WIN) |
35 #include "chrome/browser/spellchecker.h" | 42 #include "chrome/browser/spellchecker.h" |
| 43 #else |
| 44 // TODO(port): remove scaffolding, use history.h for both POSIX and WIN. |
| 45 #include "chrome/common/temp_scaffolding_stubs.h" |
| 46 #endif // !defined(OS_WIN) |
36 #include "chrome/browser/visitedlink_master.h" | 47 #include "chrome/browser/visitedlink_master.h" |
37 #include "chrome/common/chrome_paths.h" | 48 #include "chrome/common/chrome_paths.h" |
38 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
39 #include "chrome/common/debug_flags.h" | 50 #include "chrome/common/debug_flags.h" |
40 #include "chrome/common/l10n_util.h" | 51 #include "chrome/common/l10n_util.h" |
41 #include "chrome/common/logging_chrome.h" | 52 #include "chrome/common/logging_chrome.h" |
42 #include "chrome/common/pref_names.h" | 53 #include "chrome/common/pref_names.h" |
43 #include "chrome/common/pref_service.h" | 54 #include "chrome/common/pref_service.h" |
44 #include "chrome/common/process_watcher.h" | 55 #include "chrome/common/process_watcher.h" |
45 #include "chrome/renderer/render_process.h" | 56 #include "chrome/renderer/render_process.h" |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 DCHECK(backgrounded_ == (visible_widgets_ == 0)); | 474 DCHECK(backgrounded_ == (visible_widgets_ == 0)); |
464 visible_widgets_--; | 475 visible_widgets_--; |
465 DCHECK(visible_widgets_ >= 0); | 476 DCHECK(visible_widgets_ >= 0); |
466 if (visible_widgets_ == 0) { | 477 if (visible_widgets_ == 0) { |
467 DCHECK(!backgrounded_); | 478 DCHECK(!backgrounded_); |
468 SetBackgrounded(true); | 479 SetBackgrounded(true); |
469 } | 480 } |
470 } | 481 } |
471 | 482 |
472 void BrowserRenderProcessHost::AddWord(const std::wstring& word) { | 483 void BrowserRenderProcessHost::AddWord(const std::wstring& word) { |
| 484 #if defined(OS_MACOSX) |
| 485 // TODO(port): reimplement when we get the spell checker up and running on |
| 486 // OS X. |
| 487 NOTIMPLEMENTED(); |
| 488 #else |
473 base::Thread* io_thread = g_browser_process->io_thread(); | 489 base::Thread* io_thread = g_browser_process->io_thread(); |
474 if (profile()->GetSpellChecker()) { | 490 if (profile()->GetSpellChecker()) { |
475 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 491 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
476 profile()->GetSpellChecker(), &SpellChecker::AddWord, word)); | 492 profile()->GetSpellChecker(), &SpellChecker::AddWord, word)); |
477 } | 493 } |
| 494 #endif // !defined(OS_MACOSX) |
478 } | 495 } |
479 | 496 |
480 base::ProcessHandle BrowserRenderProcessHost::GetRendererProcessHandle() { | 497 base::ProcessHandle BrowserRenderProcessHost::GetRendererProcessHandle() { |
481 if (run_renderer_in_process()) | 498 if (run_renderer_in_process()) |
482 return base::Process::Current().handle(); | 499 return base::Process::Current().handle(); |
483 return process_.handle(); | 500 return process_.handle(); |
484 } | 501 } |
485 | 502 |
486 void BrowserRenderProcessHost::InitVisitedLinks() { | 503 void BrowserRenderProcessHost::InitVisitedLinks() { |
487 VisitedLinkMaster* visitedlink_master = profile()->GetVisitedLinkMaster(); | 504 VisitedLinkMaster* visitedlink_master = profile()->GetVisitedLinkMaster(); |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 // child processes determine the pid of the parent. | 799 // child processes determine the pid of the parent. |
783 // Build the channel ID. This is composed of a unique identifier for the | 800 // Build the channel ID. This is composed of a unique identifier for the |
784 // parent browser process, an identifier for the renderer/plugin instance, | 801 // parent browser process, an identifier for the renderer/plugin instance, |
785 // and a random component. We use a random component so that a hacked child | 802 // and a random component. We use a random component so that a hacked child |
786 // process can't cause denial of service by causing future named pipe creation | 803 // process can't cause denial of service by causing future named pipe creation |
787 // to fail. | 804 // to fail. |
788 return StringPrintf(L"%d.%x.%d", | 805 return StringPrintf(L"%d.%x.%d", |
789 base::GetCurrentProcId(), instance, | 806 base::GetCurrentProcId(), instance, |
790 base::RandInt(0, std::numeric_limits<int>::max())); | 807 base::RandInt(0, std::numeric_limits<int>::max())); |
791 } | 808 } |
OLD | NEW |