| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/dev_mode_bubble_controller.h" | 10 #include "chrome/browser/extensions/dev_mode_bubble_controller.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 // A test class for the SuspiciousExtensionBubbleController. | 73 // A test class for the SuspiciousExtensionBubbleController. |
| 74 class TestSuspiciousExtensionBubbleController | 74 class TestSuspiciousExtensionBubbleController |
| 75 : public SuspiciousExtensionBubbleController, | 75 : public SuspiciousExtensionBubbleController, |
| 76 public TestDelegate { | 76 public TestDelegate { |
| 77 public: | 77 public: |
| 78 explicit TestSuspiciousExtensionBubbleController(Profile* profile) | 78 explicit TestSuspiciousExtensionBubbleController(Profile* profile) |
| 79 : SuspiciousExtensionBubbleController(profile) { | 79 : SuspiciousExtensionBubbleController(profile) { |
| 80 } | 80 } |
| 81 | 81 |
| 82 virtual void OnBubbleAction() override { | 82 void OnBubbleAction() override { |
| 83 ++action_button_callback_count_; | 83 ++action_button_callback_count_; |
| 84 SuspiciousExtensionBubbleController::OnBubbleAction(); | 84 SuspiciousExtensionBubbleController::OnBubbleAction(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual void OnBubbleDismiss() override { | 87 void OnBubbleDismiss() override { |
| 88 ++dismiss_button_callback_count_; | 88 ++dismiss_button_callback_count_; |
| 89 SuspiciousExtensionBubbleController::OnBubbleDismiss(); | 89 SuspiciousExtensionBubbleController::OnBubbleDismiss(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 virtual void OnLinkClicked() override { | 92 void OnLinkClicked() override { |
| 93 ++link_click_callback_count_; | 93 ++link_click_callback_count_; |
| 94 SuspiciousExtensionBubbleController::OnLinkClicked(); | 94 SuspiciousExtensionBubbleController::OnLinkClicked(); |
| 95 } | 95 } |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 // A test class for the DevModeBubbleController. | 98 // A test class for the DevModeBubbleController. |
| 99 class TestDevModeBubbleController | 99 class TestDevModeBubbleController |
| 100 : public DevModeBubbleController, | 100 : public DevModeBubbleController, |
| 101 public TestDelegate { | 101 public TestDelegate { |
| 102 public: | 102 public: |
| 103 explicit TestDevModeBubbleController(Profile* profile) | 103 explicit TestDevModeBubbleController(Profile* profile) |
| 104 : DevModeBubbleController(profile) { | 104 : DevModeBubbleController(profile) { |
| 105 } | 105 } |
| 106 | 106 |
| 107 virtual void OnBubbleAction() override { | 107 void OnBubbleAction() override { |
| 108 ++action_button_callback_count_; | 108 ++action_button_callback_count_; |
| 109 DevModeBubbleController::OnBubbleAction(); | 109 DevModeBubbleController::OnBubbleAction(); |
| 110 } | 110 } |
| 111 | 111 |
| 112 virtual void OnBubbleDismiss() override { | 112 void OnBubbleDismiss() override { |
| 113 ++dismiss_button_callback_count_; | 113 ++dismiss_button_callback_count_; |
| 114 DevModeBubbleController::OnBubbleDismiss(); | 114 DevModeBubbleController::OnBubbleDismiss(); |
| 115 } | 115 } |
| 116 | 116 |
| 117 virtual void OnLinkClicked() override { | 117 void OnLinkClicked() override { |
| 118 ++link_click_callback_count_; | 118 ++link_click_callback_count_; |
| 119 DevModeBubbleController::OnLinkClicked(); | 119 DevModeBubbleController::OnLinkClicked(); |
| 120 } | 120 } |
| 121 }; | 121 }; |
| 122 | 122 |
| 123 // A test class for the SettingsApiBubbleController. | 123 // A test class for the SettingsApiBubbleController. |
| 124 class TestSettingsApiBubbleController : public SettingsApiBubbleController, | 124 class TestSettingsApiBubbleController : public SettingsApiBubbleController, |
| 125 public TestDelegate { | 125 public TestDelegate { |
| 126 public: | 126 public: |
| 127 TestSettingsApiBubbleController(Profile* profile, | 127 TestSettingsApiBubbleController(Profile* profile, |
| 128 SettingsApiOverrideType type) | 128 SettingsApiOverrideType type) |
| 129 : SettingsApiBubbleController(profile, type) {} | 129 : SettingsApiBubbleController(profile, type) {} |
| 130 | 130 |
| 131 virtual void OnBubbleAction() override { | 131 void OnBubbleAction() override { |
| 132 ++action_button_callback_count_; | 132 ++action_button_callback_count_; |
| 133 SettingsApiBubbleController::OnBubbleAction(); | 133 SettingsApiBubbleController::OnBubbleAction(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 virtual void OnBubbleDismiss() override { | 136 void OnBubbleDismiss() override { |
| 137 ++dismiss_button_callback_count_; | 137 ++dismiss_button_callback_count_; |
| 138 SettingsApiBubbleController::OnBubbleDismiss(); | 138 SettingsApiBubbleController::OnBubbleDismiss(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 virtual void OnLinkClicked() override { | 141 void OnLinkClicked() override { |
| 142 ++link_click_callback_count_; | 142 ++link_click_callback_count_; |
| 143 SettingsApiBubbleController::OnLinkClicked(); | 143 SettingsApiBubbleController::OnLinkClicked(); |
| 144 } | 144 } |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 // A test class for the NtpOverriddenBubbleController. | 147 // A test class for the NtpOverriddenBubbleController. |
| 148 class TestNtpOverriddenBubbleController | 148 class TestNtpOverriddenBubbleController |
| 149 : public NtpOverriddenBubbleController, | 149 : public NtpOverriddenBubbleController, |
| 150 public TestDelegate { | 150 public TestDelegate { |
| 151 public: | 151 public: |
| 152 explicit TestNtpOverriddenBubbleController(Profile* profile) | 152 explicit TestNtpOverriddenBubbleController(Profile* profile) |
| 153 : NtpOverriddenBubbleController(profile) { | 153 : NtpOverriddenBubbleController(profile) { |
| 154 } | 154 } |
| 155 | 155 |
| 156 virtual void OnBubbleAction() override { | 156 void OnBubbleAction() override { |
| 157 ++action_button_callback_count_; | 157 ++action_button_callback_count_; |
| 158 NtpOverriddenBubbleController::OnBubbleAction(); | 158 NtpOverriddenBubbleController::OnBubbleAction(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 virtual void OnBubbleDismiss() override { | 161 void OnBubbleDismiss() override { |
| 162 ++dismiss_button_callback_count_; | 162 ++dismiss_button_callback_count_; |
| 163 NtpOverriddenBubbleController::OnBubbleDismiss(); | 163 NtpOverriddenBubbleController::OnBubbleDismiss(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 virtual void OnLinkClicked() override { | 166 void OnLinkClicked() override { |
| 167 ++link_click_callback_count_; | 167 ++link_click_callback_count_; |
| 168 NtpOverriddenBubbleController::OnLinkClicked(); | 168 NtpOverriddenBubbleController::OnLinkClicked(); |
| 169 } | 169 } |
| 170 }; | 170 }; |
| 171 | 171 |
| 172 // A test class for the ProxyOverriddenBubbleController. | 172 // A test class for the ProxyOverriddenBubbleController. |
| 173 class TestProxyOverriddenBubbleController | 173 class TestProxyOverriddenBubbleController |
| 174 : public ProxyOverriddenBubbleController, | 174 : public ProxyOverriddenBubbleController, |
| 175 public TestDelegate { | 175 public TestDelegate { |
| 176 public: | 176 public: |
| 177 explicit TestProxyOverriddenBubbleController(Profile* profile) | 177 explicit TestProxyOverriddenBubbleController(Profile* profile) |
| 178 : ProxyOverriddenBubbleController(profile) { | 178 : ProxyOverriddenBubbleController(profile) { |
| 179 } | 179 } |
| 180 | 180 |
| 181 virtual void OnBubbleAction() override { | 181 void OnBubbleAction() override { |
| 182 ++action_button_callback_count_; | 182 ++action_button_callback_count_; |
| 183 ProxyOverriddenBubbleController::OnBubbleAction(); | 183 ProxyOverriddenBubbleController::OnBubbleAction(); |
| 184 } | 184 } |
| 185 | 185 |
| 186 virtual void OnBubbleDismiss() override { | 186 void OnBubbleDismiss() override { |
| 187 ++dismiss_button_callback_count_; | 187 ++dismiss_button_callback_count_; |
| 188 ProxyOverriddenBubbleController::OnBubbleDismiss(); | 188 ProxyOverriddenBubbleController::OnBubbleDismiss(); |
| 189 } | 189 } |
| 190 | 190 |
| 191 virtual void OnLinkClicked() override { | 191 void OnLinkClicked() override { |
| 192 ++link_click_callback_count_; | 192 ++link_click_callback_count_; |
| 193 ProxyOverriddenBubbleController::OnLinkClicked(); | 193 ProxyOverriddenBubbleController::OnLinkClicked(); |
| 194 } | 194 } |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 // A fake bubble used for testing the controller. Takes an action that specifies | 197 // A fake bubble used for testing the controller. Takes an action that specifies |
| 198 // what should happen when the bubble is "shown" (the bubble is actually not | 198 // what should happen when the bubble is "shown" (the bubble is actually not |
| 199 // shown, the corresponding action is taken immediately). | 199 // shown, the corresponding action is taken immediately). |
| 200 class FakeExtensionMessageBubble : public ExtensionMessageBubble { | 200 class FakeExtensionMessageBubble : public ExtensionMessageBubble { |
| 201 public: | 201 public: |
| 202 enum ExtensionBubbleAction { | 202 enum ExtensionBubbleAction { |
| 203 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0, | 203 BUBBLE_ACTION_CLICK_ACTION_BUTTON = 0, |
| 204 BUBBLE_ACTION_CLICK_DISMISS_BUTTON, | 204 BUBBLE_ACTION_CLICK_DISMISS_BUTTON, |
| 205 BUBBLE_ACTION_CLICK_LINK, | 205 BUBBLE_ACTION_CLICK_LINK, |
| 206 }; | 206 }; |
| 207 | 207 |
| 208 FakeExtensionMessageBubble() {} | 208 FakeExtensionMessageBubble() {} |
| 209 | 209 |
| 210 void set_action_on_show(ExtensionBubbleAction action) { | 210 void set_action_on_show(ExtensionBubbleAction action) { |
| 211 action_ = action; | 211 action_ = action; |
| 212 } | 212 } |
| 213 | 213 |
| 214 virtual void Show() override { | 214 void Show() override { |
| 215 if (action_ == BUBBLE_ACTION_CLICK_ACTION_BUTTON) | 215 if (action_ == BUBBLE_ACTION_CLICK_ACTION_BUTTON) |
| 216 action_callback_.Run(); | 216 action_callback_.Run(); |
| 217 else if (action_ == BUBBLE_ACTION_CLICK_DISMISS_BUTTON) | 217 else if (action_ == BUBBLE_ACTION_CLICK_DISMISS_BUTTON) |
| 218 dismiss_callback_.Run(); | 218 dismiss_callback_.Run(); |
| 219 else if (action_ == BUBBLE_ACTION_CLICK_LINK) | 219 else if (action_ == BUBBLE_ACTION_CLICK_LINK) |
| 220 link_callback_.Run(); | 220 link_callback_.Run(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 virtual void OnActionButtonClicked(const base::Closure& callback) override { | 223 void OnActionButtonClicked(const base::Closure& callback) override { |
| 224 action_callback_ = callback; | 224 action_callback_ = callback; |
| 225 } | 225 } |
| 226 | 226 |
| 227 virtual void OnDismissButtonClicked(const base::Closure& callback) override { | 227 void OnDismissButtonClicked(const base::Closure& callback) override { |
| 228 dismiss_callback_ = callback; | 228 dismiss_callback_ = callback; |
| 229 } | 229 } |
| 230 | 230 |
| 231 virtual void OnLinkClicked(const base::Closure& callback) override { | 231 void OnLinkClicked(const base::Closure& callback) override { |
| 232 link_callback_ = callback; | 232 link_callback_ = callback; |
| 233 } | 233 } |
| 234 | 234 |
| 235 private: | 235 private: |
| 236 ExtensionBubbleAction action_; | 236 ExtensionBubbleAction action_; |
| 237 | 237 |
| 238 base::Closure action_callback_; | 238 base::Closure action_callback_; |
| 239 base::Closure dismiss_callback_; | 239 base::Closure dismiss_callback_; |
| 240 base::Closure link_callback_; | 240 base::Closure link_callback_; |
| 241 }; | 241 }; |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 extensions::UNINSTALL_REASON_FOR_TESTING, | 964 extensions::UNINSTALL_REASON_FOR_TESTING, |
| 965 base::Bind(&base::DoNothing), | 965 base::Bind(&base::DoNothing), |
| 966 NULL); | 966 NULL); |
| 967 service_->UninstallExtension(kId3, | 967 service_->UninstallExtension(kId3, |
| 968 extensions::UNINSTALL_REASON_FOR_TESTING, | 968 extensions::UNINSTALL_REASON_FOR_TESTING, |
| 969 base::Bind(&base::DoNothing), | 969 base::Bind(&base::DoNothing), |
| 970 NULL); | 970 NULL); |
| 971 } | 971 } |
| 972 | 972 |
| 973 } // namespace extensions | 973 } // namespace extensions |
| OLD | NEW |