diff options
author | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 19:28:46 +0000 |
---|---|---|
committer | raymes@chromium.org <raymes@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-10 19:28:46 +0000 |
commit | 83d12c8ddc0ce79975db70edb0ffd35305f49ee2 (patch) | |
tree | 79bd1b1125f32b97616d9b1ca7ad2555d6fa1e04 /ppapi/tests/test_broker.cc | |
parent | e981b3fa852cdbf3bb098e4ebf2d1def635b90c2 (diff) | |
download | chromium_src-83d12c8ddc0ce79975db70edb0ffd35305f49ee2.zip chromium_src-83d12c8ddc0ce79975db70edb0ffd35305f49ee2.tar.gz chromium_src-83d12c8ddc0ce79975db70edb0ffd35305f49ee2.tar.bz2 |
Implement an IsAllowed function in the pepper PPB_Broker_Trusted API
Flash sometimes needs to synchronously know if it can launch the broker, otherwise it will try to launch the broker when it shouldn't, and end up popping an infobar. This adds an IsAllowed function to synchronously test whether the broker is allowed to launch without popping the infobar.
Note that the document URL of the plugin instance is needed in order to check the broker permissions in the browser process. This is only available in the renderer process. In order to avoid an extra hop to the renderer process just to get this URL, it is sent to the browser (with the render view ID) upon initialization of the instance when the instance is registered with the browser process.
BUG=163248
Review URL: https://chromiumcodereview.appspot.com/11316316
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@172104 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/tests/test_broker.cc')
-rw-r--r-- | ppapi/tests/test_broker.cc | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ppapi/tests/test_broker.cc b/ppapi/tests/test_broker.cc index 63bbd1c..d66e9dd 100644 --- a/ppapi/tests/test_broker.cc +++ b/ppapi/tests/test_broker.cc @@ -222,10 +222,14 @@ void TestBroker::RunTests(const std::string& filter) { RUN_TEST(ConnectPermissionDenied, filter); RUN_TEST(ConnectPermissionGranted, filter); + RUN_TEST(IsAllowedPermissionDenied, filter); + RUN_TEST(IsAllowedPermissionGranted, filter); } std::string TestBroker::TestCreate() { // Very simplistic test to make sure we can create a broker interface. + // TODO(raymes): All of the resources created in this file are leaked. Write + // a C++ wrapper for PPB_Broker_Trusted to avoid these leaks. PP_Resource broker = broker_interface_->CreateTrusted( instance_->pp_instance()); ASSERT_TRUE(broker); @@ -317,3 +321,20 @@ std::string TestBroker::TestConnectPermissionGranted() { PASS(); } +std::string TestBroker::TestIsAllowedPermissionDenied() { + PP_Resource broker = broker_interface_->CreateTrusted( + instance_->pp_instance()); + ASSERT_TRUE(broker); + ASSERT_EQ(PP_FALSE, broker_interface_->IsAllowed(broker)); + + PASS(); +} + +std::string TestBroker::TestIsAllowedPermissionGranted() { + PP_Resource broker = broker_interface_->CreateTrusted( + instance_->pp_instance()); + ASSERT_TRUE(broker); + ASSERT_EQ(PP_TRUE, broker_interface_->IsAllowed(broker)); + + PASS(); +} |