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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2184 | 2187 |
2185 // If the only updates were synchronously handled above, we're done. | 2188 // If the only updates were synchronously handled above, we're done. |
2186 if (changed_flags == 0) | 2189 if (changed_flags == 0) |
2187 return; | 2190 return; |
2188 | 2191 |
2189 // Save the dirty bits. | 2192 // Save the dirty bits. |
2190 scheduled_updates_[source] |= changed_flags; | 2193 scheduled_updates_[source] |= changed_flags; |
2191 | 2194 |
2192 if (!chrome_updater_factory_.HasWeakPtrs()) { | 2195 if (!chrome_updater_factory_.HasWeakPtrs()) { |
2193 // No task currently scheduled, start another. | 2196 // No task currently scheduled, start another. |
2194 base::MessageLoop::current()->PostDelayedTask( | 2197 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
2195 FROM_HERE, | 2198 FROM_HERE, base::Bind(&Browser::ProcessPendingUIUpdates, |
2196 base::Bind(&Browser::ProcessPendingUIUpdates, | 2199 chrome_updater_factory_.GetWeakPtr()), |
2197 chrome_updater_factory_.GetWeakPtr()), | |
2198 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); | 2200 base::TimeDelta::FromMilliseconds(kUIUpdateCoalescingTimeMS)); |
2199 } | 2201 } |
2200 } | 2202 } |
2201 | 2203 |
2202 void Browser::ProcessPendingUIUpdates() { | 2204 void Browser::ProcessPendingUIUpdates() { |
2203 #ifndef NDEBUG | 2205 #ifndef NDEBUG |
2204 // Validate that all tabs we have pending updates for exist. This is scary | 2206 // Validate that all tabs we have pending updates for exist. This is scary |
2205 // because the pending list must be kept in sync with any detached or | 2207 // because the pending list must be kept in sync with any detached or |
2206 // deleted tabs. | 2208 // deleted tabs. |
2207 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); | 2209 for (UpdateMap::const_iterator i = scheduled_updates_.begin(); |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2623 if (contents && !allow_js_access) { | 2625 if (contents && !allow_js_access) { |
2624 contents->web_contents()->GetController().LoadURL( | 2626 contents->web_contents()->GetController().LoadURL( |
2625 target_url, | 2627 target_url, |
2626 content::Referrer(), | 2628 content::Referrer(), |
2627 ui::PAGE_TRANSITION_LINK, | 2629 ui::PAGE_TRANSITION_LINK, |
2628 std::string()); // No extra headers. | 2630 std::string()); // No extra headers. |
2629 } | 2631 } |
2630 | 2632 |
2631 return contents != NULL; | 2633 return contents != NULL; |
2632 } | 2634 } |
OLD | NEW |