OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "chrome/browser/extensions/extension_error_controller.h" | 6 #include "chrome/browser/extensions/extension_error_controller.h" |
7 #include "chrome/browser/extensions/extension_error_ui.h" | 7 #include "chrome/browser/extensions/extension_error_ui.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_service_test_base.h" | 9 #include "chrome/browser/extensions/extension_service_test_base.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
12 #include "extensions/browser/extension_prefs.h" | 12 #include "extensions/browser/extension_prefs.h" |
13 #include "extensions/browser/extension_registry.h" | 13 #include "extensions/browser/extension_registry.h" |
14 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
15 #include "extensions/common/extension_builder.h" | 15 #include "extensions/common/extension_builder.h" |
16 #include "extensions/common/value_builder.h" | 16 #include "extensions/common/value_builder.h" |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 // Create a mock for the UI component of the error alert that is shown for | 22 // Create a mock for the UI component of the error alert that is shown for |
23 // blacklisted extensions. This allows us to test which extensions the alert | 23 // blacklisted extensions. This allows us to test which extensions the alert |
24 // is showing, and also eliminates the UI component (since this is a unit | 24 // is showing, and also eliminates the UI component (since this is a unit |
25 // test). | 25 // test). |
26 class MockExtensionErrorUI : public ExtensionErrorUI { | 26 class MockExtensionErrorUI : public ExtensionErrorUI { |
27 public: | 27 public: |
28 explicit MockExtensionErrorUI(ExtensionErrorUI::Delegate* delegate); | 28 explicit MockExtensionErrorUI(ExtensionErrorUI::Delegate* delegate); |
29 virtual ~MockExtensionErrorUI(); | 29 ~MockExtensionErrorUI() override; |
30 | 30 |
31 // Wrappers around the similar methods in ExtensionErrorUI. | 31 // Wrappers around the similar methods in ExtensionErrorUI. |
32 void CloseUI(); | 32 void CloseUI(); |
33 void Accept(); | 33 void Accept(); |
34 void Details(); | 34 void Details(); |
35 | 35 |
36 ExtensionErrorUI::Delegate* delegate() { return delegate_; } | 36 ExtensionErrorUI::Delegate* delegate() { return delegate_; } |
37 | 37 |
38 private: | 38 private: |
39 // ExtensionErrorUI implementation. | 39 // ExtensionErrorUI implementation. |
40 virtual bool ShowErrorInBubbleView() override; | 40 bool ShowErrorInBubbleView() override; |
41 virtual void ShowExtensions() override; | 41 void ShowExtensions() override; |
42 virtual void Close() override; | 42 void Close() override; |
43 | 43 |
44 // Keep a copy of the delegate around for ourselves. | 44 // Keep a copy of the delegate around for ourselves. |
45 ExtensionErrorUI::Delegate* delegate_; | 45 ExtensionErrorUI::Delegate* delegate_; |
46 }; | 46 }; |
47 | 47 |
48 // We use this as a slight hack to get the created Error UI, if any. We should | 48 // We use this as a slight hack to get the created Error UI, if any. We should |
49 // only ever have one (since this is a single-profile test), and this avoids | 49 // only ever have one (since this is a single-profile test), and this avoids |
50 // the need for any kind of accessor to the ErrorController from | 50 // the need for any kind of accessor to the ErrorController from |
51 // ExtensionService. | 51 // ExtensionService. |
52 MockExtensionErrorUI* g_error_ui = NULL; | 52 MockExtensionErrorUI* g_error_ui = NULL; |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 GetPrefs()->AcknowledgeBlacklistedExtension(extension->id()); | 205 GetPrefs()->AcknowledgeBlacklistedExtension(extension->id()); |
206 | 206 |
207 service_->Init(); | 207 service_->Init(); |
208 | 208 |
209 // We should never have made an alert, because the extension should already | 209 // We should never have made an alert, because the extension should already |
210 // be acknowledged. | 210 // be acknowledged. |
211 ASSERT_FALSE(g_error_ui); | 211 ASSERT_FALSE(g_error_ui); |
212 } | 212 } |
213 | 213 |
214 } // namespace extensions | 214 } // namespace extensions |
OLD | NEW |