summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 21:13:16 +0000
committerrogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 21:13:16 +0000
commit69e4b61b7bfc27a6eefb1bcd1483e47f4a7777b1 (patch)
tree69dcf67b49eb02cefd2a87d418c90844735f76a2 /chrome_frame
parentf57075e5ad3bd3601ed621cc4bf0deb37d1dd52e (diff)
downloadchromium_src-69e4b61b7bfc27a6eefb1bcd1483e47f4a7777b1.zip
chromium_src-69e4b61b7bfc27a6eefb1bcd1483e47f4a7777b1.tar.gz
chromium_src-69e4b61b7bfc27a6eefb1bcd1483e47f4a7777b1.tar.bz2
Export the new sessionid property of Chrome Frame form the NPAPI interface.
BUG=0 TEST=see included unit test Review URL: http://codereview.chromium.org/5331003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67311 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/chrome_frame_npapi.cc9
-rw-r--r--chrome_frame/chrome_frame_npapi.h1
-rw-r--r--chrome_frame/ff_30_privilege_check.cc16
-rw-r--r--chrome_frame/test/data/sessionid.html39
-rw-r--r--chrome_frame/test/test_with_web_server.cc28
-rw-r--r--chrome_frame/test/test_with_web_server.h4
-rw-r--r--chrome_frame/utils.cc5
-rw-r--r--chrome_frame/utils.h1
8 files changed, 100 insertions, 3 deletions
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
index f3144b1..c645ee8 100644
--- a/chrome_frame/chrome_frame_npapi.cc
+++ b/chrome_frame/chrome_frame_npapi.cc
@@ -55,6 +55,7 @@ const NPUTF8* ChromeFrameNPAPI::plugin_property_identifier_names_[] = {
"onprivatemessage",
"usechromenetwork",
"onclose",
+ "sessionid",
};
const NPUTF8* ChromeFrameNPAPI::plugin_method_identifier_names_[] = {
@@ -667,6 +668,14 @@ bool ChromeFrameNPAPI::GetProperty(NPIdentifier name,
plugin_property_identifiers_[PLUGIN_PROPERTY_USECHROMENETWORK]) {
BOOLEAN_TO_NPVARIANT(automation_client_->use_chrome_network(), *variant);
return true;
+ } else if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_SESSIONID]) {
+ if (!is_privileged_) {
+ DLOG(WARNING) << "Attempt to read sessionid property while not "
+ "privileged";
+ } else {
+ INT32_TO_NPVARIANT(automation_client_->GetSessionId(), *variant);
+ return true;
+ }
}
return false;
diff --git a/chrome_frame/chrome_frame_npapi.h b/chrome_frame/chrome_frame_npapi.h
index d606090..f05185c 100644
--- a/chrome_frame/chrome_frame_npapi.h
+++ b/chrome_frame/chrome_frame_npapi.h
@@ -47,6 +47,7 @@ class ChromeFrameNPAPI
PLUGIN_PROPERTY_ONPRIVATEMESSAGE,
PLUGIN_PROPERTY_USECHROMENETWORK,
PLUGIN_PROPERTY_ONCLOSE,
+ PLUGIN_PROPERTY_SESSIONID,
PLUGIN_PROPERTY_COUNT // must be last
} PluginPropertyId;
diff --git a/chrome_frame/ff_30_privilege_check.cc b/chrome_frame/ff_30_privilege_check.cc
index cecd4a0..7031bd5 100644
--- a/chrome_frame/ff_30_privilege_check.cc
+++ b/chrome_frame/ff_30_privilege_check.cc
@@ -22,6 +22,7 @@
#include "chrome_frame/scoped_ns_ptr_win.h"
#include "chrome_frame/ns_associate_iid_win.h"
#include "chrome_frame/np_utils.h"
+#include "chrome_frame/utils.h"
#include "googleurl/src/gurl.h"
ASSOCIATE_IID(NS_ISERVICEMANAGER_IID_STR, nsIServiceManager);
@@ -29,6 +30,21 @@ ASSOCIATE_IID(NS_ISERVICEMANAGER_IID_STR, nsIServiceManager);
// Returns true iff we're being instantiated into a document
// that has the system principal's privileges
bool IsFireFoxPrivilegedInvocation(NPP instance) {
+ // For testing purposes, check the registry to see if the privilege mode
+ // is being forced to a certain value. If this property does not exist, the
+ // mode should be verified normally. If this property does exist, its value
+ // is interpreted as follows:
+ //
+ // 0: force privilege mode off
+ // 1: force privilege mode on
+ // any other value: do normal verification
+ int privilege_mode = GetConfigInt(2, kEnableFirefoxPrivilegeMode);
+ if (privilege_mode == 0) {
+ return false;
+ } else if (privilege_mode == 1) {
+ return true;
+ }
+
// Make sure that we are running in Firefox before checking for privilege.
const char* user_agent = npapi::UserAgent(instance);
if (strstr(user_agent, "Firefox") == NULL)
diff --git a/chrome_frame/test/data/sessionid.html b/chrome_frame/test/data/sessionid.html
new file mode 100644
index 0000000..14e84bc
--- /dev/null
+++ b/chrome_frame/test/data/sessionid.html
@@ -0,0 +1,39 @@
+<html>
+<!-- This page is meant to load inside the host browser like IE/FF -->
+ <head>
+ <script type="text/javascript" src="chrome_frame_tester_helpers.js">
+ </script>
+ <script type="text/javascript">
+ function onLoad() {
+ document.ChromeFrame.addEventListener('readystatechanged',
+ function() {
+ if (document.ChromeFrame.readystate == 4) { // READY_STATE_COMPLETED
+ var sessionId = document.ChromeFrame.sessionid;
+ appendStatus('Chrome frame sessionId: ' + sessionId);
+ if (sessionId == 1) {
+ onSuccess('sessionid', 1);
+ } else {
+ onFailure('sessionid', 1, 'no sessionId');
+ }
+ }
+ }, false);
+ }
+ </script>
+ </head>
+
+ <body onload="onLoad();">
+ <object id="ChromeFrame"
+ codebase="http://www.google.com"
+ classid="CLSID:E0A900DF-9611-4446-86BD-4B1D47E7DB2A">
+ <embed id="ChromeFramePlugin" name="ChromeFrame"
+ type="application/chromeframe" privileged_mode="1"
+ </embed>
+ </object>
+ <br>
+ <br>
+ <p>Test for Chrome frame sessionid</p>
+ <div id="statusPanel" style="border: 1px solid red; width: 100%">
+ Test running....
+ </div>
+ </body>
+</html>
diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc
index 03dff3f..a030a76 100644
--- a/chrome_frame/test/test_with_web_server.cc
+++ b/chrome_frame/test/test_with_web_server.cc
@@ -127,6 +127,10 @@ void ChromeFrameTestWithWebServer::SetUp() {
}
void ChromeFrameTestWithWebServer::TearDown() {
+ // Make sure that the Firefox privilege mode is never forced either on or off
+ // after the test completes.
+ DeleteConfigValue(kEnableFirefoxPrivilegeMode);
+
CloseBrowser();
CloseAllBrowsers();
file_util::Delete(CFInstall_path_, false);
@@ -281,6 +285,19 @@ void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser,
ASSERT_EQ(version, UTF8ToWide(server_mock_.posted_result()));
}
+void ChromeFrameTestWithWebServer::SessionIdTest(BrowserKind browser,
+ const wchar_t* page,
+ int privilege_mode,
+ const char* expected_result) {
+ SetConfigInt(kEnableFirefoxPrivilegeMode, privilege_mode);
+ EXPECT_TRUE(LaunchBrowser(browser, page));
+ server_mock_.set_expected_result(expected_result);
+ server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
+ kPostedResultSubstring);
+ WaitForTestToComplete(kLongWaitTimeout);
+ ASSERT_EQ(expected_result, server_mock_.posted_result());
+}
+
// MockWebServer methods
void MockWebServer::ExpectAndServeRequest(CFInvocation invocation,
const std::wstring& url) {
@@ -804,6 +821,16 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeFF_Version) {
VersionTest(FIREFOX, kVersionPage);
}
+const wchar_t kSessionIdPage[] = L"sessionid.html";
+
+TEST_F(ChromeFrameTestWithWebServer, WidgetModeFF_SessionIdPrivilege) {
+ SessionIdTest(FIREFOX, kSessionIdPage, 1, "OK");
+}
+
+TEST_F(ChromeFrameTestWithWebServer, WidgetModeFF_SessionIdNoPrivilege) {
+ SessionIdTest(FIREFOX, kSessionIdPage, 0, "no sessionId");
+}
+
const wchar_t kEventListenerPage[] = L"event_listener.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_EventListener) {
@@ -1260,4 +1287,3 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestDownloadFromForm) {
EXPECT_EQ(1, response->get_request_count());
EXPECT_EQ(1, response->post_request_count());
}
-
diff --git a/chrome_frame/test/test_with_web_server.h b/chrome_frame/test/test_with_web_server.h
index fd65615..3b424f3 100644
--- a/chrome_frame/test/test_with_web_server.h
+++ b/chrome_frame/test/test_with_web_server.h
@@ -175,6 +175,10 @@ class ChromeFrameTestWithWebServer: public testing::Test {
// Test if chrome frame correctly reports its version.
void VersionTest(BrowserKind browser, const wchar_t* page);
+ // Test if chrome frame correctly reports its session Id.
+ void SessionIdTest(BrowserKind browser, const wchar_t* page,
+ int privilege_mode, const char* expected_result);
+
// Closes all browsers in preparation for a test and during cleanup.
void CloseAllBrowsers();
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index 294f044..8fd90fc 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -62,8 +62,9 @@ const wchar_t kEnableGCFRendererByDefault[] = L"IsDefaultRenderer";
const wchar_t kIexploreProfileName[] = L"iexplore";
const wchar_t kRundllProfileName[] = L"rundll32";
-static const wchar_t kAllowUnsafeURLs[] = L"AllowUnsafeURLs";
-static const wchar_t kEnableBuggyBhoIntercept[] = L"EnableBuggyBhoIntercept";
+const wchar_t kAllowUnsafeURLs[] = L"AllowUnsafeURLs";
+const wchar_t kEnableBuggyBhoIntercept[] = L"EnableBuggyBhoIntercept";
+const wchar_t kEnableFirefoxPrivilegeMode[] = L"EnableFirefoxPrivilegeMode";
static const wchar_t kChromeFrameNPAPIKey[] =
L"Software\\MozillaPlugins\\@google.com/ChromeFrame,version=1.0";
diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h
index 11b749b..4492078 100644
--- a/chrome_frame/utils.h
+++ b/chrome_frame/utils.h
@@ -33,6 +33,7 @@ extern const wchar_t kChromeFrameAccessibleMode[];
extern const wchar_t kChromeFrameUnpinnedMode[];
extern const wchar_t kAllowUnsafeURLs[];
extern const wchar_t kEnableBuggyBhoIntercept[];
+extern const wchar_t kEnableFirefoxPrivilegeMode[];
extern const wchar_t kChromeMimeType[];
extern const wchar_t kChromeFrameAttachTabPattern[];
extern const wchar_t kChromeFrameConfigKey[];