| 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 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2784 void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) { | 2784 void WebContentsImpl::UpdateTargetURL(int32 page_id, const GURL& url) { |
| 2785 if (delegate_) | 2785 if (delegate_) |
| 2786 delegate_->UpdateTargetURL(this, page_id, url); | 2786 delegate_->UpdateTargetURL(this, page_id, url); |
| 2787 } | 2787 } |
| 2788 | 2788 |
| 2789 void WebContentsImpl::Close(RenderViewHost* rvh) { | 2789 void WebContentsImpl::Close(RenderViewHost* rvh) { |
| 2790 // The UI may be in an event-tracking loop, such as between the | 2790 // The UI may be in an event-tracking loop, such as between the |
| 2791 // mouse-down and mouse-up in text selection or a button click. | 2791 // mouse-down and mouse-up in text selection or a button click. |
| 2792 // Defer the close until after tracking is complete, so that we | 2792 // Defer the close until after tracking is complete, so that we |
| 2793 // don't free objects out from under the UI. | 2793 // don't free objects out from under the UI. |
| 2794 // TODO(shess): This could probably be integrated with the | |
| 2795 // IsDoingDrag() test below. Punting for now because I need more | |
| 2796 // research to understand how this impacts platforms other than Mac. | |
| 2797 // TODO(shess): This could get more fine-grained. For instance, | 2794 // TODO(shess): This could get more fine-grained. For instance, |
| 2798 // closing a tab in another window while selecting text in the | 2795 // closing a tab in another window while selecting text in the |
| 2799 // current window's Omnibox should be just fine. | 2796 // current window's Omnibox should be just fine. |
| 2800 if (GetView()->IsEventTracking()) { | 2797 if (GetView()->IsEventTracking()) { |
| 2801 GetView()->CloseTabAfterEventTracking(); | 2798 GetView()->CloseTabAfterEventTracking(); |
| 2802 return; | 2799 return; |
| 2803 } | 2800 } |
| 2804 | 2801 |
| 2805 // If we close the tab while we're in the middle of a drag, we'll crash. | |
| 2806 // Instead, cancel the drag and close it as soon as the drag ends. | |
| 2807 if (GetView()->IsDoingDrag()) { | |
| 2808 GetView()->CancelDragAndCloseTab(); | |
| 2809 return; | |
| 2810 } | |
| 2811 | |
| 2812 // Ignore this if it comes from a RenderViewHost that we aren't showing. | 2802 // Ignore this if it comes from a RenderViewHost that we aren't showing. |
| 2813 if (delegate_ && rvh == GetRenderViewHost()) | 2803 if (delegate_ && rvh == GetRenderViewHost()) |
| 2814 delegate_->CloseContents(this); | 2804 delegate_->CloseContents(this); |
| 2815 } | 2805 } |
| 2816 | 2806 |
| 2817 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { | 2807 void WebContentsImpl::SwappedOut(RenderViewHost* rvh) { |
| 2818 if (delegate_ && rvh == GetRenderViewHost()) | 2808 if (delegate_ && rvh == GetRenderViewHost()) |
| 2819 delegate_->SwappedOut(this); | 2809 delegate_->SwappedOut(this); |
| 2820 } | 2810 } |
| 2821 | 2811 |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3366 } | 3356 } |
| 3367 } | 3357 } |
| 3368 | 3358 |
| 3369 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { | 3359 content::BrowserPluginGuest* WebContentsImpl::GetBrowserPluginGuest() { |
| 3370 return browser_plugin_guest_.get(); | 3360 return browser_plugin_guest_.get(); |
| 3371 } | 3361 } |
| 3372 | 3362 |
| 3373 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { | 3363 content::BrowserPluginEmbedder* WebContentsImpl::GetBrowserPluginEmbedder() { |
| 3374 return browser_plugin_embedder_.get(); | 3364 return browser_plugin_embedder_.get(); |
| 3375 } | 3365 } |
| OLD | NEW |