Chromium Code Reviews| 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 "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 // OS_WIN | 10 #endif // 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/logging.h" | 18 #include "base/logging.h" |
| 19 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 20 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 21 #include "base/path_service.h" | 21 #include "base/path_service.h" |
| 22 #include "base/process_info.h" | |
| 22 #include "base/string_number_conversions.h" | 23 #include "base/string_number_conversions.h" |
| 23 #include "base/string_util.h" | 24 #include "base/string_util.h" |
| 24 #include "base/stringprintf.h" | 25 #include "base/stringprintf.h" |
| 25 #include "base/threading/thread.h" | 26 #include "base/threading/thread.h" |
| 26 #include "base/threading/thread_restrictions.h" | 27 #include "base/threading/thread_restrictions.h" |
| 27 #include "base/time.h" | 28 #include "base/time.h" |
| 28 #include "base/utf_string_conversions.h" | 29 #include "base/utf_string_conversions.h" |
| 29 #include "chrome/app/chrome_command_ids.h" | 30 #include "chrome/app/chrome_command_ids.h" |
| 30 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 31 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 31 #include "chrome/browser/background/background_contents_service.h" | 32 #include "chrome/browser/background/background_contents_service.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 #include "chrome/browser/upgrade_detector.h" | 146 #include "chrome/browser/upgrade_detector.h" |
| 146 #include "chrome/browser/web_applications/web_app.h" | 147 #include "chrome/browser/web_applications/web_app.h" |
| 147 #include "chrome/common/chrome_constants.h" | 148 #include "chrome/common/chrome_constants.h" |
| 148 #include "chrome/common/chrome_notification_types.h" | 149 #include "chrome/common/chrome_notification_types.h" |
| 149 #include "chrome/common/chrome_switches.h" | 150 #include "chrome/common/chrome_switches.h" |
| 150 #include "chrome/common/custom_handlers/protocol_handler.h" | 151 #include "chrome/common/custom_handlers/protocol_handler.h" |
| 151 #include "chrome/common/extensions/extension.h" | 152 #include "chrome/common/extensions/extension.h" |
| 152 #include "chrome/common/extensions/extension_constants.h" | 153 #include "chrome/common/extensions/extension_constants.h" |
| 153 #include "chrome/common/pref_names.h" | 154 #include "chrome/common/pref_names.h" |
| 154 #include "chrome/common/profiling.h" | 155 #include "chrome/common/profiling.h" |
| 156 #include "chrome/common/startup_metric_utils.h" | |
| 155 #include "chrome/common/url_constants.h" | 157 #include "chrome/common/url_constants.h" |
| 156 #include "chrome/common/web_apps.h" | 158 #include "chrome/common/web_apps.h" |
| 157 #include "content/public/browser/color_chooser.h" | 159 #include "content/public/browser/color_chooser.h" |
| 158 #include "content/public/browser/devtools_manager.h" | 160 #include "content/public/browser/devtools_manager.h" |
| 159 #include "content/public/browser/download_item.h" | 161 #include "content/public/browser/download_item.h" |
| 160 #include "content/public/browser/download_manager.h" | 162 #include "content/public/browser/download_manager.h" |
| 161 #include "content/public/browser/interstitial_page.h" | 163 #include "content/public/browser/interstitial_page.h" |
| 162 #include "content/public/browser/invalidate_type.h" | 164 #include "content/public/browser/invalidate_type.h" |
| 163 #include "content/public/browser/navigation_controller.h" | 165 #include "content/public/browser/navigation_controller.h" |
| 164 #include "content/public/browser/navigation_entry.h" | 166 #include "content/public/browser/navigation_entry.h" |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1195 | 1197 |
| 1196 bool Browser::IsMouseLocked() const { | 1198 bool Browser::IsMouseLocked() const { |
| 1197 return fullscreen_controller_->IsMouseLocked(); | 1199 return fullscreen_controller_->IsMouseLocked(); |
| 1198 } | 1200 } |
| 1199 | 1201 |
| 1200 void Browser::OnWindowDidShow() { | 1202 void Browser::OnWindowDidShow() { |
| 1201 if (window_has_shown_) | 1203 if (window_has_shown_) |
| 1202 return; | 1204 return; |
| 1203 window_has_shown_ = true; | 1205 window_has_shown_ = true; |
| 1204 | 1206 |
| 1207 // CurrentProcessInfo::CreationTime() is currently only implemented on Mac and | |
| 1208 // Windows. | |
| 1209 #if defined(OS_MACOSX) || defined(OS_WIN) | |
| 1210 // Measure the latency from startup till the first browser window becomes | |
| 1211 // visible. | |
| 1212 static bool isFirstBrowserWindow = true; | |
|
sky
2012/07/25 15:51:48
is_first_browser_window
jeremy
2012/07/26 12:57:26
Done.
| |
| 1213 if (isFirstBrowserWindow && !StartupMetricUtils::WasNonBrowserUIDisplayed()) { | |
| 1214 isFirstBrowserWindow = false; | |
| 1215 const base::Time* process_creation_time = | |
| 1216 base::CurrentProcessInfo::CreationTime(); | |
| 1217 | |
| 1218 if (process_creation_time) { | |
| 1219 UMA_HISTOGRAM_LONG_TIMES( | |
| 1220 "Startup.BrowserWindowDisplay", | |
| 1221 base::Time::Now() - *process_creation_time); | |
| 1222 } | |
| 1223 } | |
| 1224 #endif // OS_MACOSX || OS_WIN | |
| 1225 | |
| 1205 // Nothing to do for non-tabbed windows. | 1226 // Nothing to do for non-tabbed windows. |
| 1206 if (!is_type_tabbed()) | 1227 if (!is_type_tabbed()) |
| 1207 return; | 1228 return; |
| 1208 | 1229 |
| 1209 // Show any pending global error bubble. | 1230 // Show any pending global error bubble. |
| 1210 GlobalErrorService* service = | 1231 GlobalErrorService* service = |
| 1211 GlobalErrorServiceFactory::GetForProfile(profile()); | 1232 GlobalErrorServiceFactory::GetForProfile(profile()); |
| 1212 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); | 1233 GlobalError* error = service->GetFirstGlobalErrorWithBubbleView(); |
| 1213 if (error) | 1234 if (error) |
| 1214 error->ShowBubbleView(this); | 1235 error->ShowBubbleView(this); |
| (...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2276 if (contents && !allow_js_access) { | 2297 if (contents && !allow_js_access) { |
| 2277 contents->web_contents()->GetController().LoadURL( | 2298 contents->web_contents()->GetController().LoadURL( |
| 2278 target_url, | 2299 target_url, |
| 2279 content::Referrer(), | 2300 content::Referrer(), |
| 2280 content::PAGE_TRANSITION_LINK, | 2301 content::PAGE_TRANSITION_LINK, |
| 2281 std::string()); // No extra headers. | 2302 std::string()); // No extra headers. |
| 2282 } | 2303 } |
| 2283 | 2304 |
| 2284 return contents != NULL; | 2305 return contents != NULL; |
| 2285 } | 2306 } |
| OLD | NEW |