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

Side by Side Diff: mojo/shell/application_manager_unittest.cc

Issue 1244233002: Allow trusted brokers to restrict connections for spawned applications to whitelisted applications … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years, 5 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 unified diff | Download patch
OLDNEW
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/at_exit.h" 5 #include "base/at_exit.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/memory/scoped_vector.h" 8 #include "base/memory/scoped_vector.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/application/public/cpp/application_connection.h" 10 #include "mojo/application/public/cpp/application_connection.h"
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 752
753 TEST_F(ApplicationManagerTest, TestEndApplicationClosure) { 753 TEST_F(ApplicationManagerTest, TestEndApplicationClosure) {
754 ClosingApplicationLoader* loader = new ClosingApplicationLoader(); 754 ClosingApplicationLoader* loader = new ClosingApplicationLoader();
755 application_manager_->SetLoaderForScheme( 755 application_manager_->SetLoaderForScheme(
756 scoped_ptr<ApplicationLoader>(loader), "test"); 756 scoped_ptr<ApplicationLoader>(loader), "test");
757 757
758 bool called = false; 758 bool called = false;
759 mojo::URLRequestPtr request(mojo::URLRequest::New()); 759 mojo::URLRequestPtr request(mojo::URLRequest::New());
760 request->url = mojo::String::From("test:test"); 760 request->url = mojo::String::From("test:test");
761 application_manager_->ConnectToApplication( 761 application_manager_->ConnectToApplication(
762 request.Pass(), std::string(), GURL(), nullptr, nullptr, 762 nullptr, request.Pass(), std::string(), GURL(), nullptr, nullptr, nullptr,
763 base::Bind(&QuitClosure, base::Unretained(&called))); 763 base::Bind(&QuitClosure, base::Unretained(&called)));
764 loop_.Run(); 764 loop_.Run();
765 EXPECT_TRUE(called); 765 EXPECT_TRUE(called);
766 } 766 }
767 767
768 TEST(ApplicationManagerTest2, ContentHandlerConnectionGetsRequestorURL) { 768 TEST(ApplicationManagerTest2, ContentHandlerConnectionGetsRequestorURL) {
769 const GURL content_handler_url("http://test.content.handler"); 769 const GURL content_handler_url("http://test.content.handler");
770 const GURL requestor_url("http://requestor.url"); 770 const GURL requestor_url("http://requestor.url");
771 TestContext test_context; 771 TestContext test_context;
772 base::MessageLoop loop; 772 base::MessageLoop loop;
773 TestDelegate test_delegate; 773 TestDelegate test_delegate;
774 test_delegate.set_create_test_fetcher(true); 774 test_delegate.set_create_test_fetcher(true);
775 ApplicationManager application_manager(&test_delegate); 775 ApplicationManager application_manager(&test_delegate);
776 application_manager.set_default_loader(nullptr); 776 application_manager.set_default_loader(nullptr);
777 application_manager.RegisterContentHandler(kTestMimeType, 777 application_manager.RegisterContentHandler(kTestMimeType,
778 content_handler_url); 778 content_handler_url);
779 779
780 TestApplicationLoader* loader = new TestApplicationLoader; 780 TestApplicationLoader* loader = new TestApplicationLoader;
781 loader->set_context(&test_context); 781 loader->set_context(&test_context);
782 application_manager.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader), 782 application_manager.SetLoaderForURL(scoped_ptr<ApplicationLoader>(loader),
783 content_handler_url); 783 content_handler_url);
784 784
785 bool called = false; 785 bool called = false;
786 mojo::URLRequestPtr request(mojo::URLRequest::New()); 786 mojo::URLRequestPtr request(mojo::URLRequest::New());
787 request->url = mojo::String::From("test:test"); 787 request->url = mojo::String::From("test:test");
788 application_manager.ConnectToApplication( 788 application_manager.ConnectToApplication(
789 request.Pass(), std::string(), requestor_url, nullptr, nullptr, 789 nullptr, request.Pass(), std::string(), requestor_url, nullptr, nullptr,
790 base::Bind(&QuitClosure, base::Unretained(&called))); 790 nullptr, base::Bind(&QuitClosure, base::Unretained(&called)));
791 loop.Run(); 791 loop.Run();
792 EXPECT_TRUE(called); 792 EXPECT_TRUE(called);
793 793
794 ASSERT_EQ(1, loader->num_loads()); 794 ASSERT_EQ(1, loader->num_loads());
795 EXPECT_EQ(requestor_url, loader->last_requestor_url()); 795 EXPECT_EQ(requestor_url, loader->last_requestor_url());
796 } 796 }
797 797
798 } // namespace 798 } // namespace
799 } // namespace shell 799 } // namespace shell
800 } // namespace mojo 800 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698