Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: content/browser/web_contents/web_contents_impl.cc

Issue 92873004: Prevent the browser process from creating duplicate RenderViewHosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/test/test_web_contents.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" 5 #include "content/browser/web_contents/web_contents_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/metrics/stats_counters.h" 14 #include "base/metrics/stats_counters.h"
15 #include "base/process/process.h"
15 #include "base/strings/string16.h" 16 #include "base/strings/string16.h"
16 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 19 #include "base/strings/utf_string_conversions.h"
19 #include "base/time/time.h" 20 #include "base/time/time.h"
20 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 21 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
21 #include "content/browser/browser_plugin/browser_plugin_guest.h" 22 #include "content/browser/browser_plugin/browser_plugin_guest.h"
22 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h" 23 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h"
23 #include "content/browser/child_process_security_policy_impl.h" 24 #include "content/browser/child_process_security_policy_impl.h"
24 #include "content/browser/devtools/devtools_manager_impl.h" 25 #include "content/browser/devtools/devtools_manager_impl.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "content/public/browser/resource_request_details.h" 67 #include "content/public/browser/resource_request_details.h"
67 #include "content/public/browser/storage_partition.h" 68 #include "content/public/browser/storage_partition.h"
68 #include "content/public/browser/user_metrics.h" 69 #include "content/public/browser/user_metrics.h"
69 #include "content/public/browser/web_contents_delegate.h" 70 #include "content/public/browser/web_contents_delegate.h"
70 #include "content/public/browser/web_contents_observer.h" 71 #include "content/public/browser/web_contents_observer.h"
71 #include "content/public/browser/web_contents_view.h" 72 #include "content/public/browser/web_contents_view.h"
72 #include "content/public/common/bindings_policy.h" 73 #include "content/public/common/bindings_policy.h"
73 #include "content/public/common/content_constants.h" 74 #include "content/public/common/content_constants.h"
74 #include "content/public/common/content_switches.h" 75 #include "content/public/common/content_switches.h"
75 #include "content/public/common/page_zoom.h" 76 #include "content/public/common/page_zoom.h"
77 #include "content/public/common/result_codes.h"
76 #include "content/public/common/url_constants.h" 78 #include "content/public/common/url_constants.h"
77 #include "net/base/mime_util.h" 79 #include "net/base/mime_util.h"
78 #include "net/base/net_util.h" 80 #include "net/base/net_util.h"
79 #include "net/http/http_cache.h" 81 #include "net/http/http_cache.h"
80 #include "net/http/http_transaction_factory.h" 82 #include "net/http/http_transaction_factory.h"
81 #include "net/url_request/url_request_context.h" 83 #include "net/url_request/url_request_context.h"
82 #include "net/url_request/url_request_context_getter.h" 84 #include "net/url_request/url_request_context_getter.h"
83 #include "ui/base/layout.h" 85 #include "ui/base/layout.h"
84 #include "ui/gfx/display.h" 86 #include "ui/gfx/display.h"
85 #include "ui/gfx/screen.h" 87 #include "ui/gfx/screen.h"
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1245 GotResponseToLockMouseRequest(false); 1247 GotResponseToLockMouseRequest(false);
1246 } 1248 }
1247 } 1249 }
1248 1250
1249 void WebContentsImpl::LostMouseLock() { 1251 void WebContentsImpl::LostMouseLock() {
1250 if (delegate_) 1252 if (delegate_)
1251 delegate_->LostMouseLock(); 1253 delegate_->LostMouseLock();
1252 } 1254 }
1253 1255
1254 void WebContentsImpl::CreateNewWindow( 1256 void WebContentsImpl::CreateNewWindow(
1257 int render_process_id,
1255 int route_id, 1258 int route_id,
1256 int main_frame_route_id, 1259 int main_frame_route_id,
1257 const ViewHostMsg_CreateWindow_Params& params, 1260 const ViewHostMsg_CreateWindow_Params& params,
1258 SessionStorageNamespace* session_storage_namespace) { 1261 SessionStorageNamespace* session_storage_namespace) {
1259 // We usually create the new window in the same BrowsingInstance (group of 1262 // We usually create the new window in the same BrowsingInstance (group of
1260 // script-related windows), by passing in the current SiteInstance. However, 1263 // script-related windows), by passing in the current SiteInstance. However,
1261 // if the opener is being suppressed (in a non-guest), we create a new 1264 // if the opener is being suppressed (in a non-guest), we create a new
1262 // SiteInstance in its own BrowsingInstance. 1265 // SiteInstance in its own BrowsingInstance.
1263 bool is_guest = GetRenderProcessHost()->IsGuest(); 1266 bool is_guest = GetRenderProcessHost()->IsGuest();
1264 1267
1268 // If the opener is to be suppressed, the new window can be in any process.
1269 // Since routing ids are process specific, we must not have one passed in
1270 // as argument here.
1271 DCHECK(!params.opener_suppressed || route_id == MSG_ROUTING_NONE);
1272
1265 scoped_refptr<SiteInstance> site_instance = 1273 scoped_refptr<SiteInstance> site_instance =
1266 params.opener_suppressed && !is_guest ? 1274 params.opener_suppressed && !is_guest ?
1267 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) : 1275 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) :
1268 GetSiteInstance(); 1276 GetSiteInstance();
1269 1277
1278 // A message to create a new window can only come from the active process for
1279 // this WebContentsImpl instance. If any other process sends the request,
1280 // it is invalid and the process must be terminated.
1281 if (GetRenderProcessHost()->GetID() != render_process_id) {
1282 base::ProcessHandle process_handle =
1283 RenderProcessHost::FromID(render_process_id)->GetHandle();
1284 if (process_handle != base::kNullProcessHandle) {
1285 RecordAction(
1286 UserMetricsAction("Terminate_ProcessMismatch_CreateNewWindow"));
1287 base::KillProcess(process_handle, content::RESULT_CODE_KILLED, false);
1288 }
1289 return;
1290 }
1291
1270 // We must assign the SessionStorageNamespace before calling Init(). 1292 // We must assign the SessionStorageNamespace before calling Init().
1271 // 1293 //
1272 // http://crbug.com/142685 1294 // http://crbug.com/142685
1273 const std::string& partition_id = 1295 const std::string& partition_id =
1274 GetContentClient()->browser()-> 1296 GetContentClient()->browser()->
1275 GetStoragePartitionIdForSite(GetBrowserContext(), 1297 GetStoragePartitionIdForSite(GetBrowserContext(),
1276 site_instance->GetSiteURL()); 1298 site_instance->GetSiteURL());
1277 StoragePartition* partition = BrowserContext::GetStoragePartition( 1299 StoragePartition* partition = BrowserContext::GetStoragePartition(
1278 GetBrowserContext(), site_instance.get()); 1300 GetBrowserContext(), site_instance.get());
1279 DOMStorageContextWrapper* dom_storage_context = 1301 DOMStorageContextWrapper* dom_storage_context =
(...skipping 2420 matching lines...) Expand 10 before | Expand all | Expand 10 after
3700 } 3722 }
3701 3723
3702 void WebContentsImpl::OnFrameRemoved( 3724 void WebContentsImpl::OnFrameRemoved(
3703 RenderViewHostImpl* render_view_host, 3725 RenderViewHostImpl* render_view_host,
3704 int64 frame_id) { 3726 int64 frame_id) {
3705 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3727 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3706 FrameDetached(render_view_host, frame_id)); 3728 FrameDetached(render_view_host, frame_id));
3707 } 3729 }
3708 3730
3709 } // namespace content 3731 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.h ('k') | content/test/test_web_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698