| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "mojo/common/weak_binding_set.h" | 11 #include "mojo/common/weak_binding_set.h" |
| 12 #include "mojo/shell/capability_filter_test.h" | 12 #include "mojo/shell/capability_filter_test.h" |
| 13 #include "mojo/shell/fetcher.h" | 13 #include "mojo/shell/fetcher.h" |
| 14 #include "mojo/shell/package_manager/package_manager_impl.h" | 14 #include "mojo/shell/package_manager/package_manager_impl.h" |
| 15 #include "mojo/shell/public/cpp/application_connection.h" | |
| 16 #include "mojo/shell/public/cpp/application_delegate.h" | |
| 17 #include "mojo/shell/public/cpp/application_impl.h" | 15 #include "mojo/shell/public/cpp/application_impl.h" |
| 18 #include "mojo/shell/public/cpp/interface_factory.h" | 16 #include "mojo/shell/public/cpp/interface_factory.h" |
| 17 #include "mojo/shell/public/cpp/shell_client.h" |
| 19 #include "mojo/shell/public/interfaces/content_handler.mojom.h" | 18 #include "mojo/shell/public/interfaces/content_handler.mojom.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 20 |
| 22 namespace mojo { | 21 namespace mojo { |
| 23 namespace shell { | 22 namespace shell { |
| 24 namespace test { | 23 namespace test { |
| 25 namespace { | 24 namespace { |
| 26 | 25 |
| 27 const char kTestMimeType[] = "test/mime-type"; | 26 const char kTestMimeType[] = "test/mime-type"; |
| 28 | 27 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 // Overridden from PackageManagerImpl: | 69 // Overridden from PackageManagerImpl: |
| 71 void FetchRequest( | 70 void FetchRequest( |
| 72 URLRequestPtr request, | 71 URLRequestPtr request, |
| 73 const Fetcher::FetchCallback& loader_callback) override { | 72 const Fetcher::FetchCallback& loader_callback) override { |
| 74 new TestFetcher(GURL(request->url.get()), loader_callback); | 73 new TestFetcher(GURL(request->url.get()), loader_callback); |
| 75 } | 74 } |
| 76 | 75 |
| 77 DISALLOW_COPY_AND_ASSIGN(TestPackageManager); | 76 DISALLOW_COPY_AND_ASSIGN(TestPackageManager); |
| 78 }; | 77 }; |
| 79 | 78 |
| 80 class TestContentHandler : public ApplicationDelegate, | 79 class TestContentHandler : public ShellClient, |
| 81 public InterfaceFactory<mojom::ContentHandler>, | 80 public InterfaceFactory<mojom::ContentHandler>, |
| 82 public mojom::ContentHandler { | 81 public mojom::ContentHandler { |
| 83 public: | 82 public: |
| 84 TestContentHandler() {} | 83 TestContentHandler() {} |
| 85 ~TestContentHandler() override {} | 84 ~TestContentHandler() override {} |
| 86 | 85 |
| 87 private: | 86 private: |
| 88 // Overridden from ApplicationDelegate: | 87 // Overridden from ShellClient: |
| 89 void Initialize(Shell* shell, const std::string& url, uint32_t id) override {} | 88 void Initialize(Shell* shell, const std::string& url, uint32_t id) override {} |
| 90 bool AcceptConnection(ApplicationConnection* connection) override { | 89 bool AcceptConnection(Connection* connection) override { |
| 91 connection->AddService<mojom::ContentHandler>(this); | 90 connection->AddService<mojom::ContentHandler>(this); |
| 92 return true; | 91 return true; |
| 93 } | 92 } |
| 94 | 93 |
| 95 // Overridden from InterfaceFactory<mojom::ContentHandler>: | 94 // Overridden from InterfaceFactory<mojom::ContentHandler>: |
| 96 void Create(ApplicationConnection* connection, | 95 void Create(Connection* connection, |
| 97 InterfaceRequest<mojom::ContentHandler> request) override { | 96 InterfaceRequest<mojom::ContentHandler> request) override { |
| 98 bindings_.AddBinding(this, std::move(request)); | 97 bindings_.AddBinding(this, std::move(request)); |
| 99 } | 98 } |
| 100 | 99 |
| 101 // Overridden from mojom::ContentHandler: | 100 // Overridden from mojom::ContentHandler: |
| 102 void StartApplication( | 101 void StartApplication( |
| 103 InterfaceRequest<mojom::Application> application, | 102 InterfaceRequest<mojom::Application> application, |
| 104 URLResponsePtr response, | 103 URLResponsePtr response, |
| 105 const Callback<void()>& destruct_callback) override { | 104 const Callback<void()>& destruct_callback) override { |
| 106 scoped_ptr<ApplicationDelegate> delegate(new test::TestApplication); | 105 scoped_ptr<ShellClient> delegate(new test::TestApplication); |
| 107 embedded_apps_.push_back( | 106 embedded_apps_.push_back( |
| 108 new ApplicationImpl(delegate.get(), std::move(application))); | 107 new ApplicationImpl(delegate.get(), std::move(application))); |
| 109 embedded_app_delegates_.push_back(std::move(delegate)); | 108 embedded_app_delegates_.push_back(std::move(delegate)); |
| 110 destruct_callback.Run(); | 109 destruct_callback.Run(); |
| 111 } | 110 } |
| 112 | 111 |
| 113 WeakBindingSet<mojom::ContentHandler> bindings_; | 112 WeakBindingSet<mojom::ContentHandler> bindings_; |
| 114 ScopedVector<ApplicationDelegate> embedded_app_delegates_; | 113 ScopedVector<ShellClient> embedded_app_delegates_; |
| 115 ScopedVector<ApplicationImpl> embedded_apps_; | 114 ScopedVector<ApplicationImpl> embedded_apps_; |
| 116 | 115 |
| 117 DISALLOW_COPY_AND_ASSIGN(TestContentHandler); | 116 DISALLOW_COPY_AND_ASSIGN(TestContentHandler); |
| 118 }; | 117 }; |
| 119 | 118 |
| 120 } // namespace | 119 } // namespace |
| 121 | 120 |
| 122 class CapabilityFilterContentHandlerTest : public test::CapabilityFilterTest { | 121 class CapabilityFilterContentHandlerTest : public test::CapabilityFilterTest { |
| 123 public: | 122 public: |
| 124 CapabilityFilterContentHandlerTest() | 123 CapabilityFilterContentHandlerTest() |
| (...skipping 28 matching lines...) Expand all Loading... |
| 153 RunBlockingTest(); | 152 RunBlockingTest(); |
| 154 } | 153 } |
| 155 | 154 |
| 156 TEST_F(CapabilityFilterContentHandlerTest, Wildcards) { | 155 TEST_F(CapabilityFilterContentHandlerTest, Wildcards) { |
| 157 RunWildcardTest(); | 156 RunWildcardTest(); |
| 158 } | 157 } |
| 159 | 158 |
| 160 } // namespace test | 159 } // namespace test |
| 161 } // namespace shell | 160 } // namespace shell |
| 162 } // namespace mojo | 161 } // namespace mojo |
| OLD | NEW |