| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return EventListener::ForURL(event_name, listener_url, process, | 86 return EventListener::ForURL(event_name, listener_url, process, |
| 87 base::WrapUnique(filter)); | 87 base::WrapUnique(filter)); |
| 88 } | 88 } |
| 89 | 89 |
| 90 // Creates an extension. If |component| is true, it is created as a component | 90 // Creates an extension. If |component| is true, it is created as a component |
| 91 // extension. If |persistent| is true, it is created with a persistent | 91 // extension. If |persistent| is true, it is created with a persistent |
| 92 // background page; otherwise it is created with an event page. | 92 // background page; otherwise it is created with an event page. |
| 93 scoped_refptr<Extension> CreateExtension(bool component, bool persistent) { | 93 scoped_refptr<Extension> CreateExtension(bool component, bool persistent) { |
| 94 ExtensionBuilder builder; | 94 ExtensionBuilder builder; |
| 95 std::unique_ptr<base::DictionaryValue> manifest = | 95 std::unique_ptr<base::DictionaryValue> manifest = |
| 96 base::WrapUnique(new base::DictionaryValue()); | 96 base::MakeUnique<base::DictionaryValue>(); |
| 97 manifest->SetString("name", "foo"); | 97 manifest->SetString("name", "foo"); |
| 98 manifest->SetString("version", "1.0.0"); | 98 manifest->SetString("version", "1.0.0"); |
| 99 manifest->SetInteger("manifest_version", 2); | 99 manifest->SetInteger("manifest_version", 2); |
| 100 manifest->SetString("background.page", "background.html"); | 100 manifest->SetString("background.page", "background.html"); |
| 101 manifest->SetBoolean("background.persistent", persistent); | 101 manifest->SetBoolean("background.persistent", persistent); |
| 102 builder.SetManifest(std::move(manifest)); | 102 builder.SetManifest(std::move(manifest)); |
| 103 if (component) | 103 if (component) |
| 104 builder.SetLocation(Manifest::Location::COMPONENT); | 104 builder.SetLocation(Manifest::Location::COMPONENT); |
| 105 | 105 |
| 106 return builder.Build(); | 106 return builder.Build(); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 scoped_refptr<Extension> component_event = CreateExtension(true, false); | 269 scoped_refptr<Extension> component_event = CreateExtension(true, false); |
| 270 router.ReportEvent(events::HistogramValue::FOR_TEST, component_event.get(), | 270 router.ReportEvent(events::HistogramValue::FOR_TEST, component_event.get(), |
| 271 false /** did_enqueue */); | 271 false /** did_enqueue */); |
| 272 ExpectHistogramCounts(6, 2, 2, 1, 0, 2); | 272 ExpectHistogramCounts(6, 2, 2, 1, 0, 2); |
| 273 router.ReportEvent(events::HistogramValue::FOR_TEST, component_event.get(), | 273 router.ReportEvent(events::HistogramValue::FOR_TEST, component_event.get(), |
| 274 true /** did_enqueue */); | 274 true /** did_enqueue */); |
| 275 ExpectHistogramCounts(7, 3, 2, 2, 1, 2); | 275 ExpectHistogramCounts(7, 3, 2, 2, 1, 2); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace extensions | 278 } // namespace extensions |
| OLD | NEW |