OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/browser/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
(...skipping 2161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 } | 2172 } |
2173 } | 2173 } |
2174 } | 2174 } |
2175 | 2175 |
2176 void TabContents::UpdateInspectorSettings(const std::string& raw_settings) { | 2176 void TabContents::UpdateInspectorSettings(const std::string& raw_settings) { |
2177 profile()->GetPrefs()->SetString(prefs::kWebKitInspectorSettings, | 2177 profile()->GetPrefs()->SetString(prefs::kWebKitInspectorSettings, |
2178 UTF8ToWide(raw_settings)); | 2178 UTF8ToWide(raw_settings)); |
2179 } | 2179 } |
2180 | 2180 |
2181 void TabContents::Close(RenderViewHost* rvh) { | 2181 void TabContents::Close(RenderViewHost* rvh) { |
| 2182 // The UI may be in an event-tracking loop, such as between the |
| 2183 // mouse-down and mouse-up in text selection or a button click. |
| 2184 // Defer the close until after tracking is complete, so that we |
| 2185 // don't free objects out from under the UI. |
| 2186 // TODO(shess): This could probably be integrated with the |
| 2187 // IsDoingDrag() test below. Punting for now because I need more |
| 2188 // research to understand how this impacts platforms other than Mac. |
| 2189 // TODO(shess): This could get more fine-grained. For instance, |
| 2190 // closing a tab in another window while selecting text in the |
| 2191 // current window's Omnibox should be just fine. |
| 2192 if (view()->IsEventTracking()) { |
| 2193 view()->CloseTabAfterEventTracking(); |
| 2194 return; |
| 2195 } |
| 2196 |
2182 // If we close the tab while we're in the middle of a drag, we'll crash. | 2197 // If we close the tab while we're in the middle of a drag, we'll crash. |
2183 // Instead, cancel the drag and close it as soon as the drag ends. | 2198 // Instead, cancel the drag and close it as soon as the drag ends. |
2184 if (view()->IsDoingDrag()) { | 2199 if (view()->IsDoingDrag()) { |
2185 view()->CancelDragAndCloseTab(); | 2200 view()->CancelDragAndCloseTab(); |
2186 return; | 2201 return; |
2187 } | 2202 } |
2188 | 2203 |
2189 // Ignore this if it comes from a RenderViewHost that we aren't showing. | 2204 // Ignore this if it comes from a RenderViewHost that we aren't showing. |
2190 if (delegate() && rvh == render_view_host()) | 2205 if (delegate() && rvh == render_view_host()) |
2191 delegate()->CloseContents(this); | 2206 delegate()->CloseContents(this); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2644 #endif | 2659 #endif |
2645 | 2660 |
2646 default: | 2661 default: |
2647 NOTREACHED(); | 2662 NOTREACHED(); |
2648 } | 2663 } |
2649 } | 2664 } |
2650 | 2665 |
2651 void TabContents::set_encoding(const std::string& encoding) { | 2666 void TabContents::set_encoding(const std::string& encoding) { |
2652 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 2667 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
2653 } | 2668 } |
OLD | NEW |