| 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 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" |
| 15 #include "base/linked_ptr.h" | 16 #include "base/linked_ptr.h" |
| 16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 17 #include "base/path_service.h" | 18 #include "base/path_service.h" |
| 18 #include "base/process_util.h" | 19 #include "base/process_util.h" |
| 19 #include "base/rand_util.h" | 20 #include "base/rand_util.h" |
| 20 #include "base/scoped_ptr.h" | 21 #include "base/scoped_ptr.h" |
| 21 #include "base/shared_memory.h" | 22 #include "base/shared_memory.h" |
| 22 #include "base/singleton.h" | 23 #include "base/singleton.h" |
| 23 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 24 #include "base/thread.h" | 25 #include "base/thread.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Deleted in CleanUp() on the renderer thread, so don't use a smart pointer. | 110 // Deleted in CleanUp() on the renderer thread, so don't use a smart pointer. |
| 110 RenderProcess* render_process_; | 111 RenderProcess* render_process_; |
| 111 }; | 112 }; |
| 112 | 113 |
| 113 // Used for a View_ID where the renderer has not been attached yet | 114 // Used for a View_ID where the renderer has not been attached yet |
| 114 const int32 kInvalidViewID = -1; | 115 const int32 kInvalidViewID = -1; |
| 115 | 116 |
| 116 // Get the path to the renderer executable, which is the same as the | 117 // Get the path to the renderer executable, which is the same as the |
| 117 // current executable. | 118 // current executable. |
| 118 bool GetRendererPath(std::wstring* cmd_line) { | 119 bool GetRendererPath(std::wstring* cmd_line) { |
| 120 #if defined(OS_LINUX) |
| 121 // Ubuntu has AppArmor, which triggers based on binary names. Since we only |
| 122 // want to sandbox the renderers they need to have a different name than the |
| 123 // main Chromium binary (although it can just be a hard link to the same |
| 124 // file). Thus, we probe to see if "<argv0>-renderer" exists. If so, we run |
| 125 // that. |
| 126 |
| 127 if (!PathService::Get(base::FILE_EXE, cmd_line)) |
| 128 return false; |
| 129 std::wstring alt_path = *cmd_line; |
| 130 alt_path.append(L"-renderer"); |
| 131 if (file_util::PathExists(alt_path)) |
| 132 *cmd_line = alt_path; |
| 133 return true; |
| 134 #else |
| 119 return PathService::Get(base::FILE_EXE, cmd_line); | 135 return PathService::Get(base::FILE_EXE, cmd_line); |
| 136 #endif |
| 120 } | 137 } |
| 121 | 138 |
| 122 BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) | 139 BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile) |
| 123 : RenderProcessHost(profile), | 140 : RenderProcessHost(profile), |
| 124 visible_widgets_(0), | 141 visible_widgets_(0), |
| 125 backgrounded_(true), | 142 backgrounded_(true), |
| 126 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( | 143 ALLOW_THIS_IN_INITIALIZER_LIST(cached_dibs_cleaner_( |
| 127 base::TimeDelta::FromSeconds(5), | 144 base::TimeDelta::FromSeconds(5), |
| 128 this, &BrowserRenderProcessHost::ClearTransportDIBCache)) { | 145 this, &BrowserRenderProcessHost::ClearTransportDIBCache)) { |
| 129 widget_helper_ = new RenderWidgetHelper(); | 146 widget_helper_ = new RenderWidgetHelper(); |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 SendUserScriptsUpdate(shared_memory); | 787 SendUserScriptsUpdate(shared_memory); |
| 771 } | 788 } |
| 772 break; | 789 break; |
| 773 } | 790 } |
| 774 default: { | 791 default: { |
| 775 NOTREACHED(); | 792 NOTREACHED(); |
| 776 break; | 793 break; |
| 777 } | 794 } |
| 778 } | 795 } |
| 779 } | 796 } |
| OLD | NEW |