OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "extensions/browser/event_router.h" | 5 #include "extensions/browser/event_router.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "extensions/browser/extension_pref_value_map.h" | 24 #include "extensions/browser/extension_pref_value_map.h" |
25 #include "extensions/browser/extension_prefs.h" | 25 #include "extensions/browser/extension_prefs.h" |
26 #include "extensions/browser/extension_prefs_factory.h" | 26 #include "extensions/browser/extension_prefs_factory.h" |
27 #include "extensions/browser/extensions_test.h" | 27 #include "extensions/browser/extensions_test.h" |
28 #include "extensions/common/extension_builder.h" | 28 #include "extensions/common/extension_builder.h" |
29 #include "extensions/common/test_util.h" | 29 #include "extensions/common/test_util.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 | 31 |
32 using base::DictionaryValue; | 32 using base::DictionaryValue; |
33 using base::ListValue; | 33 using base::ListValue; |
34 using base::StringValue; | 34 using base::Value; |
35 | 35 |
36 namespace extensions { | 36 namespace extensions { |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 // A simple mock to keep track of listener additions and removals. | 40 // A simple mock to keep track of listener additions and removals. |
41 class MockEventRouterObserver : public EventRouter::Observer { | 41 class MockEventRouterObserver : public EventRouter::Observer { |
42 public: | 42 public: |
43 MockEventRouterObserver() | 43 MockEventRouterObserver() |
44 : listener_added_count_(0), | 44 : listener_added_count_(0), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 | 117 |
118 return builder.Build(); | 118 return builder.Build(); |
119 } | 119 } |
120 | 120 |
121 std::unique_ptr<DictionaryValue> CreateHostSuffixFilter( | 121 std::unique_ptr<DictionaryValue> CreateHostSuffixFilter( |
122 const std::string& suffix) { | 122 const std::string& suffix) { |
123 std::unique_ptr<DictionaryValue> filter(new DictionaryValue()); | 123 std::unique_ptr<DictionaryValue> filter(new DictionaryValue()); |
124 std::unique_ptr<ListValue> filter_list(new ListValue()); | 124 std::unique_ptr<ListValue> filter_list(new ListValue()); |
125 std::unique_ptr<DictionaryValue> filter_dict(new DictionaryValue()); | 125 std::unique_ptr<DictionaryValue> filter_dict(new DictionaryValue()); |
126 | 126 |
127 filter_dict->Set("hostSuffix", base::MakeUnique<StringValue>(suffix)); | 127 filter_dict->Set("hostSuffix", base::MakeUnique<Value>(suffix)); |
128 filter_list->Append(std::move(filter_dict)); | 128 filter_list->Append(std::move(filter_dict)); |
129 filter->Set("url", std::move(filter_list)); | 129 filter->Set("url", std::move(filter_list)); |
130 | 130 |
131 return filter; | 131 return filter; |
132 } | 132 } |
133 | 133 |
134 } // namespace | 134 } // namespace |
135 | 135 |
136 class EventRouterTest : public ExtensionsTest { | 136 class EventRouterTest : public ExtensionsTest { |
137 public: | 137 public: |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 // Remove the third filter. | 441 // Remove the third filter. |
442 event_router()->RemoveFilteredEventListener(kEventName, render_process_host(), | 442 event_router()->RemoveFilteredEventListener(kEventName, render_process_host(), |
443 kExtensionId, *filters[2], true); | 443 kExtensionId, *filters[2], true); |
444 ASSERT_FALSE(ContainsFilter(kExtensionId, kEventName, *filters[0])); | 444 ASSERT_FALSE(ContainsFilter(kExtensionId, kEventName, *filters[0])); |
445 ASSERT_FALSE(ContainsFilter(kExtensionId, kEventName, *filters[1])); | 445 ASSERT_FALSE(ContainsFilter(kExtensionId, kEventName, *filters[1])); |
446 ASSERT_FALSE(ContainsFilter(kExtensionId, kEventName, *filters[2])); | 446 ASSERT_FALSE(ContainsFilter(kExtensionId, kEventName, *filters[2])); |
447 } | 447 } |
448 | 448 |
449 } // namespace extensions | 449 } // namespace extensions |
OLD | NEW |