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

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: Fixes based on Charlie's review. 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
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,
Charlie Reis 2013/12/02 22:25:34 I had trouble following how route_id could be used
nasko 2013/12/02 22:51:08 Done.
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
1265 scoped_refptr<SiteInstance> site_instance = 1268 scoped_refptr<SiteInstance> site_instance =
1266 params.opener_suppressed && !is_guest ? 1269 params.opener_suppressed && !is_guest ?
1267 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) : 1270 SiteInstance::CreateForURL(GetBrowserContext(), params.target_url) :
1268 GetSiteInstance(); 1271 GetSiteInstance();
1269 1272
1273 // A message to create a new window can only come from the active process for
1274 // this WebContentsImpl instance. If any other process sends the request,
1275 // it is invalid and the process must be terminated.
1276 if (GetRenderProcessHost() &&
Charlie Reis 2013/12/02 22:25:34 nit: No need to check for null here. This should
nasko 2013/12/02 22:51:08 Done.
1277 GetRenderProcessHost()->GetID() != render_process_id) {
1278 base::ProcessHandle process_handle =
1279 RenderProcessHost::FromID(render_process_id)->GetHandle();
1280 if (process_handle != base::kNullProcessHandle) {
1281 RecordAction(
1282 UserMetricsAction("Terminate_ProcessMismatch_CreateNewWindow"));
1283 base::KillProcess(process_handle, content::RESULT_CODE_KILLED, false);
1284 }
1285 return;
1286 }
1287
1270 // We must assign the SessionStorageNamespace before calling Init(). 1288 // We must assign the SessionStorageNamespace before calling Init().
1271 // 1289 //
1272 // http://crbug.com/142685 1290 // http://crbug.com/142685
1273 const std::string& partition_id = 1291 const std::string& partition_id =
1274 GetContentClient()->browser()-> 1292 GetContentClient()->browser()->
1275 GetStoragePartitionIdForSite(GetBrowserContext(), 1293 GetStoragePartitionIdForSite(GetBrowserContext(),
1276 site_instance->GetSiteURL()); 1294 site_instance->GetSiteURL());
1277 StoragePartition* partition = BrowserContext::GetStoragePartition( 1295 StoragePartition* partition = BrowserContext::GetStoragePartition(
1278 GetBrowserContext(), site_instance.get()); 1296 GetBrowserContext(), site_instance.get());
1279 DOMStorageContextWrapper* dom_storage_context = 1297 DOMStorageContextWrapper* dom_storage_context =
(...skipping 2420 matching lines...) Expand 10 before | Expand all | Expand 10 after
3700 } 3718 }
3701 3719
3702 void WebContentsImpl::OnFrameRemoved( 3720 void WebContentsImpl::OnFrameRemoved(
3703 RenderViewHostImpl* render_view_host, 3721 RenderViewHostImpl* render_view_host,
3704 int64 frame_id) { 3722 int64 frame_id) {
3705 FOR_EACH_OBSERVER(WebContentsObserver, observers_, 3723 FOR_EACH_OBSERVER(WebContentsObserver, observers_,
3706 FrameDetached(render_view_host, frame_id)); 3724 FrameDetached(render_view_host, frame_id));
3707 } 3725 }
3708 3726
3709 } // namespace content 3727 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698