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/enumerate_modules_model_win.h" | 9 #include "chrome/browser/enumerate_modules_model_win.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const GURL& help_center_url) | 43 const GURL& help_center_url) |
44 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 44 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
45 browser_(browser), | 45 browser_(browser), |
46 help_center_url_(help_center_url) { | 46 help_center_url_(help_center_url) { |
47 set_close_on_deactivate(false); | 47 set_close_on_deactivate(false); |
48 | 48 |
49 // 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. |
50 set_anchor_view_insets(gfx::Insets( | 50 set_anchor_view_insets(gfx::Insets( |
51 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); | 51 GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0)); |
52 | 52 |
53 registrar_.Add(this, chrome::NOTIFICATION_MODULE_INCOMPATIBILITY_ICON_CHANGE, | 53 // Register for notifications about conflicting modules. |
54 content::NotificationService::AllSources()); | 54 EnumerateModulesModel::GetInstance()->AddObserver(this); |
55 } | 55 } |
56 | 56 |
57 // static | 57 // static |
58 void ConflictingModuleView::MaybeShow(Browser* browser, | 58 void ConflictingModuleView::MaybeShow(Browser* browser, |
59 views::View* anchor_view) { | 59 views::View* anchor_view) { |
60 static bool done_checking = false; | 60 static bool done_checking = false; |
61 if (done_checking) | 61 if (done_checking) |
62 return; // Only show the bubble once per launch. | 62 return; // Only show the bubble once per launch. |
63 | 63 |
64 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); | 64 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); |
65 GURL url = model->GetFirstNotableConflict(); | 65 GURL url = model->GetConflictUrl(); |
66 if (!url.is_valid()) { | 66 if (!url.is_valid()) { |
67 done_checking = true; | 67 done_checking = true; |
68 return; | 68 return; |
69 } | 69 } |
70 | 70 |
71 // 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. |
72 IntegerPrefMember bubble_shown; | 72 IntegerPrefMember bubble_shown; |
73 bubble_shown.Init(prefs::kModuleConflictBubbleShown, | 73 bubble_shown.Init(prefs::kModuleConflictBubbleShown, |
74 browser->profile()->GetPrefs()); | 74 browser->profile()->GetPrefs()); |
75 if (bubble_shown.GetValue() >= kShowConflictingModuleBubbleMax) { | 75 if (bubble_shown.GetValue() >= kShowConflictingModuleBubbleMax) { |
(...skipping 13 matching lines...) Expand all Loading... |
89 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate); | 89 views::BubbleDialogDelegateView::CreateBubble(bubble_delegate); |
90 bubble_delegate->ShowBubble(); | 90 bubble_delegate->ShowBubble(); |
91 | 91 |
92 done_checking = true; | 92 done_checking = true; |
93 } | 93 } |
94 | 94 |
95 //////////////////////////////////////////////////////////////////////////////// | 95 //////////////////////////////////////////////////////////////////////////////// |
96 // ConflictingModuleView - private. | 96 // ConflictingModuleView - private. |
97 | 97 |
98 ConflictingModuleView::~ConflictingModuleView() { | 98 ConflictingModuleView::~ConflictingModuleView() { |
| 99 EnumerateModulesModel::GetInstance()->RemoveObserver(this); |
99 } | 100 } |
100 | 101 |
101 void ConflictingModuleView::ShowBubble() { | 102 void ConflictingModuleView::ShowBubble() { |
102 GetWidget()->Show(); | 103 GetWidget()->Show(); |
103 | 104 |
104 IntegerPrefMember bubble_shown; | 105 IntegerPrefMember bubble_shown; |
105 bubble_shown.Init( | 106 bubble_shown.Init( |
106 prefs::kModuleConflictBubbleShown, | 107 prefs::kModuleConflictBubbleShown, |
107 browser_->profile()->GetPrefs()); | 108 browser_->profile()->GetPrefs()); |
108 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... |
155 UMA_HISTOGRAM_ENUMERATION("ConflictingModule.UserSelection", | 156 UMA_HISTOGRAM_ENUMERATION("ConflictingModule.UserSelection", |
156 EnumerateModulesModel::ACTION_BUBBLE_SHOWN, | 157 EnumerateModulesModel::ACTION_BUBBLE_SHOWN, |
157 EnumerateModulesModel::ACTION_BOUNDARY); | 158 EnumerateModulesModel::ACTION_BOUNDARY); |
158 } | 159 } |
159 | 160 |
160 void ConflictingModuleView::GetAccessibleState( | 161 void ConflictingModuleView::GetAccessibleState( |
161 ui::AXViewState* state) { | 162 ui::AXViewState* state) { |
162 state->role = ui::AX_ROLE_ALERT_DIALOG; | 163 state->role = ui::AX_ROLE_ALERT_DIALOG; |
163 } | 164 } |
164 | 165 |
165 void ConflictingModuleView::Observe( | 166 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(); | 167 EnumerateModulesModel* model = EnumerateModulesModel::GetInstance(); |
171 if (!model->ShouldShowConflictWarning()) | 168 if (!model->ShouldShowConflictWarning()) |
172 GetWidget()->Close(); | 169 GetWidget()->Close(); |
173 } | 170 } |
OLD | NEW |