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