| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "chrome/browser/ui/browser.h" | 5 #include "chrome/browser/ui/browser.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 void Browser::TabStripEmpty() { | 1171 void Browser::TabStripEmpty() { |
| 1172 // Close the frame after we return to the message loop (not immediately, | 1172 // Close the frame after we return to the message loop (not immediately, |
| 1173 // otherwise it will destroy this object before the stack has a chance to | 1173 // otherwise it will destroy this object before the stack has a chance to |
| 1174 // cleanly unwind.) | 1174 // cleanly unwind.) |
| 1175 // Note: This will be called several times if TabStripEmpty is called several | 1175 // Note: This will be called several times if TabStripEmpty is called several |
| 1176 // times. This is because it does not close the window if tabs are | 1176 // times. This is because it does not close the window if tabs are |
| 1177 // still present. | 1177 // still present. |
| 1178 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1178 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1179 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); | 1179 FROM_HERE, |
| 1180 base::BindOnce(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); |
| 1180 | 1181 |
| 1181 // Instant may have visible WebContents that need to be detached before the | 1182 // Instant may have visible WebContents that need to be detached before the |
| 1182 // window system closes. | 1183 // window system closes. |
| 1183 instant_controller_.reset(); | 1184 instant_controller_.reset(); |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 bool Browser::CanOverscrollContent() const { | 1187 bool Browser::CanOverscrollContent() const { |
| 1187 #if defined(OS_WIN) | 1188 #if defined(OS_WIN) |
| 1188 // Don't enable overscroll on Windows machines unless they have a touch | 1189 // Don't enable overscroll on Windows machines unless they have a touch |
| 1189 // screen as these machines typically don't have a touchpad capable of | 1190 // screen as these machines typically don't have a touchpad capable of |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2198 // If the only updates were synchronously handled above, we're done. | 2199 // If the only updates were synchronously handled above, we're done. |
| 2199 if (changed_flags == 0) | 2200 if (changed_flags == 0) |
| 2200 return; | 2201 return; |
| 2201 | 2202 |
| 2202 // Save the dirty bits. | 2203 // Save the dirty bits. |
| 2203 scheduled_updates_[source] |= changed_flags; | 2204 scheduled_updates_[source] |= changed_flags; |
| 2204 | 2205 |
| 2205 if (!chrome_updater_factory_.HasWeakPtrs()) { | 2206 if (!chrome_updater_factory_.HasWeakPtrs()) { |
| 2206 // No task currently scheduled, start another. | 2207 // No task currently scheduled, start another. |
| 2207 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 2208 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 2208 FROM_HERE, base::Bind(&Browser::ProcessPendingUIUpdates, | 2209 FROM_HERE, |
| 2209 chrome_updater_factory_.GetWeakPtr()), | 2210 base::BindOnce(&Browser::ProcessPendingUIUpdates, |
| 2211 chrome_updater_factory_.GetWeakPtr()), |
| 2210 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); | 2212 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); |
| 2211 } | 2213 } |
| 2212 } | 2214 } |
| 2213 | 2215 |
| 2214 void Browser::ProcessPendingUIUpdates() { | 2216 void Browser::ProcessPendingUIUpdates() { |
| 2215 #ifndef NDEBUG | 2217 #ifndef NDEBUG |
| 2216 // Validate that all tabs we have pending updates for exist. This is scary | 2218 // Validate that all tabs we have pending updates for exist. This is scary |
| 2217 // because the pending list must be kept in sync with any detached or | 2219 // because the pending list must be kept in sync with any detached or |
| 2218 // deleted tabs. | 2220 // deleted tabs. |
| 2219 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); | 2221 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2621 // new window later, thus we need to navigate the window now. | 2623 // new window later, thus we need to navigate the window now. |
| 2622 if (contents) { | 2624 if (contents) { |
| 2623 contents->web_contents()->GetController().LoadURL( | 2625 contents->web_contents()->GetController().LoadURL( |
| 2624 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, | 2626 target_url, content::Referrer(), ui::PAGE_TRANSITION_LINK, |
| 2625 std::string()); // No extra headers. | 2627 std::string()); // No extra headers. |
| 2626 } | 2628 } |
| 2627 } | 2629 } |
| 2628 | 2630 |
| 2629 return contents != NULL; | 2631 return contents != NULL; |
| 2630 } | 2632 } |
| OLD | NEW |