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