| 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 2796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2807 void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) { | 2807 void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) { |
| 2808 if (delegate_) | 2808 if (delegate_) |
| 2809 delegate_->UpdateTargetURL(this, page_id, url); | 2809 delegate_->UpdateTargetURL(this, page_id, url); |
| 2810 } | 2810 } |
| 2811 | 2811 |
| 2812 void WebContentsImpl::Close(RenderViewHost* rvh) { | 2812 void WebContentsImpl::Close(RenderViewHost* rvh) { |
| 2813 // The UI may be in an event-tracking loop, such as between the | 2813 // The UI may be in an event-tracking loop, such as between the |
| 2814 // mouse-down and mouse-up in text selection or a button click. | 2814 // mouse-down and mouse-up in text selection or a button click. |
| 2815 // Defer the close until after tracking is complete, so that we | 2815 // Defer the close until after tracking is complete, so that we |
| 2816 // don't free objects out from under the UI. | 2816 // don't free objects out from under the UI. |
| 2817 // TODO(shess): This could probably be integrated with the | |
| 2818 // IsDoingDrag() test below. Punting for now because I need more | |
| 2819 // research to understand how this impacts platforms other than Mac. | |
| 2820 // TODO(shess): This could get more fine-grained. For instance, | 2817 // TODO(shess): This could get more fine-grained. For instance, |
| 2821 // closing a tab in another window while selecting text in the | 2818 // closing a tab in another window while selecting text in the |
| 2822 // current window's Omnibox should be just fine. | 2819 // current window's Omnibox should be just fine. |
| 2823 if (GetView()->IsEventTracking()) { | 2820 if (GetView()->IsEventTracking()) { |
| 2824 GetView()->CloseTabAfterEventTracking(); | 2821 GetView()->CloseTabAfterEventTracking(); |
| 2825 return; | 2822 return; |
| 2826 } | 2823 } |
| 2827 | 2824 |
| 2828 // If we close the tab while we're in the middle of a drag, we'll crash. | |
| 2829 // Instead, cancel the drag and close it as soon as the drag ends. | |
| 2830 if (GetView()->IsDoingDrag()) { | |
| 2831 GetView()->CancelDragAndCloseTab(); | |
| 2832 return; | |
| 2833 } | |
| 2834 | |
| 2835 // Ignore this if it comes from a RenderViewHost that we aren't showing. | 2825 // Ignore this if it comes from a RenderViewHost that we aren't showing. |
| 2836 if (delegate_ && rvh == GetRenderViewHost()) | 2826 if (delegate_ && rvh == GetRenderViewHost()) |
| 2837 delegate_->CloseContents(this); | 2827 delegate_->CloseContents(this); |
| 2838 } | 2828 } |
| 2839 | 2829 |
| 2840 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { | 2830 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { |
| 2841 if (delegate_ && rvh == GetRenderViewHost()) | 2831 if (delegate_ && rvh == GetRenderViewHost()) |
| 2842 delegate_->SwappedOut(this); | 2832 delegate_->SwappedOut(this); |
| 2843 } | 2833 } |
| 2844 | 2834 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3391 } | 3381 } |
| 3392 } | 3382 } |
| 3393 | 3383 |
| 3394 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3384 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3395 return browser_plugin_guest_.get(); | 3385 return browser_plugin_guest_.get(); |
| 3396 } | 3386 } |
| 3397 | 3387 |
| 3398 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3388 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3399 return browser_plugin_embedder_.get(); | 3389 return browser_plugin_embedder_.get(); |
| 3400 } | 3390 } |
| OLD | NEW |