Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / test / plugin / plugin_private_test.cc
blob22b1a3352e0644c4066ed76cc566eda8dc375c4f
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/test/plugin/plugin_private_test.h"
7 #include "base/basictypes.h"
8 #include "base/strings/string_util.h"
9 #include "content/test/plugin/plugin_client.h"
11 namespace NPAPIClient {
13 PrivateTest::PrivateTest(NPP id, NPNetscapeFuncs *host_functions)
14 : PluginTest(id, host_functions) {
17 NPError PrivateTest::New(uint16 mode, int16 argc,
18 const char* argn[], const char* argv[],
19 NPSavedData* saved) {
20 PluginTest::New(mode, argc, argn, argv, saved);
22 NPBool private_mode = 0;
23 NPNetscapeFuncs* browser = NPAPIClient::PluginClient::HostFunctions();
24 NPError result = browser->getvalue(
25 id(), NPNVprivateModeBool, &private_mode);
26 if (result != NPERR_NO_ERROR) {
27 SetError("Failed to read NPNVprivateModeBool value.");
28 } else {
29 NPIdentifier location = HostFunctions()->getstringidentifier("location");
30 NPIdentifier href = HostFunctions()->getstringidentifier("href");
32 NPObject *window_obj = NULL;
33 HostFunctions()->getvalue(id(), NPNVWindowNPObject, &window_obj);
35 NPVariant location_var;
36 HostFunctions()->getproperty(id(), window_obj, location, &location_var);
38 NPVariant href_var;
39 HostFunctions()->getproperty(id(), NPVARIANT_TO_OBJECT(location_var), href,
40 &href_var);
41 std::string href_str(href_var.value.stringValue.UTF8Characters,
42 href_var.value.stringValue.UTF8Length);
43 bool private_expected = href_str.find("?private") != href_str.npos;
44 if (private_mode != static_cast<NPBool>(private_expected))
45 SetError("NPNVprivateModeBool returned incorrect value.");
47 HostFunctions()->releasevariantvalue(&href_var);
48 HostFunctions()->releasevariantvalue(&location_var);
49 HostFunctions()->releaseobject(window_obj);
52 SignalTestCompleted();
54 return NPERR_NO_ERROR;
57 } // namespace NPAPIClient