| 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 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 #endif // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
| 11 | 11 |
| 12 #include <algorithm> | 12 #include <algorithm> |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/base_paths.h" | 15 #include "base/base_paths.h" |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/location.h" |
| 18 #include "base/logging.h" | 19 #include "base/logging.h" |
| 19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 20 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
| 21 #include "base/process/process_info.h" | 22 #include "base/process/process_info.h" |
| 22 #include "base/profiler/scoped_tracker.h" | 23 #include "base/profiler/scoped_tracker.h" |
| 24 #include "base/single_thread_task_runner.h" |
| 23 #include "base/strings/string_number_conversions.h" | 25 #include "base/strings/string_number_conversions.h" |
| 24 #include "base/strings/string_util.h" | 26 #include "base/strings/string_util.h" |
| 25 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 26 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 29 #include "base/thread_task_runner_handle.h" |
| 27 #include "base/threading/thread.h" | 30 #include "base/threading/thread.h" |
| 28 #include "base/threading/thread_restrictions.h" | 31 #include "base/threading/thread_restrictions.h" |
| 29 #include "base/time/time.h" | 32 #include "base/time/time.h" |
| 30 #include "chrome/app/chrome_command_ids.h" | 33 #include "chrome/app/chrome_command_ids.h" |
| 31 #include "chrome/browser/app_mode/app_mode_utils.h" | 34 #include "chrome/browser/app_mode/app_mode_utils.h" |
| 32 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 35 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 33 #include "chrome/browser/background/background_contents.h" | 36 #include "chrome/browser/background/background_contents.h" |
| 34 #include "chrome/browser/background/background_contents_service.h" | 37 #include "chrome/browser/background/background_contents_service.h" |
| 35 #include "chrome/browser/background/background_contents_service_factory.h" | 38 #include "chrome/browser/background/background_contents_service_factory.h" |
| 36 #include "chrome/browser/browser_process.h" | 39 #include "chrome/browser/browser_process.h" |
| (...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 } | 1156 } |
| 1154 } | 1157 } |
| 1155 | 1158 |
| 1156 void Browser::TabStripEmpty() { | 1159 void Browser::TabStripEmpty() { |
| 1157 // Close the frame after we return to the message loop (not immediately, | 1160 // Close the frame after we return to the message loop (not immediately, |
| 1158 // otherwise it will destroy this object before the stack has a chance to | 1161 // otherwise it will destroy this object before the stack has a chance to |
| 1159 // cleanly unwind.) | 1162 // cleanly unwind.) |
| 1160 // Note: This will be called several times if TabStripEmpty is called several | 1163 // Note: This will be called several times if TabStripEmpty is called several |
| 1161 // times. This is because it does not close the window if tabs are | 1164 // times. This is because it does not close the window if tabs are |
| 1162 // still present. | 1165 // still present. |
| 1163 base::MessageLoop::current()->PostTask( | 1166 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1164 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); | 1167 FROM_HERE, base::Bind(&Browser::CloseFrame, weak_factory_.GetWeakPtr())); |
| 1165 | 1168 |
| 1166 // Instant may have visible WebContents that need to be detached before the | 1169 // Instant may have visible WebContents that need to be detached before the |
| 1167 // window system closes. | 1170 // window system closes. |
| 1168 instant_controller_.reset(); | 1171 instant_controller_.reset(); |
| 1169 } | 1172 } |
| 1170 | 1173 |
| 1171 bool Browser::CanOverscrollContent() const { | 1174 bool Browser::CanOverscrollContent() const { |
| 1172 #if defined(OS_WIN) | 1175 #if defined(OS_WIN) |
| 1173 // Don't enable overscroll on Windows machines unless they have a touch | 1176 // Don't enable overscroll on Windows machines unless they have a touch |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2183 | 2186 |
| 2184 // If the only updates were synchronously handled above, we're done. | 2187 // If the only updates were synchronously handled above, we're done. |
| 2185 if (changed_flags == 0) | 2188 if (changed_flags == 0) |
| 2186 return; | 2189 return; |
| 2187 | 2190 |
| 2188 // Save the dirty bits. | 2191 // Save the dirty bits. |
| 2189 scheduled_updates_[source] |= changed_flags; | 2192 scheduled_updates_[source] |= changed_flags; |
| 2190 | 2193 |
| 2191 if (!chrome_updater_factory_.HasWeakPtrs()) { | 2194 if (!chrome_updater_factory_.HasWeakPtrs()) { |
| 2192 // No task currently scheduled, start another. | 2195 // No task currently scheduled, start another. |
| 2193 base::MessageLoop::current()->PostDelayedTask( | 2196 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 2194 FROM_HERE, | 2197 FROM_HERE, base::Bind(&Browser::ProcessPendingUIUpdates, |
| 2195 base::Bind(&Browser::ProcessPendingUIUpdates, | 2198 chrome_updater_factory_.GetWeakPtr()), |
| 2196 chrome_updater_factory_.GetWeakPtr()), | |
| 2197 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); | 2199 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); |
| 2198 } | 2200 } |
| 2199 } | 2201 } |
| 2200 | 2202 |
| 2201 void Browser::ProcessPendingUIUpdates() { | 2203 void Browser::ProcessPendingUIUpdates() { |
| 2202 #ifndef NDEBUG | 2204 #ifndef NDEBUG |
| 2203 // Validate that all tabs we have pending updates for exist. This is scary | 2205 // Validate that all tabs we have pending updates for exist. This is scary |
| 2204 // because the pending list must be kept in sync with any detached or | 2206 // because the pending list must be kept in sync with any detached or |
| 2205 // deleted tabs. | 2207 // deleted tabs. |
| 2206 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); | 2208 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2622 if (contents && !allow_js_access) { | 2624 if (contents && !allow_js_access) { |
| 2623 contents->web_contents()->GetController().LoadURL( | 2625 contents->web_contents()->GetController().LoadURL( |
| 2624 target_url, | 2626 target_url, |
| 2625 content::Referrer(), | 2627 content::Referrer(), |
| 2626 ui::PAGE_TRANSITION_LINK, | 2628 ui::PAGE_TRANSITION_LINK, |
| 2627 std::string()); // No extra headers. | 2629 std::string()); // No extra headers. |
| 2628 } | 2630 } |
| 2629 | 2631 |
| 2630 return contents != NULL; | 2632 return contents != NULL; |
| 2631 } | 2633 } |
| OLD | NEW |