OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/views/outdated_upgrade_bubble_view.h" | 5 #include "chrome/browser/ui/views/outdated_upgrade_bubble_view.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #endif | 9 #endif |
10 | 10 |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/upgrade_detector.h" | 15 #include "chrome/browser/upgrade_detector.h" |
16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/page_navigator.h" | 18 #include "content/public/browser/page_navigator.h" |
18 #include "content/public/browser/user_metrics.h" | 19 #include "content/public/browser/user_metrics.h" |
19 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
20 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
21 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
24 #include "ui/views/controls/button/label_button.h" | 25 #include "ui/views/controls/button/label_button.h" |
25 #include "ui/views/controls/image_view.h" | 26 #include "ui/views/controls/image_view.h" |
26 #include "ui/views/controls/label.h" | 27 #include "ui/views/controls/label.h" |
27 #include "ui/views/layout/grid_layout.h" | 28 #include "ui/views/layout/grid_layout.h" |
28 #include "ui/views/layout/layout_constants.h" | 29 #include "ui/views/layout/layout_constants.h" |
29 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
30 #include "url/gurl.h" | 31 #include "url/gurl.h" |
31 | 32 |
32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
33 #include "base/win/win_util.h" | 34 #include "base/win/win_util.h" |
34 #include "base/win/windows_version.h" | 35 #include "base/win/windows_version.h" |
| 36 #include "chrome/installer/util/google_update_util.h" |
35 #include "chrome/installer/util/install_util.h" | 37 #include "chrome/installer/util/install_util.h" |
36 #include "ui/gfx/icon_util.h" | 38 #include "ui/gfx/icon_util.h" |
37 #endif | 39 #endif |
38 | 40 |
| 41 using content::BrowserThread; |
39 using views::GridLayout; | 42 using views::GridLayout; |
40 | 43 |
41 namespace { | 44 namespace { |
42 | 45 |
43 // Fixed width of the column holding the description label of the bubble. | 46 // Fixed width of the column holding the description label of the bubble. |
44 // TODO(mad): Make sure there is enough room for all languages. | 47 // TODO(mad): Make sure there is enough room for all languages. |
45 const int kWidthOfDescriptionText = 330; | 48 const int kWidthOfDescriptionText = 330; |
46 | 49 |
47 // We subtract 2 to account for the natural button padding, and | 50 // We subtract 2 to account for the natural button padding, and |
48 // to bring the separation visually in line with the row separation | 51 // to bring the separation visually in line with the row separation |
49 // height. | 52 // height. |
50 const int kButtonPadding = views::kRelatedButtonHSpacing - 2; | 53 const int kButtonPadding = views::kRelatedButtonHSpacing - 2; |
51 | 54 |
52 // The URL to be used to re-install Chrome when auto-update failed for too long. | 55 // The URL to be used to re-install Chrome when auto-update failed for too long. |
53 const char kDownloadChromeUrl[] = "https://www.google.com/chrome/?&brand=CHWL" | 56 const char kDownloadChromeUrl[] = "https://www.google.com/chrome/?&brand=CHWL" |
54 "&utm_campaign=en&utm_source=en-et-na-us-chrome-bubble&utm_medium=et"; | 57 "&utm_campaign=en&utm_source=en-et-na-us-chrome-bubble&utm_medium=et"; |
55 | 58 |
56 // The maximum number of ignored bubble we track in the NumLaterPerReinstall | 59 // The maximum number of ignored bubble we track in the NumLaterPerReinstall |
57 // histogram. | 60 // histogram. |
58 const int kMaxIgnored = 50; | 61 const int kMaxIgnored = 50; |
59 // The number of buckets we want the NumLaterPerReinstall histogram to use. | 62 // The number of buckets we want the NumLaterPerReinstall histogram to use. |
60 const int kNumIgnoredBuckets = 5; | 63 const int kNumIgnoredBuckets = 5; |
61 | 64 |
62 // Adds an elevation icon to |button| when running a system level install. | 65 // Adds an elevation icon to |button| when running a system level install. |
63 void AddElevationIconIfNeeded(views::LabelButton* button) { | 66 void AddElevationIconIfNeeded(views::LabelButton* button) { |
64 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
65 if ((base::win::GetVersion() >= base::win::VERSION_VISTA) && | 68 if ((base::win::GetVersion() >= base::win::VERSION_VISTA) && |
66 base::win::UserAccountControlIsEnabled()) { | 69 base::win::UserAccountControlIsEnabled()) { |
67 base::FilePath exe_path; | |
68 PathService::Get(base::FILE_EXE, &exe_path); | |
69 if (InstallUtil::IsPerUserInstall(exe_path.value().c_str())) | |
70 return; | |
71 | |
72 // This code was lifted from chrome/browser/ui/views/infobars/infobar_view. | 70 // This code was lifted from chrome/browser/ui/views/infobars/infobar_view. |
73 // TODO(mad): Investigate the possibility of moving it to a common place. | 71 // TODO(mad): Investigate the possibility of moving it to a common place. |
74 SHSTOCKICONINFO icon_info = { sizeof(SHSTOCKICONINFO) }; | 72 SHSTOCKICONINFO icon_info = { sizeof(SHSTOCKICONINFO) }; |
75 // Even with the runtime guard above, we have to use GetProcAddress() here, | 73 // Even with the runtime guard above, we have to use GetProcAddress() here, |
76 // because otherwise the loader will try to resolve the function address on | 74 // because otherwise the loader will try to resolve the function address on |
77 // startup, which will break on XP. | 75 // startup, which will break on XP. |
78 typedef HRESULT (STDAPICALLTYPE *GetStockIconInfo)(SHSTOCKICONID, UINT, | 76 typedef HRESULT (STDAPICALLTYPE *GetStockIconInfo)(SHSTOCKICONID, UINT, |
79 SHSTOCKICONINFO*); | 77 SHSTOCKICONINFO*); |
80 GetStockIconInfo func = reinterpret_cast<GetStockIconInfo>( | 78 GetStockIconInfo func = reinterpret_cast<GetStockIconInfo>( |
81 GetProcAddress(GetModuleHandle(L"shell32.dll"), "SHGetStockIconInfo")); | 79 GetProcAddress(GetModuleHandle(L"shell32.dll"), "SHGetStockIconInfo")); |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 UMA_HISTOGRAM_CUSTOM_COUNTS( | 246 UMA_HISTOGRAM_CUSTOM_COUNTS( |
249 "OutdatedUpgradeBubble.NumLaterPerReinstall", num_ignored_bubbles_, | 247 "OutdatedUpgradeBubble.NumLaterPerReinstall", num_ignored_bubbles_, |
250 0, kMaxIgnored, kNumIgnoredBuckets); | 248 0, kMaxIgnored, kNumIgnoredBuckets); |
251 content::RecordAction( | 249 content::RecordAction( |
252 base::UserMetricsAction("OutdatedUpgradeBubble.Reinstall")); | 250 base::UserMetricsAction("OutdatedUpgradeBubble.Reinstall")); |
253 navigator_->OpenURL(content::OpenURLParams(GURL(kDownloadChromeUrl), | 251 navigator_->OpenURL(content::OpenURLParams(GURL(kDownloadChromeUrl), |
254 content::Referrer(), | 252 content::Referrer(), |
255 NEW_FOREGROUND_TAB, | 253 NEW_FOREGROUND_TAB, |
256 content::PAGE_TRANSITION_LINK, | 254 content::PAGE_TRANSITION_LINK, |
257 false)); | 255 false)); |
| 256 #if defined(OS_WIN) |
258 } else { | 257 } else { |
259 DCHECK(UpgradeDetector::GetInstance()->is_outdated_install_no_au()); | 258 DCHECK(UpgradeDetector::GetInstance()->is_outdated_install_no_au()); |
260 UMA_HISTOGRAM_CUSTOM_COUNTS( | 259 UMA_HISTOGRAM_CUSTOM_COUNTS( |
261 "OutdatedUpgradeBubble.NumLaterPerEnableAU", num_ignored_bubbles_, | 260 "OutdatedUpgradeBubble.NumLaterPerEnableAU", num_ignored_bubbles_, |
262 0, kMaxIgnored, kNumIgnoredBuckets); | 261 0, kMaxIgnored, kNumIgnoredBuckets); |
263 content::RecordAction( | 262 content::RecordAction( |
264 base::UserMetricsAction("OutdatedUpgradeBubble.EnableAU")); | 263 base::UserMetricsAction("OutdatedUpgradeBubble.EnableAU")); |
265 // TODO(robertshield): Make a call to GoogleUpdateSettings to enable | 264 // Record that the autoupdate flavour of the dialog has been shown. |
266 // auto-update. | |
267 if (g_browser_process->local_state()) { | 265 if (g_browser_process->local_state()) { |
268 g_browser_process->local_state()->SetBoolean( | 266 g_browser_process->local_state()->SetBoolean( |
269 prefs::kAttemptedToEnableAutoupdate, true); | 267 prefs::kAttemptedToEnableAutoupdate, true); |
270 } | 268 } |
| 269 |
| 270 // Re-enable updates by shelling out to setup.exe in the blocking pool. |
| 271 BrowserThread::PostBlockingPoolTask(FROM_HERE, |
| 272 base::Bind(&google_update::ElevateIfNeededToReenableUpdates)); |
| 273 #endif // defined(OS_WIN) |
271 } | 274 } |
272 } else { | 275 } else { |
273 DCHECK_EQ(later_button_, sender); | 276 DCHECK_EQ(later_button_, sender); |
274 content::RecordAction( | 277 content::RecordAction( |
275 base::UserMetricsAction("OutdatedUpgradeBubble.Later")); | 278 base::UserMetricsAction("OutdatedUpgradeBubble.Later")); |
276 } | 279 } |
277 GetWidget()->Close(); | 280 GetWidget()->Close(); |
278 } | 281 } |
OLD | NEW |