Chromium Code Reviews| 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 "chrome/installer/util/google_update_util.h" | |
| 18 #include "content/public/browser/browser_thread.h" | |
| 17 #include "content/public/browser/page_navigator.h" | 19 #include "content/public/browser/page_navigator.h" |
| 18 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 19 #include "grit/chromium_strings.h" | 21 #include "grit/chromium_strings.h" |
| 20 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 21 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
| 24 #include "ui/views/controls/button/label_button.h" | 26 #include "ui/views/controls/button/label_button.h" |
| 25 #include "ui/views/controls/image_view.h" | 27 #include "ui/views/controls/image_view.h" |
| 26 #include "ui/views/controls/label.h" | 28 #include "ui/views/controls/label.h" |
| 27 #include "ui/views/layout/grid_layout.h" | 29 #include "ui/views/layout/grid_layout.h" |
| 28 #include "ui/views/layout/layout_constants.h" | 30 #include "ui/views/layout/layout_constants.h" |
| 29 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
| 30 #include "url/gurl.h" | 32 #include "url/gurl.h" |
| 31 | 33 |
| 32 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 33 #include "base/win/win_util.h" | 35 #include "base/win/win_util.h" |
| 34 #include "base/win/windows_version.h" | 36 #include "base/win/windows_version.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 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 if (icon.get()) { | 90 if (icon.get()) { |
| 88 button->SetImage(views::Button::STATE_NORMAL, | 91 button->SetImage(views::Button::STATE_NORMAL, |
| 89 gfx::ImageSkia::CreateFrom1xBitmap(*icon)); | 92 gfx::ImageSkia::CreateFrom1xBitmap(*icon)); |
| 90 } | 93 } |
| 91 DestroyIcon(icon_info.hIcon); | 94 DestroyIcon(icon_info.hIcon); |
| 92 } | 95 } |
| 93 } | 96 } |
| 94 #endif | 97 #endif |
| 95 } | 98 } |
| 96 | 99 |
| 100 void ReenableUpdates() { | |
| 101 google_update::ElevateIfNeededToReenableUpdates(); | |
| 102 } | |
| 103 | |
| 97 } // namespace | 104 } // namespace |
| 98 | 105 |
| 99 // OutdatedUpgradeBubbleView --------------------------------------------------- | 106 // OutdatedUpgradeBubbleView --------------------------------------------------- |
| 100 | 107 |
| 101 OutdatedUpgradeBubbleView* OutdatedUpgradeBubbleView::upgrade_bubble_ = NULL; | 108 OutdatedUpgradeBubbleView* OutdatedUpgradeBubbleView::upgrade_bubble_ = NULL; |
| 102 int OutdatedUpgradeBubbleView::num_ignored_bubbles_ = 0; | 109 int OutdatedUpgradeBubbleView::num_ignored_bubbles_ = 0; |
| 103 | 110 |
| 104 // static | 111 // static |
| 105 void OutdatedUpgradeBubbleView::ShowBubble(views::View* anchor_view, | 112 void OutdatedUpgradeBubbleView::ShowBubble(views::View* anchor_view, |
| 106 content::PageNavigator* navigator, | 113 content::PageNavigator* navigator, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 255 NEW_FOREGROUND_TAB, | 262 NEW_FOREGROUND_TAB, |
| 256 content::PAGE_TRANSITION_LINK, | 263 content::PAGE_TRANSITION_LINK, |
| 257 false)); | 264 false)); |
| 258 } else { | 265 } else { |
| 259 DCHECK(UpgradeDetector::GetInstance()->is_outdated_install_no_au()); | 266 DCHECK(UpgradeDetector::GetInstance()->is_outdated_install_no_au()); |
| 260 UMA_HISTOGRAM_CUSTOM_COUNTS( | 267 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 261 "OutdatedUpgradeBubble.NumLaterPerEnableAU", num_ignored_bubbles_, | 268 "OutdatedUpgradeBubble.NumLaterPerEnableAU", num_ignored_bubbles_, |
| 262 0, kMaxIgnored, kNumIgnoredBuckets); | 269 0, kMaxIgnored, kNumIgnoredBuckets); |
| 263 content::RecordAction( | 270 content::RecordAction( |
| 264 base::UserMetricsAction("OutdatedUpgradeBubble.EnableAU")); | 271 base::UserMetricsAction("OutdatedUpgradeBubble.EnableAU")); |
| 265 // TODO(robertshield): Make a call to GoogleUpdateSettings to enable | 272 // Record that the autoupdate flavour of the dialog has been shown. |
| 266 // auto-update. | |
| 267 if (g_browser_process->local_state()) { | 273 if (g_browser_process->local_state()) { |
| 268 g_browser_process->local_state()->SetBoolean( | 274 g_browser_process->local_state()->SetBoolean( |
| 269 prefs::kAttemptedToEnableAutoupdate, true); | 275 prefs::kAttemptedToEnableAutoupdate, true); |
| 270 } | 276 } |
| 277 | |
| 278 // Re-enable updates by shelling out to setup.exe on the file thread. | |
| 279 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | |
| 280 base::Bind(&ReenableUpdates)); | |
|
MAD
2014/03/28 18:18:23
You were not able to Bind directly to google_updat
robertshield
2014/03/28 19:15:35
Done.
| |
| 271 } | 281 } |
| 272 } else { | 282 } else { |
| 273 DCHECK_EQ(later_button_, sender); | 283 DCHECK_EQ(later_button_, sender); |
| 274 content::RecordAction( | 284 content::RecordAction( |
| 275 base::UserMetricsAction("OutdatedUpgradeBubble.Later")); | 285 base::UserMetricsAction("OutdatedUpgradeBubble.Later")); |
| 276 } | 286 } |
| 277 GetWidget()->Close(); | 287 GetWidget()->Close(); |
| 278 } | 288 } |
| OLD | NEW |