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/startup/startup_browser_creator_impl.h" | 5 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "apps/app_restore_service.h" | 10 #include "apps/app_restore_service.h" |
11 #include "apps/app_restore_service_factory.h" | 11 #include "apps/app_restore_service_factory.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/environment.h" | 16 #include "base/environment.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
19 #include "base/metrics/field_trial.h" | |
19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
20 #include "base/metrics/statistics_recorder.h" | 21 #include "base/metrics/statistics_recorder.h" |
21 #include "base/path_service.h" | 22 #include "base/path_service.h" |
22 #include "base/prefs/pref_service.h" | 23 #include "base/prefs/pref_service.h" |
23 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
24 #include "base/strings/string_split.h" | 25 #include "base/strings/string_split.h" |
25 #include "base/strings/utf_string_conversions.h" | 26 #include "base/strings/utf_string_conversions.h" |
26 #include "base/threading/thread_restrictions.h" | 27 #include "base/threading/thread_restrictions.h" |
27 #include "chrome/browser/apps/install_chrome_app.h" | 28 #include "chrome/browser/apps/install_chrome_app.h" |
28 #include "chrome/browser/auto_launch_trial.h" | 29 #include "chrome/browser/auto_launch_trial.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 LM_WITH_URLS, // Launched with urls in the cmd line. | 123 LM_WITH_URLS, // Launched with urls in the cmd line. |
123 LM_SHORTCUT_NONE, // Not launched from a shortcut. | 124 LM_SHORTCUT_NONE, // Not launched from a shortcut. |
124 LM_SHORTCUT_NONAME, // Launched from shortcut but no name available. | 125 LM_SHORTCUT_NONAME, // Launched from shortcut but no name available. |
125 LM_SHORTCUT_UNKNOWN, // Launched from user-defined shortcut. | 126 LM_SHORTCUT_UNKNOWN, // Launched from user-defined shortcut. |
126 LM_SHORTCUT_QUICKLAUNCH, // Launched from the quick launch bar. | 127 LM_SHORTCUT_QUICKLAUNCH, // Launched from the quick launch bar. |
127 LM_SHORTCUT_DESKTOP, // Launched from a desktop shortcut. | 128 LM_SHORTCUT_DESKTOP, // Launched from a desktop shortcut. |
128 LM_SHORTCUT_TASKBAR, // Launched from the taskbar. | 129 LM_SHORTCUT_TASKBAR, // Launched from the taskbar. |
129 LM_LINUX_MAC_BEOS // Other OS buckets start here. | 130 LM_LINUX_MAC_BEOS // Other OS buckets start here. |
130 }; | 131 }; |
131 | 132 |
133 // The Finch experiment name and group name that enables new bubble UI after | |
134 // session crashes. | |
135 const char kManagedModeFinchName[] = "EnalbeSessionCrashedBubbleUI"; | |
136 const char kEnalbeBubbleUIGroupEnabled[] = "Enabled"; | |
137 | |
132 #if defined(OS_WIN) | 138 #if defined(OS_WIN) |
133 // Undocumented flag in the startup info structure tells us what shortcut was | 139 // Undocumented flag in the startup info structure tells us what shortcut was |
134 // used to launch the browser. See http://www.catch22.net/tuts/undoc01 for | 140 // used to launch the browser. See http://www.catch22.net/tuts/undoc01 for |
135 // more information. Confirmed to work on XP, Vista and Win7. | 141 // more information. Confirmed to work on XP, Vista and Win7. |
136 LaunchMode GetLaunchShortcutKind() { | 142 LaunchMode GetLaunchShortcutKind() { |
137 STARTUPINFOW si = { sizeof(si) }; | 143 STARTUPINFOW si = { sizeof(si) }; |
138 GetStartupInfoW(&si); | 144 GetStartupInfoW(&si); |
139 if (si.dwFlags & 0x800) { | 145 if (si.dwFlags & 0x800) { |
140 if (!si.lpTitle) | 146 if (!si.lpTitle) |
141 return LM_SHORTCUT_NONAME; | 147 return LM_SHORTCUT_NONAME; |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 return browser; | 844 return browser; |
839 } | 845 } |
840 | 846 |
841 void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary( | 847 void StartupBrowserCreatorImpl::AddInfoBarsIfNecessary( |
842 Browser* browser, | 848 Browser* browser, |
843 chrome::startup::IsProcessStartup is_process_startup) { | 849 chrome::startup::IsProcessStartup is_process_startup) { |
844 if (!browser || !profile_ || browser->tab_strip_model()->count() == 0) | 850 if (!browser || !profile_ || browser->tab_strip_model()->count() == 0) |
845 return; | 851 return; |
846 | 852 |
847 if (HasPendingUncleanExit(browser->profile())) { | 853 if (HasPendingUncleanExit(browser->profile())) { |
848 if (!command_line_.HasSwitch(switches::kEnableSessionCrashedBubble) || | 854 // The new bubble UI can be enabled by Finch experiment or by flag. |
849 !ShowSessionCrashedBubble(browser)) | 855 if (!((base::FieldTrialList::FindFullName(kManagedModeFinchName) == |
856 kEnalbeBubbleUIGroupEnabled || | |
857 command_line_.HasSwitch(switches::kEnableSessionCrashedBubble)) && | |
858 ShowSessionCrashedBubble(browser))) | |
Alexei Svitkine (slow)
2014/05/15 19:02:35
Hmm, I think it would be better to move this logic
yao
2014/05/15 21:19:38
Done.
| |
850 SessionCrashedInfoBarDelegate::Create(browser); | 859 SessionCrashedInfoBarDelegate::Create(browser); |
851 } | 860 } |
852 | 861 |
853 // The below info bars are only added to the first profile which is launched. | 862 // The below info bars are only added to the first profile which is launched. |
854 // Other profiles might be restoring the browsing sessions asynchronously, | 863 // Other profiles might be restoring the browsing sessions asynchronously, |
855 // so we cannot add the info bars to the focused tabs here. | 864 // so we cannot add the info bars to the focused tabs here. |
856 if (is_process_startup == chrome::startup::IS_PROCESS_STARTUP && | 865 if (is_process_startup == chrome::startup::IS_PROCESS_STARTUP && |
857 !command_line_.HasSwitch(switches::kTestType)) { | 866 !command_line_.HasSwitch(switches::kTestType)) { |
858 chrome::ShowBadFlagsPrompt(browser); | 867 chrome::ShowBadFlagsPrompt(browser); |
859 GoogleApiKeysInfoBarDelegate::Create(InfoBarService::FromWebContents( | 868 GoogleApiKeysInfoBarDelegate::Create(InfoBarService::FromWebContents( |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
933 // If the first URL is the NTP, replace it with the sync promo. This | 942 // If the first URL is the NTP, replace it with the sync promo. This |
934 // behavior is desired because completing or skipping the sync promo | 943 // behavior is desired because completing or skipping the sync promo |
935 // causes a redirect to the NTP. | 944 // causes a redirect to the NTP. |
936 if (!startup_urls->empty() && IsNewTabURL(profile_, startup_urls->at(0))) | 945 if (!startup_urls->empty() && IsNewTabURL(profile_, startup_urls->at(0))) |
937 startup_urls->at(0) = sync_promo_url; | 946 startup_urls->at(0) = sync_promo_url; |
938 else | 947 else |
939 startup_urls->insert(startup_urls->begin(), sync_promo_url); | 948 startup_urls->insert(startup_urls->begin(), sync_promo_url); |
940 } | 949 } |
941 } | 950 } |
942 } | 951 } |
OLD | NEW |