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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 maximum_zoom_percent_( | 355 maximum_zoom_percent_( |
356 static_cast<int>(content::kMaximumZoomFactor * 100)), | 356 static_cast<int>(content::kMaximumZoomFactor * 100)), |
357 temporary_zoom_settings_(false), | 357 temporary_zoom_settings_(false), |
358 content_restrictions_(0), | 358 content_restrictions_(0), |
359 color_chooser_(NULL) { | 359 color_chooser_(NULL) { |
360 } | 360 } |
361 | 361 |
362 WebContentsImpl::~WebContentsImpl() { | 362 WebContentsImpl::~WebContentsImpl() { |
363 is_being_destroyed_ = true; | 363 is_being_destroyed_ = true; |
364 | 364 |
| 365 for (std::set<RenderWidgetHostImpl*>::iterator iter = |
| 366 created_widgets_.begin(); iter != created_widgets_.end(); ++iter) { |
| 367 (*iter)->DetachDelegate(); |
| 368 } |
| 369 created_widgets_.clear(); |
| 370 |
365 // Clear out any JavaScript state. | 371 // Clear out any JavaScript state. |
366 if (dialog_creator_) | 372 if (dialog_creator_) |
367 dialog_creator_->ResetJavaScriptState(this); | 373 dialog_creator_->ResetJavaScriptState(this); |
368 | 374 |
369 if (color_chooser_) | 375 if (color_chooser_) |
370 color_chooser_->End(); | 376 color_chooser_->End(); |
371 | 377 |
372 NotifyDisconnected(); | 378 NotifyDisconnected(); |
373 | 379 |
374 // Notify any observer that have a reference on this WebContents. | 380 // Notify any observer that have a reference on this WebContents. |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1154 void WebContentsImpl::Deactivate() { | 1160 void WebContentsImpl::Deactivate() { |
1155 if (delegate_) | 1161 if (delegate_) |
1156 delegate_->DeactivateContents(this); | 1162 delegate_->DeactivateContents(this); |
1157 } | 1163 } |
1158 | 1164 |
1159 void WebContentsImpl::LostCapture() { | 1165 void WebContentsImpl::LostCapture() { |
1160 if (delegate_) | 1166 if (delegate_) |
1161 delegate_->LostCapture(); | 1167 delegate_->LostCapture(); |
1162 } | 1168 } |
1163 | 1169 |
| 1170 void WebContentsImpl::RenderWidgetDeleted( |
| 1171 RenderWidgetHostImpl* render_widget_host) { |
| 1172 if (is_being_destroyed_) { |
| 1173 // |created_widgets_| might have been destroyed. |
| 1174 return; |
| 1175 } |
| 1176 |
| 1177 std::set<RenderWidgetHostImpl*>::iterator iter = |
| 1178 created_widgets_.find(render_widget_host); |
| 1179 if (iter != created_widgets_.end()) |
| 1180 created_widgets_.erase(iter); |
| 1181 } |
| 1182 |
1164 bool WebContentsImpl::PreHandleKeyboardEvent( | 1183 bool WebContentsImpl::PreHandleKeyboardEvent( |
1165 const NativeWebKeyboardEvent& event, | 1184 const NativeWebKeyboardEvent& event, |
1166 bool* is_keyboard_shortcut) { | 1185 bool* is_keyboard_shortcut) { |
1167 return delegate_ && | 1186 return delegate_ && |
1168 delegate_->PreHandleKeyboardEvent(this, event, is_keyboard_shortcut); | 1187 delegate_->PreHandleKeyboardEvent(this, event, is_keyboard_shortcut); |
1169 } | 1188 } |
1170 | 1189 |
1171 void WebContentsImpl::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 1190 void WebContentsImpl::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
1172 if (delegate_) | 1191 if (delegate_) |
1173 delegate_->HandleKeyboardEvent(this, event); | 1192 delegate_->HandleKeyboardEvent(this, event); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1316 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { | 1335 void WebContentsImpl::CreateNewFullscreenWidget(int route_id) { |
1317 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); | 1336 CreateNewWidget(route_id, true, WebKit::WebPopupTypeNone); |
1318 } | 1337 } |
1319 | 1338 |
1320 void WebContentsImpl::CreateNewWidget(int route_id, | 1339 void WebContentsImpl::CreateNewWidget(int route_id, |
1321 bool is_fullscreen, | 1340 bool is_fullscreen, |
1322 WebKit::WebPopupType popup_type) { | 1341 WebKit::WebPopupType popup_type) { |
1323 content::RenderProcessHost* process = GetRenderProcessHost(); | 1342 content::RenderProcessHost* process = GetRenderProcessHost(); |
1324 RenderWidgetHostImpl* widget_host = | 1343 RenderWidgetHostImpl* widget_host = |
1325 new RenderWidgetHostImpl(this, process, route_id); | 1344 new RenderWidgetHostImpl(this, process, route_id); |
| 1345 created_widgets_.insert(widget_host); |
| 1346 |
1326 RenderWidgetHostViewPort* widget_view = | 1347 RenderWidgetHostViewPort* widget_view = |
1327 RenderWidgetHostViewPort::CreateViewForWidget(widget_host); | 1348 RenderWidgetHostViewPort::CreateViewForWidget(widget_host); |
1328 if (!is_fullscreen) { | 1349 if (!is_fullscreen) { |
1329 // Popups should not get activated. | 1350 // Popups should not get activated. |
1330 widget_view->SetPopupType(popup_type); | 1351 widget_view->SetPopupType(popup_type); |
1331 } | 1352 } |
1332 // Save the created widget associated with the route so we can show it later. | 1353 // Save the created widget associated with the route so we can show it later. |
1333 pending_widget_views_[route_id] = widget_view; | 1354 pending_widget_views_[route_id] = widget_view; |
1334 | 1355 |
1335 #if defined(OS_MACOSX) | 1356 #if defined(OS_MACOSX) |
(...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3292 old_browser_plugin_host()->embedder_render_process_host(); | 3313 old_browser_plugin_host()->embedder_render_process_host(); |
3293 *embedder_container_id = old_browser_plugin_host()->instance_id(); | 3314 *embedder_container_id = old_browser_plugin_host()->instance_id(); |
3294 int embedder_process_id = | 3315 int embedder_process_id = |
3295 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; | 3316 embedder_render_process_host ? embedder_render_process_host->GetID() : -1; |
3296 if (embedder_process_id != -1) { | 3317 if (embedder_process_id != -1) { |
3297 *embedder_channel_name = | 3318 *embedder_channel_name = |
3298 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), | 3319 StringPrintf("%d.r%d", render_view_host->GetProcess()->GetID(), |
3299 embedder_process_id); | 3320 embedder_process_id); |
3300 } | 3321 } |
3301 } | 3322 } |
OLD | NEW |