OLD | NEW |
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/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 #endif | 269 #endif |
270 is_showing_before_unload_dialog_(false), | 270 is_showing_before_unload_dialog_(false), |
271 opener_web_ui_type_(WebUI::kNoWebUI), | 271 opener_web_ui_type_(WebUI::kNoWebUI), |
272 closed_by_user_gesture_(false), | 272 closed_by_user_gesture_(false), |
273 minimum_zoom_percent_( | 273 minimum_zoom_percent_( |
274 static_cast<int>(content::kMinimumZoomFactor * 100)), | 274 static_cast<int>(content::kMinimumZoomFactor * 100)), |
275 maximum_zoom_percent_( | 275 maximum_zoom_percent_( |
276 static_cast<int>(content::kMaximumZoomFactor * 100)), | 276 static_cast<int>(content::kMaximumZoomFactor * 100)), |
277 temporary_zoom_settings_(false), | 277 temporary_zoom_settings_(false), |
278 content_restrictions_(0), | 278 content_restrictions_(0), |
279 view_type_(content::VIEW_TYPE_TAB_CONTENTS), | 279 view_type_(content::VIEW_TYPE_WEB_CONTENTS), |
280 has_opener_(false), | 280 has_opener_(false), |
281 color_chooser_(NULL) { | 281 color_chooser_(NULL) { |
282 render_manager_.Init(browser_context, site_instance, routing_id); | 282 render_manager_.Init(browser_context, site_instance, routing_id); |
283 | 283 |
284 view_.reset(content::GetContentClient()->browser()-> | 284 view_.reset(content::GetContentClient()->browser()-> |
285 OverrideCreateWebContentsView(this)); | 285 OverrideCreateWebContentsView(this)); |
286 if (!view_.get()) { | 286 if (!view_.get()) { |
287 content::WebContentsViewDelegate* delegate = | 287 content::WebContentsViewDelegate* delegate = |
288 content::GetContentClient()->browser()->GetWebContentsViewDelegate( | 288 content::GetContentClient()->browser()->GetWebContentsViewDelegate( |
289 this); | 289 this); |
290 #if defined(USE_AURA) | 290 #if defined(USE_AURA) |
291 view_.reset(new WebContentsViewAura(this, delegate)); | 291 view_.reset(new WebContentsViewAura(this, delegate)); |
292 #elif defined(OS_WIN) | 292 #elif defined(OS_WIN) |
293 view_.reset(new WebContentsViewWin(this, delegate)); | 293 view_.reset(new WebContentsViewWin(this, delegate)); |
294 #elif defined(TOOLKIT_GTK) | 294 #elif defined(TOOLKIT_GTK) |
295 view_.reset(new content::WebContentsViewGtk(this, delegate)); | 295 view_.reset(new content::WebContentsViewGtk(this, delegate)); |
296 #elif defined(OS_MACOSX) | 296 #elif defined(OS_MACOSX) |
297 view_.reset(web_contents_view_mac::CreateWebContentsView(this, delegate)); | 297 view_.reset(web_contents_view_mac::CreateWebContentsView(this, delegate)); |
298 #elif defined(OS_ANDROID) | 298 #elif defined(OS_ANDROID) |
299 view_.reset(new WebContentsViewAndroid(this)); | 299 view_.reset(new WebContentsViewAndroid(this)); |
300 #endif | 300 #endif |
301 (void)delegate; | 301 (void)delegate; |
302 } | 302 } |
303 CHECK(view_.get()); | 303 CHECK(view_.get()); |
304 | 304 |
305 // We have the initial size of the view be based on the size of the passed in | 305 // We have the initial size of the view be based on the size of the view of |
306 // tab contents (normally a tab from the same window). | 306 // the passed in WebContents. |
307 view_->CreateView(base_web_contents ? | 307 view_->CreateView(base_web_contents ? |
308 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); | 308 base_web_contents->GetView()->GetContainerSize() : gfx::Size()); |
309 | 309 |
310 #if defined(ENABLE_JAVA_BRIDGE) | 310 #if defined(ENABLE_JAVA_BRIDGE) |
311 java_bridge_dispatcher_host_manager_.reset( | 311 java_bridge_dispatcher_host_manager_.reset( |
312 new JavaBridgeDispatcherHostManager(this)); | 312 new JavaBridgeDispatcherHostManager(this)); |
313 #endif | 313 #endif |
314 | 314 |
315 browser_plugin_web_contents_observer_.reset( | 315 browser_plugin_web_contents_observer_.reset( |
316 new content::BrowserPluginWebContentsObserver(this)); | 316 new content::BrowserPluginWebContentsObserver(this)); |
317 } | 317 } |
318 | 318 |
319 WebContentsImpl::~WebContentsImpl() { | 319 WebContentsImpl::~WebContentsImpl() { |
320 is_being_destroyed_ = true; | 320 is_being_destroyed_ = true; |
321 | 321 |
322 // Clear out any JavaScript state. | 322 // Clear out any JavaScript state. |
323 if (dialog_creator_) | 323 if (dialog_creator_) |
324 dialog_creator_->ResetJavaScriptState(this); | 324 dialog_creator_->ResetJavaScriptState(this); |
325 | 325 |
326 if (color_chooser_) | 326 if (color_chooser_) |
327 color_chooser_->End(); | 327 color_chooser_->End(); |
328 | 328 |
329 NotifyDisconnected(); | 329 NotifyDisconnected(); |
330 | 330 |
331 // Notify any observer that have a reference on this tab contents. | 331 // Notify any observer that have a reference on this WebContents. |
332 content::NotificationService::current()->Notify( | 332 content::NotificationService::current()->Notify( |
333 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 333 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
334 content::Source<WebContents>(this), | 334 content::Source<WebContents>(this), |
335 content::NotificationService::NoDetails()); | 335 content::NotificationService::NoDetails()); |
336 | 336 |
337 // TODO(brettw) this should be moved to the view. | 337 // TODO(brettw) this should be moved to the view. |
338 #if defined(OS_WIN) && !defined(USE_AURA) | 338 #if defined(OS_WIN) && !defined(USE_AURA) |
339 // If we still have a window handle, destroy it. GetNativeView can return | 339 // If we still have a window handle, destroy it. GetNativeView can return |
340 // NULL if this contents was part of a window that closed. | 340 // NULL if this contents was part of a window that closed. |
341 if (GetNativeView()) { | 341 if (GetNativeView()) { |
(...skipping 2281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2623 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { | 2623 void WebContentsImpl::CreateViewAndSetSizeForRVH(RenderViewHost* rvh) { |
2624 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); | 2624 RenderWidgetHostView* rwh_view = GetView()->CreateViewForWidget(rvh); |
2625 // Can be NULL during tests. | 2625 // Can be NULL during tests. |
2626 if (rwh_view) | 2626 if (rwh_view) |
2627 rwh_view->SetSize(GetView()->GetContainerSize()); | 2627 rwh_view->SetSize(GetView()->GetContainerSize()); |
2628 } | 2628 } |
2629 | 2629 |
2630 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { | 2630 RenderViewHostImpl* WebContentsImpl::GetRenderViewHostImpl() { |
2631 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); | 2631 return static_cast<RenderViewHostImpl*>(GetRenderViewHost()); |
2632 } | 2632 } |
OLD | NEW |