Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Unified Diff: content/public/test/web_contents_binding_set_test_binder.h

Issue 2752283004: Add the ability to override WebContentsBindingSet binders for testing (Closed)
Patch Set: . Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/browser/web_contents_binding_set.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/test/web_contents_binding_set_test_binder.h
diff --git a/content/public/test/web_contents_binding_set_test_binder.h b/content/public/test/web_contents_binding_set_test_binder.h
new file mode 100644
index 0000000000000000000000000000000000000000..755bbdae67890e39478a4de79b43f73a4a523db0
--- /dev/null
+++ b/content/public/test/web_contents_binding_set_test_binder.h
@@ -0,0 +1,34 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/browser/web_contents_binding_set.h"
+
+#include "mojo/public/cpp/bindings/associated_interface_request.h"
+
+namespace content {
+
+// Helper class which test code can use with
+// WebContentsImpl::OverrideBinderForTesting() in order to override
+// WebContentsBindingSet interface binding behavior in tests.
+template <typename Interface>
+class WebContentsBindingSetTestBinder : public WebContentsBindingSet::Binder {
+ public:
+ ~WebContentsBindingSetTestBinder() override {}
+
+ // Call for every new incoming interface request for a frame.
+ virtual void BindRequest(
+ RenderFrameHost* render_frame_host,
+ mojo::AssociatedInterfaceRequest<Interface> request) = 0;
+
+ private:
+ // Binder:
+ void OnRequestForFrame(RenderFrameHost* render_frame_host,
+ mojo::ScopedInterfaceEndpointHandle handle) override {
+ mojo::AssociatedInterfaceRequest<Interface> request;
+ request.Bind(std::move(handle));
+ BindRequest(render_frame_host, std::move(request));
+ }
+};
+
+} // namespace content
« no previous file with comments | « content/public/browser/web_contents_binding_set.cc ('k') | content/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698