| 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/conflicting_module_view_win.h" | 5 #include "chrome/browser/ui/views/conflicting_module_view_win.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/layout_constants.h" | 11 #include "chrome/browser/ui/layout_constants.h" |
| 12 #include "chrome/browser/win/enumerate_modules_model.h" | |
| 13 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/grit/chromium_strings.h" | 13 #include "chrome/grit/chromium_strings.h" |
| 15 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 16 #include "chrome/grit/locale_settings.h" | 15 #include "chrome/grit/locale_settings.h" |
| 17 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/user_metrics.h" | 17 #include "content/public/browser/user_metrics.h" |
| 19 #include "grit/theme_resources.h" | 18 #include "grit/theme_resources.h" |
| 20 #include "ui/accessibility/ax_view_state.h" | 19 #include "ui/accessibility/ax_view_state.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 43 const GURL& help_center_url) | 42 const GURL& help_center_url) |
| 44 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 43 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
| 45 browser_(browser), | 44 browser_(browser), |
| 46 help_center_url_(help_center_url) { | 45 help_center_url_(help_center_url) { |
| 47 set_close_on_deactivate(false); | 46 set_close_on_deactivate(false); |
| 48 | 47 |
| 49 // Compensate for built-in vertical padding in the anchor view's image. | 48 // Compensate for built-in vertical padding in the anchor view's image. |
| 50 set_anchor_view_insets(gfx::Insets( | 49 set_anchor_view_insets(gfx::Insets( |
| 51 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 50 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
| 52 | 51 |
| 53 registrar_.Add(this, chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_ICON_CHANGE, | 52 // Register for notifications about conflicting modules. |
| 54 content::NotificationService::AllSources()); | 53 EnumerateModulesModel::GetInstance()->AddObserver(this); |
| 55 } | 54 } |
| 56 | 55 |
| 57 // static | 56 // static |
| 58 void ConflictingModuleView::MaybeShow(Browser* browser, | 57 void ConflictingModuleView::MaybeShow(Browser* browser, |
| 59 views::View* anchor_view) { | 58 views::View* anchor_view) { |
| 60 static bool done_checking = false; | 59 static bool done_checking = false; |
| 61 if (done_checking) | 60 if (done_checking) |
| 62 return; // Only show the bubble once per launch. | 61 return; // Only show the bubble once per launch. |
| 63 | 62 |
| 64 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); | 63 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); |
| 65 GURL url = model->GetFirstNotableConflict(); | 64 GURL url = model->GetConflictUrl(); |
| 66 if (!url.is_valid()) { | 65 if (!url.is_valid()) { |
| 67 done_checking = true; | 66 done_checking = true; |
| 68 return; | 67 return; |
| 69 } | 68 } |
| 70 | 69 |
| 71 // A pref that counts how often the Sideload Wipeout bubble has been shown. | 70 // A pref that counts how often the Sideload Wipeout bubble has been shown. |
| 72 IntegerPrefMember bubble_shown; | 71 IntegerPrefMember bubble_shown; |
| 73 bubble_shown.Init(prefs::kModuleConflictBubbleShown, | 72 bubble_shown.Init(prefs::kModuleConflictBubbleShown, |
| 74 browser->profile()->GetPrefs()); | 73 browser->profile()->GetPrefs()); |
| 75 if (bubble_shown.GetValue() >= kShowConflictingModuleBubbleMax) { | 74 if (bubble_shown.GetValue() >= kShowConflictingModuleBubbleMax) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 89 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate); | 88 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate); |
| 90 bubble_delegate->ShowBubble(); | 89 bubble_delegate->ShowBubble(); |
| 91 | 90 |
| 92 done_checking = true; | 91 done_checking = true; |
| 93 } | 92 } |
| 94 | 93 |
| 95 //////////////////////////////////////////////////////////////////////////////// | 94 //////////////////////////////////////////////////////////////////////////////// |
| 96 // ConflictingModuleView - private. | 95 // ConflictingModuleView - private. |
| 97 | 96 |
| 98 ConflictingModuleView::~ConflictingModuleView() { | 97 ConflictingModuleView::~ConflictingModuleView() { |
| 98 EnumerateModulesModel::GetInstance()->RemoveObserver(this); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void ConflictingModuleView::ShowBubble() { | 101 void ConflictingModuleView::ShowBubble() { |
| 102 GetWidget()->Show(); | 102 GetWidget()->Show(); |
| 103 | 103 |
| 104 IntegerPrefMember bubble_shown; | 104 IntegerPrefMember bubble_shown; |
| 105 bubble_shown.Init( | 105 bubble_shown.Init( |
| 106 prefs::kModuleConflictBubbleShown, | 106 prefs::kModuleConflictBubbleShown, |
| 107 browser_->profile()->GetPrefs()); | 107 browser_->profile()->GetPrefs()); |
| 108 bubble_shown.SetValue(bubble_shown.GetValue() + 1); | 108 bubble_shown.SetValue(bubble_shown.GetValue() + 1); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 UMA_HISTOGRAM_ENUMERATION("ConflictingModule.UserSelection", | 155 UMA_HISTOGRAM_ENUMERATION("ConflictingModule.UserSelection", |
| 156 EnumerateModulesModel::ACTION_BUBBLE_SHOWN, | 156 EnumerateModulesModel::ACTION_BUBBLE_SHOWN, |
| 157 EnumerateModulesModel::ACTION_BOUNDARY); | 157 EnumerateModulesModel::ACTION_BOUNDARY); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void ConflictingModuleView::GetAccessibleState( | 160 void ConflictingModuleView::GetAccessibleState( |
| 161 ui::AXViewState* state) { | 161 ui::AXViewState* state) { |
| 162 state->role = ui::AX_ROLE_ALERT_DIALOG; | 162 state->role = ui::AX_ROLE_ALERT_DIALOG; |
| 163 } | 163 } |
| 164 | 164 |
| 165 void ConflictingModuleView::Observe( | 165 void ConflictingModuleView::OnConflictsAcknowledged() { |
| 166 int type, | |
| 167 const content::NotificationSource& source, | |
| 168 const content::NotificationDetails& details) { | |
| 169 DCHECK_EQ(chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_ICON_CHANGE, type); | |
| 170 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); | 166 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); |
| 171 if (!model->ShouldShowConflictWarning()) | 167 if (!model->ShouldShowConflictWarning()) |
| 172 GetWidget()->Close(); | 168 GetWidget()->Close(); |
| 173 } | 169 } |
| OLD | NEW |