| 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 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "base/metrics/user_metrics.h" |
| 8 #include "base/task_scheduler/post_task.h" | 9 #include "base/task_scheduler/post_task.h" |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/ui/layout_constants.h" | 12 #include "chrome/browser/ui/layout_constants.h" |
| 12 #include "chrome/browser/ui/views/elevation_icon_setter.h" | 13 #include "chrome/browser/ui/views/elevation_icon_setter.h" |
| 13 #include "chrome/browser/upgrade_detector.h" | 14 #include "chrome/browser/upgrade_detector.h" |
| 14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
| 15 #include "chrome/grit/chromium_strings.h" | 16 #include "chrome/grit/chromium_strings.h" |
| 16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
| 17 #include "components/prefs/pref_service.h" | 18 #include "components/prefs/pref_service.h" |
| 18 #include "content/public/browser/page_navigator.h" | 19 #include "content/public/browser/page_navigator.h" |
| 19 #include "content/public/browser/user_metrics.h" | |
| 20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 21 #include "ui/views/controls/label.h" | 21 #include "ui/views/controls/label.h" |
| 22 #include "ui/views/layout/fill_layout.h" | 22 #include "ui/views/layout/fill_layout.h" |
| 23 #include "ui/views/layout/layout_constants.h" | 23 #include "ui/views/layout/layout_constants.h" |
| 24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
| 25 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 26 | 26 |
| 27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
| 28 #include "chrome/installer/util/google_update_util.h" | 28 #include "chrome/installer/util/google_update_util.h" |
| 29 #endif | 29 #endif |
| (...skipping 27 matching lines...) Expand all Loading... |
| 57 | 57 |
| 58 // static | 58 // static |
| 59 void OutdatedUpgradeBubbleView::ShowBubble(views::View* anchor_view, | 59 void OutdatedUpgradeBubbleView::ShowBubble(views::View* anchor_view, |
| 60 content::PageNavigator* navigator, | 60 content::PageNavigator* navigator, |
| 61 bool auto_update_enabled) { | 61 bool auto_update_enabled) { |
| 62 if (g_upgrade_bubble) | 62 if (g_upgrade_bubble) |
| 63 return; | 63 return; |
| 64 g_upgrade_bubble = new OutdatedUpgradeBubbleView(anchor_view, navigator, | 64 g_upgrade_bubble = new OutdatedUpgradeBubbleView(anchor_view, navigator, |
| 65 auto_update_enabled); | 65 auto_update_enabled); |
| 66 views::BubbleDialogDelegateView::CreateBubble(g_upgrade_bubble)->Show(); | 66 views::BubbleDialogDelegateView::CreateBubble(g_upgrade_bubble)->Show(); |
| 67 content::RecordAction(auto_update_enabled ? | 67 base::RecordAction( |
| 68 base::UserMetricsAction("OutdatedUpgradeBubble.Show") : | 68 auto_update_enabled |
| 69 base::UserMetricsAction("OutdatedUpgradeBubble.ShowNoAU")); | 69 ? base::UserMetricsAction("OutdatedUpgradeBubble.Show") |
| 70 : base::UserMetricsAction("OutdatedUpgradeBubble.ShowNoAU")); |
| 70 } | 71 } |
| 71 | 72 |
| 72 bool OutdatedUpgradeBubbleView::IsAvailable() { | 73 bool OutdatedUpgradeBubbleView::IsAvailable() { |
| 73 // This should only work on non-Chrome OS desktop platforms. | 74 // This should only work on non-Chrome OS desktop platforms. |
| 74 #if defined(OS_WIN) || defined(OS_MACOSX) || \ | 75 #if defined(OS_WIN) || defined(OS_MACOSX) || \ |
| 75 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) | 76 (defined(OS_LINUX) && !defined(OS_CHROMEOS)) |
| 76 return true; | 77 return true; |
| 77 #else | 78 #else |
| 78 return false; | 79 return false; |
| 79 #endif | 80 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 92 // would attempt to show a bubble that is closing. | 93 // would attempt to show a bubble that is closing. |
| 93 DCHECK_EQ(g_upgrade_bubble, this); | 94 DCHECK_EQ(g_upgrade_bubble, this); |
| 94 g_upgrade_bubble = nullptr; | 95 g_upgrade_bubble = nullptr; |
| 95 } | 96 } |
| 96 | 97 |
| 97 base::string16 OutdatedUpgradeBubbleView::GetWindowTitle() const { | 98 base::string16 OutdatedUpgradeBubbleView::GetWindowTitle() const { |
| 98 return l10n_util::GetStringUTF16(IDS_UPGRADE_BUBBLE_TITLE); | 99 return l10n_util::GetStringUTF16(IDS_UPGRADE_BUBBLE_TITLE); |
| 99 } | 100 } |
| 100 | 101 |
| 101 bool OutdatedUpgradeBubbleView::Cancel() { | 102 bool OutdatedUpgradeBubbleView::Cancel() { |
| 102 content::RecordAction(base::UserMetricsAction("OutdatedUpgradeBubble.Later")); | 103 base::RecordAction(base::UserMetricsAction("OutdatedUpgradeBubble.Later")); |
| 103 return true; | 104 return true; |
| 104 } | 105 } |
| 105 | 106 |
| 106 bool OutdatedUpgradeBubbleView::Accept() { | 107 bool OutdatedUpgradeBubbleView::Accept() { |
| 107 // Offset the +1 in the dtor. | 108 // Offset the +1 in the dtor. |
| 108 --g_num_ignored_bubbles; | 109 --g_num_ignored_bubbles; |
| 109 | 110 |
| 110 if (auto_update_enabled_) { | 111 if (auto_update_enabled_) { |
| 111 DCHECK(UpgradeDetector::GetInstance()->is_outdated_install()); | 112 DCHECK(UpgradeDetector::GetInstance()->is_outdated_install()); |
| 112 UMA_HISTOGRAM_CUSTOM_COUNTS("OutdatedUpgradeBubble.NumLaterPerReinstall", | 113 UMA_HISTOGRAM_CUSTOM_COUNTS("OutdatedUpgradeBubble.NumLaterPerReinstall", |
| 113 g_num_ignored_bubbles, 1, kMaxIgnored, | 114 g_num_ignored_bubbles, 1, kMaxIgnored, |
| 114 kNumIgnoredBuckets); | 115 kNumIgnoredBuckets); |
| 115 content::RecordAction( | 116 base::RecordAction( |
| 116 base::UserMetricsAction("OutdatedUpgradeBubble.Reinstall")); | 117 base::UserMetricsAction("OutdatedUpgradeBubble.Reinstall")); |
| 117 navigator_->OpenURL( | 118 navigator_->OpenURL( |
| 118 content::OpenURLParams(GURL(kDownloadChromeUrl), content::Referrer(), | 119 content::OpenURLParams(GURL(kDownloadChromeUrl), content::Referrer(), |
| 119 WindowOpenDisposition::NEW_FOREGROUND_TAB, | 120 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 120 ui::PAGE_TRANSITION_LINK, false)); | 121 ui::PAGE_TRANSITION_LINK, false)); |
| 121 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
| 122 } else { | 123 } else { |
| 123 DCHECK(UpgradeDetector::GetInstance()->is_outdated_install_no_au()); | 124 DCHECK(UpgradeDetector::GetInstance()->is_outdated_install_no_au()); |
| 124 UMA_HISTOGRAM_CUSTOM_COUNTS("OutdatedUpgradeBubble.NumLaterPerEnableAU", | 125 UMA_HISTOGRAM_CUSTOM_COUNTS("OutdatedUpgradeBubble.NumLaterPerEnableAU", |
| 125 g_num_ignored_bubbles, 1, kMaxIgnored, | 126 g_num_ignored_bubbles, 1, kMaxIgnored, |
| 126 kNumIgnoredBuckets); | 127 kNumIgnoredBuckets); |
| 127 content::RecordAction( | 128 base::RecordAction( |
| 128 base::UserMetricsAction("OutdatedUpgradeBubble.EnableAU")); | 129 base::UserMetricsAction("OutdatedUpgradeBubble.EnableAU")); |
| 129 // Record that the autoupdate flavour of the dialog has been shown. | 130 // Record that the autoupdate flavour of the dialog has been shown. |
| 130 if (g_browser_process->local_state()) { | 131 if (g_browser_process->local_state()) { |
| 131 g_browser_process->local_state()->SetBoolean( | 132 g_browser_process->local_state()->SetBoolean( |
| 132 prefs::kAttemptedToEnableAutoupdate, true); | 133 prefs::kAttemptedToEnableAutoupdate, true); |
| 133 } | 134 } |
| 134 | 135 |
| 135 // Re-enable updates by shelling out to setup.exe asynchronously. | 136 // Re-enable updates by shelling out to setup.exe asynchronously. |
| 136 base::PostTaskWithTraits( | 137 base::PostTaskWithTraits( |
| 137 FROM_HERE, | 138 FROM_HERE, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 views::View* anchor_view, | 180 views::View* anchor_view, |
| 180 content::PageNavigator* navigator, | 181 content::PageNavigator* navigator, |
| 181 bool auto_update_enabled) | 182 bool auto_update_enabled) |
| 182 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 183 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
| 183 auto_update_enabled_(auto_update_enabled), | 184 auto_update_enabled_(auto_update_enabled), |
| 184 navigator_(navigator) { | 185 navigator_(navigator) { |
| 185 // Compensate for built-in vertical padding in the anchor view's image. | 186 // Compensate for built-in vertical padding in the anchor view's image. |
| 186 set_anchor_view_insets(gfx::Insets( | 187 set_anchor_view_insets(gfx::Insets( |
| 187 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 188 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 188 } | 189 } |
| OLD | NEW |