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

Side by Side Diff: content/browser/tab_contents/tab_contents.cc

Issue 8760024: Cross-process postMessage (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Current checkpoint Created 8 years, 12 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/tab_contents/tab_contents.h" 5 #include "content/browser/tab_contents/tab_contents.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/metrics/stats_counters.h" 11 #include "base/metrics/stats_counters.h"
12 #include "base/string16.h" 12 #include "base/string16.h"
13 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/time.h" 14 #include "base/time.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "content/browser/child_process_security_policy.h" 16 #include "content/browser/child_process_security_policy.h"
17 #include "content/browser/content_frame.h"
17 #include "content/browser/debugger/devtools_manager_impl.h" 18 #include "content/browser/debugger/devtools_manager_impl.h"
18 #include "content/browser/download/download_manager.h" 19 #include "content/browser/download/download_manager.h"
19 #include "content/browser/download/download_stats.h" 20 #include "content/browser/download/download_stats.h"
21 #include "content/browser/frame_map.h"
20 #include "content/browser/host_zoom_map.h" 22 #include "content/browser/host_zoom_map.h"
21 #include "content/browser/in_process_webkit/session_storage_namespace.h" 23 #include "content/browser/in_process_webkit/session_storage_namespace.h"
22 #include "content/browser/intents/intents_host_impl.h" 24 #include "content/browser/intents/intents_host_impl.h"
23 #include "content/browser/load_from_memory_cache_details.h" 25 #include "content/browser/load_from_memory_cache_details.h"
24 #include "content/browser/load_notification_details.h" 26 #include "content/browser/load_notification_details.h"
25 #include "content/browser/renderer_host/render_process_host_impl.h" 27 #include "content/browser/renderer_host/render_process_host_impl.h"
26 #include "content/browser/renderer_host/render_view_host.h" 28 #include "content/browser/renderer_host/render_view_host.h"
27 #include "content/browser/renderer_host/render_widget_host_view.h" 29 #include "content/browser/renderer_host/render_widget_host_view.h"
28 #include "content/browser/renderer_host/resource_dispatcher_host.h" 30 #include "content/browser/renderer_host/resource_dispatcher_host.h"
29 #include "content/browser/renderer_host/resource_request_details.h" 31 #include "content/browser/renderer_host/resource_request_details.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 } 179 }
178 180
179 } // namespace 181 } // namespace
180 182
181 183
182 // TabContents ---------------------------------------------------------------- 184 // TabContents ----------------------------------------------------------------
183 185
184 TabContents::TabContents(content::BrowserContext* browser_context, 186 TabContents::TabContents(content::BrowserContext* browser_context,
185 SiteInstance* site_instance, 187 SiteInstance* site_instance,
186 int routing_id, 188 int routing_id,
187 const TabContents* base_tab_contents, 189 content::ContentFrame* opener,
188 SessionStorageNamespace* session_storage_namespace) 190 SessionStorageNamespace* session_storage_namespace)
189 : delegate_(NULL), 191 : delegate_(NULL),
190 ALLOW_THIS_IN_INITIALIZER_LIST(controller_( 192 ALLOW_THIS_IN_INITIALIZER_LIST(controller_(
191 this, browser_context, session_storage_namespace)), 193 this, browser_context, session_storage_namespace)),
192 ALLOW_THIS_IN_INITIALIZER_LIST(view_( 194 ALLOW_THIS_IN_INITIALIZER_LIST(view_(
193 content::GetContentClient()->browser()->CreateTabContentsView(this))), 195 content::GetContentClient()->browser()->CreateTabContentsView(this))),
194 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this)), 196 ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this)),
195 is_loading_(false), 197 is_loading_(false),
196 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING), 198 crashed_status_(base::TERMINATION_STATUS_STILL_RUNNING),
197 crashed_error_code_(0), 199 crashed_error_code_(0),
(...skipping 11 matching lines...) Expand all
209 #endif 211 #endif
210 is_showing_before_unload_dialog_(false), 212 is_showing_before_unload_dialog_(false),
211 opener_web_ui_type_(WebUI::kNoWebUI), 213 opener_web_ui_type_(WebUI::kNoWebUI),
212 closed_by_user_gesture_(false), 214 closed_by_user_gesture_(false),
213 minimum_zoom_percent_( 215 minimum_zoom_percent_(
214 static_cast<int>(content::kMinimumZoomFactor * 100)), 216 static_cast<int>(content::kMinimumZoomFactor * 100)),
215 maximum_zoom_percent_( 217 maximum_zoom_percent_(
216 static_cast<int>(content::kMaximumZoomFactor * 100)), 218 static_cast<int>(content::kMaximumZoomFactor * 100)),
217 temporary_zoom_settings_(false), 219 temporary_zoom_settings_(false),
218 content_restrictions_(0), 220 content_restrictions_(0),
219 view_type_(content::VIEW_TYPE_TAB_CONTENTS) { 221 view_type_(content::VIEW_TYPE_TAB_CONTENTS),
222 content_frame_(
223 browser_context->frame_mapper()->InitializeFrame(
224 true, *this, opener)) {
220 render_manager_.Init(browser_context, site_instance, routing_id); 225 render_manager_.Init(browser_context, site_instance, routing_id);
221 226
227 // TODO(supersat): This is a hack and should be removed.
228 browser_context->frame_mapper()->UpdateFrame(
229 content_frame_, render_view_host()->process()->GetID(),
230 render_view_host()->routing_id(),
231 -1 /* We don't know the frame id yet */);
232
222 // We have the initial size of the view be based on the size of the passed in 233 // We have the initial size of the view be based on the size of the passed in
223 // tab contents (normally a tab from the same window). 234 // tab contents (normally a tab from the same window).
224 view_->CreateView(base_tab_contents ? 235 view_->CreateView(opener ?
225 base_tab_contents->view()->GetContainerSize() : gfx::Size()); 236 opener->tab_contents().view()->GetContainerSize() : gfx::Size());
226 237
227 #if defined(ENABLE_JAVA_BRIDGE) 238 #if defined(ENABLE_JAVA_BRIDGE)
228 java_bridge_dispatcher_host_manager_.reset( 239 java_bridge_dispatcher_host_manager_.reset(
229 new JavaBridgeDispatcherHostManager(this)); 240 new JavaBridgeDispatcherHostManager(this));
230 #endif 241 #endif
231 } 242 }
232 243
233 TabContents::~TabContents() { 244 TabContents::~TabContents() {
234 is_being_destroyed_ = true; 245 is_being_destroyed_ = true;
235 246
(...skipping 19 matching lines...) Expand all
255 host->view()->WillWmDestroy(); 266 host->view()->WillWmDestroy();
256 } 267 }
257 #endif 268 #endif
258 269
259 // OnCloseStarted isn't called in unit tests. 270 // OnCloseStarted isn't called in unit tests.
260 if (!tab_close_start_time_.is_null()) { 271 if (!tab_close_start_time_.is_null()) {
261 UMA_HISTOGRAM_TIMES("Tab.Close", 272 UMA_HISTOGRAM_TIMES("Tab.Close",
262 base::TimeTicks::Now() - tab_close_start_time_); 273 base::TimeTicks::Now() - tab_close_start_time_);
263 } 274 }
264 275
276 // Remove the top-level frame from the frame mapper
277 browser_context()->frame_mapper()->RemoveFrame(content_frame_);
278 delete content_frame_;
279
265 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed()); 280 FOR_EACH_OBSERVER(TabContentsObserver, observers_, TabContentsDestroyed());
266 281
267 set_delegate(NULL); 282 set_delegate(NULL);
268 } 283 }
269 284
270 // TODO(cbentzel): Either remove the debugging code, or rename to SetDelegate. 285 // TODO(cbentzel): Either remove the debugging code, or rename to SetDelegate.
271 void TabContents::set_delegate(TabContentsDelegate* delegate) { 286 void TabContents::set_delegate(TabContentsDelegate* delegate) {
272 if (delegate == delegate_) 287 if (delegate == delegate_)
273 return; 288 return;
274 if (delegate_) 289 if (delegate_)
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 FOR_EACH_OBSERVER(TabContentsObserver, observers_, StopNavigation()); 706 FOR_EACH_OBSERVER(TabContentsObserver, observers_, StopNavigation());
692 } 707 }
693 708
694 TabContents* TabContents::Clone() { 709 TabContents* TabContents::Clone() {
695 // We create a new SiteInstance so that the new tab won't share processes 710 // We create a new SiteInstance so that the new tab won't share processes
696 // with the old one. This can be changed in the future if we need it to share 711 // with the old one. This can be changed in the future if we need it to share
697 // processes for some reason. 712 // processes for some reason.
698 TabContents* tc = new TabContents( 713 TabContents* tc = new TabContents(
699 browser_context(), 714 browser_context(),
700 SiteInstance::CreateSiteInstance(browser_context()), 715 SiteInstance::CreateSiteInstance(browser_context()),
701 MSG_ROUTING_NONE, this, NULL); 716 MSG_ROUTING_NONE, content_frame_, NULL);
702 tc->controller().CopyStateFrom(controller_); 717 tc->controller().CopyStateFrom(controller_);
703 return tc; 718 return tc;
704 } 719 }
705 720
706 void TabContents::ShowPageInfo(const GURL& url, 721 void TabContents::ShowPageInfo(const GURL& url,
707 const NavigationEntry::SSLStatus& ssl, 722 const NavigationEntry::SSLStatus& ssl,
708 bool show_history) { 723 bool show_history) {
709 if (!delegate_) 724 if (!delegate_)
710 return; 725 return;
711 726
(...skipping 1281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) { 2008 WebUI* TabContents::CreateWebUIForRenderManager(const GURL& url) {
1994 return content::WebUIFactory::Get()->CreateWebUIForURL(this, url); 2009 return content::WebUIFactory::Get()->CreateWebUIForURL(this, url);
1995 } 2010 }
1996 2011
1997 NavigationEntry* 2012 NavigationEntry*
1998 TabContents::GetLastCommittedNavigationEntryForRenderManager() { 2013 TabContents::GetLastCommittedNavigationEntryForRenderManager() {
1999 return controller_.GetLastCommittedEntry(); 2014 return controller_.GetLastCommittedEntry();
2000 } 2015 }
2001 2016
2002 bool TabContents::CreateRenderViewForRenderManager( 2017 bool TabContents::CreateRenderViewForRenderManager(
2003 RenderViewHost* render_view_host) { 2018 RenderViewHost* render_view_host, int opener_route_id) {
2004 // Can be NULL during tests. 2019 // Can be NULL during tests.
2005 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host); 2020 RenderWidgetHostView* rwh_view = view_->CreateViewForWidget(render_view_host);
2006 2021
2007 // Now that the RenderView has been created, we need to tell it its size. 2022 // Now that the RenderView has been created, we need to tell it its size.
2008 if (rwh_view) 2023 if (rwh_view)
2009 rwh_view->SetSize(view_->GetContainerSize()); 2024 rwh_view->SetSize(view_->GetContainerSize());
2010 2025
2011 // Make sure we use the correct starting page_id in the new RenderView. 2026 // Make sure we use the correct starting page_id in the new RenderView.
2012 UpdateMaxPageIDIfNecessary(render_view_host); 2027 UpdateMaxPageIDIfNecessary(render_view_host);
2013 int32 max_page_id = 2028 int32 max_page_id =
2014 GetMaxPageIDForSiteInstance(render_view_host->site_instance()); 2029 GetMaxPageIDForSiteInstance(render_view_host->site_instance());
2015 2030
2016 if (!render_view_host->CreateRenderView(string16(), max_page_id)) 2031 if (!render_view_host->CreateRenderView(string16(), opener_route_id,
2032 max_page_id))
2017 return false; 2033 return false;
2018 2034
2019 #if defined(OS_LINUX) || defined(OS_OPENBSD) 2035 #if defined(OS_LINUX) || defined(OS_OPENBSD)
2020 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on 2036 // Force a ViewMsg_Resize to be sent, needed to make plugins show up on
2021 // linux. See crbug.com/83941. 2037 // linux. See crbug.com/83941.
2022 if (rwh_view) { 2038 if (rwh_view) {
2023 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) 2039 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost())
2024 render_widget_host->WasResized(); 2040 render_widget_host->WasResized();
2025 } 2041 }
2026 #endif 2042 #endif
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh); 2077 RenderWidgetHostView* rwh_view = view()->CreateViewForWidget(rvh);
2062 // Can be NULL during tests. 2078 // Can be NULL during tests.
2063 if (rwh_view) 2079 if (rwh_view)
2064 rwh_view->SetSize(view()->GetContainerSize()); 2080 rwh_view->SetSize(view()->GetContainerSize());
2065 } 2081 }
2066 2082
2067 bool TabContents::GotResponseToLockMouseRequest(bool allowed) { 2083 bool TabContents::GotResponseToLockMouseRequest(bool allowed) {
2068 return render_view_host() ? 2084 return render_view_host() ?
2069 render_view_host()->GotResponseToLockMouseRequest(allowed) : false; 2085 render_view_host()->GotResponseToLockMouseRequest(allowed) : false;
2070 } 2086 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.h ('k') | content/browser/tab_contents/test_tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698