| 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_MACOSX) |
| 42 // TODO(port): Enable when we finish porting spellchecker to os x. |
| 43 #else |
| 35 #include "chrome/browser/spellchecker.h" | 44 #include "chrome/browser/spellchecker.h" |
| 45 #endif // !defined(OS_WIN) |
| 36 #include "chrome/browser/visitedlink_master.h" | 46 #include "chrome/browser/visitedlink_master.h" |
| 37 #include "chrome/common/chrome_paths.h" | 47 #include "chrome/common/chrome_paths.h" |
| 38 #include "chrome/common/chrome_switches.h" | 48 #include "chrome/common/chrome_switches.h" |
| 39 #include "chrome/common/debug_flags.h" | 49 #include "chrome/common/debug_flags.h" |
| 40 #include "chrome/common/l10n_util.h" | 50 #include "chrome/common/l10n_util.h" |
| 41 #include "chrome/common/logging_chrome.h" | 51 #include "chrome/common/logging_chrome.h" |
| 42 #include "chrome/common/pref_names.h" | 52 #include "chrome/common/pref_names.h" |
| 43 #include "chrome/common/pref_service.h" | 53 #include "chrome/common/pref_service.h" |
| 44 #include "chrome/common/process_watcher.h" | 54 #include "chrome/common/process_watcher.h" |
| 45 #include "chrome/renderer/render_process.h" | 55 #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)); | 473 DCHECK(backgrounded_ == (visible_widgets_ == 0)); |
| 464 visible_widgets_--; | 474 visible_widgets_--; |
| 465 DCHECK(visible_widgets_ >= 0); | 475 DCHECK(visible_widgets_ >= 0); |
| 466 if (visible_widgets_ == 0) { | 476 if (visible_widgets_ == 0) { |
| 467 DCHECK(!backgrounded_); | 477 DCHECK(!backgrounded_); |
| 468 SetBackgrounded(true); | 478 SetBackgrounded(true); |
| 469 } | 479 } |
| 470 } | 480 } |
| 471 | 481 |
| 472 void BrowserRenderProcessHost::AddWord(const std::wstring& word) { | 482 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 |
| 473 base::Thread* io_thread = g_browser_process->io_thread(); | 488 base::Thread* io_thread = g_browser_process->io_thread(); |
| 474 if (profile()->GetSpellChecker()) { | 489 if (profile()->GetSpellChecker()) { |
| 475 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 490 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 476 profile()->GetSpellChecker(), &SpellChecker::AddWord, word)); | 491 profile()->GetSpellChecker(), &SpellChecker::AddWord, word)); |
| 477 } | 492 } |
| 493 #endif // !defined(OS_MACOSX) |
| 478 } | 494 } |
| 479 | 495 |
| 480 base::ProcessHandle BrowserRenderProcessHost::GetRendererProcessHandle() { | 496 base::ProcessHandle BrowserRenderProcessHost::GetRendererProcessHandle() { |
| 481 if (run_renderer_in_process()) | 497 if (run_renderer_in_process()) |
| 482 return base::Process::Current().handle(); | 498 return base::Process::Current().handle(); |
| 483 return process_.handle(); | 499 return process_.handle(); |
| 484 } | 500 } |
| 485 | 501 |
| 486 void BrowserRenderProcessHost::InitVisitedLinks() { | 502 void BrowserRenderProcessHost::InitVisitedLinks() { |
| 487 VisitedLinkMaster* visitedlink_master = profile()->GetVisitedLinkMaster(); | 503 VisitedLinkMaster* visitedlink_master = profile()->GetVisitedLinkMaster(); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 // child processes determine the pid of the parent. | 799 // child processes determine the pid of the parent. |
| 784 // 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 |
| 785 // parent browser process, an identifier for the renderer/plugin instance, | 801 // parent browser process, an identifier for the renderer/plugin instance, |
| 786 // 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 |
| 787 // 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 |
| 788 // to fail. | 804 // to fail. |
| 789 return StringPrintf(L"%d.%x.%d", | 805 return StringPrintf(L"%d.%x.%d", |
| 790 base::GetCurrentProcId(), instance, | 806 base::GetCurrentProcId(), instance, |
| 791 base::RandInt(0, std::numeric_limits<int>::max())); | 807 base::RandInt(0, std::numeric_limits<int>::max())); |
| 792 } | 808 } |
| OLD | NEW |