summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-29 02:29:53 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-29 02:29:53 +0000
commit99d81e5b17ea11dd11be5cd88ae8446347ebab8c (patch)
treea862d90d8e4cb881f6b5522637e92214b81c78ff /chrome_frame
parentdc8e66456af280e6d5c14ebd195e115fbe0b016c (diff)
downloadchromium_src-99d81e5b17ea11dd11be5cd88ae8446347ebab8c.zip
chromium_src-99d81e5b17ea11dd11be5cd88ae8446347ebab8c.tar.gz
chromium_src-99d81e5b17ea11dd11be5cd88ae8446347ebab8c.tar.bz2
Remove 1) NPAPI support from Chrome Frame and 2) Firefox/Opera/Safari tests.
BUG=none TEST=automated testing should suffice R=ananta@chromium.org,robertshield@chromium.org Review URL: http://codereview.chromium.org/7276037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/cfproxy.h5
-rw-r--r--chrome_frame/chrome_frame.gyp56
-rw-r--r--chrome_frame/chrome_frame_automation.cc72
-rw-r--r--chrome_frame/chrome_frame_automation.h16
-rw-r--r--chrome_frame/chrome_frame_histograms.cc86
-rw-r--r--chrome_frame/chrome_frame_histograms.h58
-rw-r--r--chrome_frame/chrome_frame_npapi.cc1139
-rw-r--r--chrome_frame/chrome_frame_npapi.h298
-rw-r--r--chrome_frame/chrome_frame_npapi_entrypoints.cc218
-rw-r--r--chrome_frame/chrome_frame_npapi_entrypoints.h40
-rw-r--r--chrome_frame/chrome_frame_npapi_unittest.cc176
-rw-r--r--chrome_frame/chrome_frame_plugin.h2
-rw-r--r--chrome_frame/chrome_tab.cc53
-rw-r--r--chrome_frame/chrome_tab.def7
-rw-r--r--chrome_frame/external_tab.h5
-rw-r--r--chrome_frame/metrics_service.cc3
-rw-r--r--chrome_frame/navigation_constraints.h3
-rw-r--r--chrome_frame/np_browser_functions.cc533
-rw-r--r--chrome_frame/np_browser_functions.h283
-rw-r--r--chrome_frame/np_utils.cc45
-rw-r--r--chrome_frame/np_utils.h19
-rw-r--r--chrome_frame/npapi_url_request.cc448
-rw-r--r--chrome_frame/npapi_url_request.h73
-rw-r--r--chrome_frame/plugin_url_request.cc3
-rw-r--r--chrome_frame/test/chrome_frame_test_utils.cc21
-rw-r--r--chrome_frame/test/chrome_frame_test_utils.h6
-rw-r--r--chrome_frame/test/test_with_web_server.cc281
-rw-r--r--chrome_frame/test/test_with_web_server.h16
-rw-r--r--chrome_frame/test_utils.cc28
-rw-r--r--chrome_frame/utils.cc59
-rw-r--r--chrome_frame/utils.h15
31 files changed, 30 insertions, 4037 deletions
diff --git a/chrome_frame/cfproxy.h b/chrome_frame/cfproxy.h
index 34f3f27..7e4c0fb 100644
--- a/chrome_frame/cfproxy.h
+++ b/chrome_frame/cfproxy.h
@@ -41,9 +41,8 @@ struct SyncMessageContext {
/*
-[npapi] UIDelegate (UI_THREAD)
-[activex] <---------------+
-[activedoc] |
+[activex] UIDelegate (UI_THREAD)
+[activedoc] <---------------+
|
| ChromeProxy (UI_THREAD)
+----------------+ --------------> +-------+
diff --git a/chrome_frame/chrome_frame.gyp b/chrome_frame/chrome_frame.gyp
index 8684b05..09186fa 100644
--- a/chrome_frame/chrome_frame.gyp
+++ b/chrome_frame/chrome_frame.gyp
@@ -37,7 +37,6 @@
'../chrome/chrome.gyp:chrome_strings',
'../chrome/chrome.gyp:theme_resources',
'../skia/skia.gyp:skia',
- '../third_party/npapi/npapi.gyp:npapi',
],
'defines': [ 'ISOLATION_AWARE_ENABLED=1' ],
'include_dirs': [
@@ -88,8 +87,6 @@
],
'sources': [
'<(SHARED_INTERMEDIATE_DIR)/chrome_tab.h',
- 'chrome_frame_histograms.h',
- 'chrome_frame_histograms.cc',
'chrome_frame_unittest_main.cc',
'chrome_launcher.cc',
'chrome_launcher.h',
@@ -128,17 +125,10 @@
'<(SHARED_INTERMEDIATE_DIR)',
],
'conditions': [
- # We needed to extract this test from the chrome_frame_unittests because
- # we can't instrument code for coverage if it depends on 3rd party
+ # We can't instrument code for coverage if it depends on 3rd party
# binaries that we don't have PDBs for. See here for more details:
# http://connect.microsoft.com/VisualStudio/feedback/details/176188/can-not-disable-warning-lnk4099
['coverage==0', {
- 'dependencies': [
- 'chrome_frame_npapi',
- ],
- 'sources': [
- 'chrome_frame_npapi_unittest.cc',
- ],
'conditions': [
['OS=="win"', {
'dependencies': [
@@ -211,7 +201,6 @@
'../third_party/iaccessible2/iaccessible2.gyp:IAccessible2Proxy',
'../third_party/libxslt/libxslt.gyp:libxslt',
'chrome_frame_ie',
- 'chrome_frame_npapi',
'chrome_frame_strings',
'chrome_frame_utils',
'chrome_tab_idl',
@@ -318,7 +307,6 @@
'../third_party/libxml/libxml.gyp:libxml',
'../third_party/libxslt/libxslt.gyp:libxslt',
'chrome_frame_ie',
- 'chrome_frame_npapi',
'chrome_frame_strings',
'chrome_frame_utils',
'chrome_tab_idl',
@@ -395,7 +383,6 @@
'../testing/gtest.gyp:gtest',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
- 'chrome_frame_npapi',
'chrome_frame_ie',
'chrome_tab_idl',
'npchrome_frame',
@@ -472,7 +459,6 @@
'../testing/gmock.gyp:gmock',
'../testing/gtest.gyp:gtest',
'chrome_frame_ie',
- 'chrome_frame_npapi',
'chrome_frame_strings',
'chrome_tab_idl',
],
@@ -542,7 +528,6 @@
'../testing/gtest.gyp:gtest',
'../third_party/iaccessible2/iaccessible2.gyp:iaccessible2',
'chrome_frame_ie',
- 'chrome_frame_npapi',
'chrome_frame_strings',
'npchrome_frame',
],
@@ -599,39 +584,6 @@
],
},
{
- 'target_name': 'chrome_frame_npapi_core',
- 'type': 'static_library',
- 'dependencies': [
- '../base/base.gyp:base',
- ],
- 'sources': [
- 'np_browser_functions.cc',
- 'np_browser_functions.h',
- ],
- },
- {
- 'target_name': 'chrome_frame_npapi',
- 'type': 'static_library',
- 'dependencies': [
- 'chrome_frame_common',
- 'chrome_frame_npapi_core',
- 'chrome_frame_strings',
- 'chrome_frame_utils',
- '../chrome/chrome.gyp:common',
- '../net/net.gyp:net',
- ],
- 'sources': [
- 'chrome_frame_npapi.cc',
- 'chrome_frame_npapi.h',
- 'np_utils.cc',
- 'np_utils.h',
- 'npapi_url_request.cc',
- 'npapi_url_request.h',
- ],
- 'include_dirs': [
- ],
- },
- {
'target_name': 'chrome_frame_strings',
'type': 'none',
'variables': {
@@ -702,8 +654,6 @@
'chrome_frame_activex.h',
'chrome_frame_activex.rgs',
'chrome_frame_activex_base.h',
- 'chrome_frame_histograms.cc',
- 'chrome_frame_histograms.h',
'chrome_protocol.cc',
'chrome_protocol.h',
'chrome_protocol.rgs',
@@ -872,7 +822,6 @@
'dependencies': [
'../base/base.gyp:base',
'chrome_frame_ie',
- 'chrome_frame_npapi',
'chrome_frame_strings',
'chrome_frame_utils',
'chrome_tab_idl',
@@ -887,9 +836,6 @@
],
'sources': [
'chrome_frame_elevation.rgs',
- 'chrome_frame_npapi.rgs',
- 'chrome_frame_npapi_entrypoints.cc',
- 'chrome_frame_npapi_entrypoints.h',
'chrome_frame_reporting.cc',
'chrome_frame_reporting.h',
'chrome_tab.cc',
diff --git a/chrome_frame/chrome_frame_automation.cc b/chrome_frame/chrome_frame_automation.cc
index f0ccbe4..2f975f1 100644
--- a/chrome_frame/chrome_frame_automation.cc
+++ b/chrome_frame/chrome_frame_automation.cc
@@ -38,10 +38,6 @@ int64 kAutomationServerReasonableLaunchDelay = 1000; // in milliseconds
int64 kAutomationServerReasonableLaunchDelay = 1000 * 10;
#endif
-int kDefaultSendUMADataInterval = 20000; // in milliseconds.
-
-static const wchar_t kUmaSendIntervalValue[] = L"UmaSendInterval";
-
class ChromeFrameAutomationProxyImpl::TabProxyNotificationMessageFilter
: public IPC::ChannelProxy::MessageFilter {
public:
@@ -205,8 +201,7 @@ DISABLE_RUNNABLE_METHOD_REFCOUNT(AutomationProxyCacheEntry);
AutomationProxyCacheEntry::AutomationProxyCacheEntry(
ChromeFrameLaunchParams* params, LaunchDelegate* delegate)
: profile_name(params->profile_name()),
- launch_result_(AUTOMATION_LAUNCH_RESULT_INVALID),
- snapshots_(NULL), uma_send_interval_(1) {
+ launch_result_(AUTOMATION_LAUNCH_RESULT_INVALID) {
DCHECK(delegate);
thread_.reset(new base::Thread(WideToASCII(profile_name).c_str()));
thread_->Start();
@@ -231,17 +226,6 @@ AutomationProxyCacheEntry::~AutomationProxyCacheEntry() {
}
}
-void AutomationProxyCacheEntry::StartSendUmaInterval(
- ChromeFrameHistogramSnapshots* snapshots, int send_interval) {
- DCHECK(snapshots);
- DCHECK(!snapshots_);
- snapshots_ = snapshots;
- uma_send_interval_ = send_interval;
- thread_->message_loop()->PostDelayedTask(FROM_HERE,
- NewRunnableMethod(this, &AutomationProxyCacheEntry::SendUMAData),
- send_interval);
-}
-
void AutomationProxyCacheEntry::CreateProxy(ChromeFrameLaunchParams* params,
LaunchDelegate* delegate) {
DCHECK(IsSameThread(base::PlatformThread::CurrentId()));
@@ -381,9 +365,6 @@ void AutomationProxyCacheEntry::RemoveDelegate(LaunchDelegate* delegate,
if (launch_delegates_.size() == 1) {
*was_last_delegate = true;
- if (snapshots_)
- SendUMAData();
-
// Process pending notifications.
thread_->message_loop()->RunAllPending();
@@ -421,38 +402,9 @@ void AutomationProxyCacheEntry::OnChannelError() {
}
}
-void AutomationProxyCacheEntry::SendUMAData() {
- DCHECK(IsSameThread(base::PlatformThread::CurrentId()));
- DCHECK(snapshots_);
- // IE uses the chrome frame provided UMA data uploading scheme. NPAPI
- // continues to use Chrome to upload UMA data.
- if (CrashMetricsReporter::GetInstance()->active()) {
- return;
- }
-
- if (!proxy_.get()) {
- DLOG(WARNING) << __FUNCTION__ << " NULL proxy, can't send UMA data";
- } else {
- ChromeFrameHistogramSnapshots::HistogramPickledList histograms =
- snapshots_->GatherAllHistograms();
-
- if (!histograms.empty()) {
- proxy_->Send(new AutomationMsg_RecordHistograms(histograms));
- }
-
- MessageLoop::current()->PostDelayedTask(FROM_HERE,
- NewRunnableMethod(this, &AutomationProxyCacheEntry::SendUMAData),
- uma_send_interval_);
- }
-}
-
-
DISABLE_RUNNABLE_METHOD_REFCOUNT(ProxyFactory);
-ProxyFactory::ProxyFactory()
- : uma_send_interval_(0) {
- uma_send_interval_ = GetConfigInt(kDefaultSendUMADataInterval,
- kUmaSendIntervalValue);
+ProxyFactory::ProxyFactory() {
}
ProxyFactory::~ProxyFactory() {
@@ -483,13 +435,6 @@ void ProxyFactory::GetAutomationServer(
DVLOG(1) << __FUNCTION__ << " creating new proxy entry";
entry = new AutomationProxyCacheEntry(params, delegate);
proxies_.container().push_back(entry);
-
- // IE uses the chrome frame provided UMA data uploading scheme. NPAPI
- // continues to use Chrome to upload UMA data.
- if (!CrashMetricsReporter::GetInstance()->active()) {
- entry->StartSendUmaInterval(&chrome_frame_histograms_,
- uma_send_interval_);
- }
} else if (delegate) {
// Notify the new delegate of the launch status from the worker thread
// and add it to the list of delegates.
@@ -621,7 +566,7 @@ bool ChromeFrameAutomationClient::Initialize(
// Create a window on the UI thread for marshaling messages back and forth
// from the IPC thread. This window cannot be a message only window as the
// external chrome tab window is created as a child of this window. This
- // window is eventually reparented to the ActiveX/NPAPI plugin window.
+ // window is eventually reparented to the ActiveX plugin window.
if (!Create(GetDesktopWindow(), NULL, NULL,
WS_CHILDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
WS_EX_TOOLWINDOW)) {
@@ -657,14 +602,6 @@ void ChromeFrameAutomationClient::Uninitialize() {
init_state_ = UNINITIALIZING;
// Called from client's FinalRelease() / destructor
- // ChromeFrameAutomationClient may wait for the initialization (launch)
- // to complete while Uninitialize is called.
- // We either have to:
- // 1) Make ReleaseAutomationServer blocking call (wait until thread exits)
- // 2) Behave like a COM object i.e. increase module lock count.
- // Otherwise the DLL may get unloaded while we have running threads.
- // Unfortunately in NPAPI case we cannot increase module lock count, hence
- // we stick with blocking/waiting
if (url_fetcher_) {
// Clean up any outstanding requests
url_fetcher_->StopAllRequests();
@@ -1057,8 +994,7 @@ bool ChromeFrameAutomationClient::ProcessUrlRequestMessage(TabProxy* tab,
}
// These are invoked in channel's background thread.
-// Cannot call any method of the activex/npapi here since they are STA
-// kind of beings.
+// Cannot call any method of the activex here since it is a STA kind of being.
// By default we marshal the IPC message to the main/GUI thread and from there
// we safely invoke chrome_frame_delegate_->OnMessageReceived(msg).
bool ChromeFrameAutomationClient::OnMessageReceived(TabProxy* tab,
diff --git a/chrome_frame/chrome_frame_automation.h b/chrome_frame/chrome_frame_automation.h
index eed2983..1d4a70f 100644
--- a/chrome_frame/chrome_frame_automation.h
+++ b/chrome_frame/chrome_frame_automation.h
@@ -21,7 +21,6 @@
#include "chrome/test/automation/automation_proxy.h"
#include "chrome/test/automation/tab_proxy.h"
#include "chrome_frame/chrome_frame_delegate.h"
-#include "chrome_frame/chrome_frame_histograms.h"
#include "chrome_frame/plugin_url_request.h"
#include "chrome_frame/sync_msg_reply_dispatcher.h"
#include "content/common/page_zoom.h"
@@ -231,9 +230,6 @@ class AutomationProxyCacheEntry
void RemoveDelegate(LaunchDelegate* delegate, base::WaitableEvent* done,
bool* was_last_delegate);
- void StartSendUmaInterval(ChromeFrameHistogramSnapshots* snapshots,
- int send_interval);
-
DWORD WaitForThread(DWORD timeout) { // NOLINT
DCHECK(thread_.get());
return ::WaitForSingleObject(thread_->thread_handle(), timeout);
@@ -266,7 +262,6 @@ class AutomationProxyCacheEntry
protected:
void CreateProxy(ChromeFrameLaunchParams* params,
LaunchDelegate* delegate);
- void SendUMAData();
protected:
std::wstring profile_name;
@@ -278,8 +273,6 @@ class AutomationProxyCacheEntry
// Used for UMA histogram logging to measure the time for the chrome
// automation server to start;
base::TimeTicks automation_server_launch_start_time_;
- ChromeFrameHistogramSnapshots* snapshots_;
- int uma_send_interval_;
};
// We must create and destroy automation proxy in a thread with a message loop.
@@ -304,17 +297,10 @@ class ProxyFactory {
Vector proxies_;
// Lock if we are going to call GetAutomationServer from more than one thread.
base::Lock lock_;
-
- // Gathers histograms to be sent to Chrome.
- ChromeFrameHistogramSnapshots chrome_frame_histograms_;
-
- // Interval for sending UMA data
- int uma_send_interval_;
};
// Handles all automation requests initiated from the chrome frame objects.
-// These include the chrome tab/chrome frame activex/chrome frame npapi
-// plugin objects.
+// These include the chrome tab/chrome frame activex plugin objects.
class ChromeFrameAutomationClient
: public CWindowImpl<ChromeFrameAutomationClient>,
public TaskMarshallerThroughWindowsMessages<ChromeFrameAutomationClient>,
diff --git a/chrome_frame/chrome_frame_histograms.cc b/chrome_frame/chrome_frame_histograms.cc
deleted file mode 100644
index edcc968..0000000
--- a/chrome_frame/chrome_frame_histograms.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome_frame/chrome_frame_histograms.h"
-
-#include "base/metrics/histogram.h"
-#include "base/lazy_instance.h"
-#include "base/logging.h"
-#include "base/message_loop.h"
-
-using base::Histogram;
-using base::StatisticsRecorder;
-
- // Initialize histogram statistics gathering system.
-base::LazyInstance<StatisticsRecorder>
- g_statistics_recorder_(base::LINKER_INITIALIZED);
-
-ChromeFrameHistogramSnapshots::ChromeFrameHistogramSnapshots() {
- // Ensure that an instance of the StatisticsRecorder object is created.
- g_statistics_recorder_.Get();
-}
-
-ChromeFrameHistogramSnapshots::HistogramPickledList
- ChromeFrameHistogramSnapshots::GatherAllHistograms() {
-
- base::AutoLock auto_lock(lock_);
-
- StatisticsRecorder::Histograms histograms;
- StatisticsRecorder::GetHistograms(&histograms);
-
- HistogramPickledList pickled_histograms;
-
- for (StatisticsRecorder::Histograms::iterator it = histograms.begin();
- histograms.end() != it;
- it++) {
- (*it)->SetFlags(Histogram::kIPCSerializationSourceFlag);
- GatherHistogram(**it, &pickled_histograms);
- }
-
- return pickled_histograms;
-}
-
-void ChromeFrameHistogramSnapshots::GatherHistogram(
- const Histogram& histogram,
- HistogramPickledList* pickled_histograms) {
-
- // Get up-to-date snapshot of sample stats.
- Histogram::SampleSet snapshot;
- histogram.SnapshotSample(&snapshot);
- const std::string& histogram_name = histogram.histogram_name();
-
- // Check if we already have a log of this histogram and if not create an
- // empty set.
- LoggedSampleMap::iterator it = logged_samples_.find(histogram_name);
- Histogram::SampleSet* already_logged;
- if (logged_samples_.end() == it) {
- // Add new entry.
- already_logged = &logged_samples_[histogram.histogram_name()];
- already_logged->Resize(histogram); // Complete initialization.
- } else {
- already_logged = &(it->second);
- // Deduct any stats we've already logged from our snapshot.
- snapshot.Subtract(*already_logged);
- }
-
- // Snapshot now contains only a delta to what we've already_logged.
- if (snapshot.TotalCount() > 0) {
- GatherHistogramDelta(histogram, snapshot, pickled_histograms);
- // Add new data into our running total.
- already_logged->Add(snapshot);
- }
-}
-
-void ChromeFrameHistogramSnapshots::GatherHistogramDelta(
- const Histogram& histogram,
- const Histogram::SampleSet& snapshot,
- HistogramPickledList* pickled_histograms) {
-
- DCHECK(0 != snapshot.TotalCount());
- snapshot.CheckSize(histogram);
-
- std::string histogram_info =
- Histogram::SerializeHistogramInfo(histogram, snapshot);
- pickled_histograms->push_back(histogram_info);
-}
diff --git a/chrome_frame/chrome_frame_histograms.h b/chrome_frame/chrome_frame_histograms.h
deleted file mode 100644
index 0dc9e48..0000000
--- a/chrome_frame/chrome_frame_histograms.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_FRAME_HISTOGRAM_SNAPSHOTS_H_
-#define CHROME_FRAME_HISTOGRAM_SNAPSHOTS_H_
-
-#include <map>
-#include <string>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/metrics/histogram.h"
-#include "base/process.h"
-#include "base/synchronization/lock.h"
-#include "base/task.h"
-
-// This class gathers histogram data in the host browser process and
-// serializes the data into a vector of strings to be uploaded to the
-// Chrome browser process. It records the histogram data which has been
-// logged and only uploads the delta with the next log.
-// TODO(iyengar)
-// This class does not contain any ChromeFrame specific stuff. It should
-// be moved to base.
-class ChromeFrameHistogramSnapshots {
- public:
- // Maintain a map of histogram names to the sample stats we've sent.
- typedef std::map<std::string, base::Histogram::SampleSet> LoggedSampleMap;
- typedef std::vector<std::string> HistogramPickledList;
-
- ChromeFrameHistogramSnapshots();
- ~ChromeFrameHistogramSnapshots() {}
-
- // Extract snapshot data and return it to be sent off to the Chrome browser
- // process.
- // Return only a delta to what we have already sent.
- HistogramPickledList GatherAllHistograms();
-
- private:
- void GatherHistogram(const base::Histogram& histogram,
- HistogramPickledList* histograms);
-
- void GatherHistogramDelta(const base::Histogram& histogram,
- const base::Histogram::SampleSet& snapshot,
- HistogramPickledList* histograms);
-
- // For histograms, record what we've already logged (as a sample for each
- // histogram) so that we can send only the delta with the next log.
- LoggedSampleMap logged_samples_;
-
- // Synchronizes the histogram gathering operation.
- base::Lock lock_;
-
- DISALLOW_COPY_AND_ASSIGN(ChromeFrameHistogramSnapshots);
-};
-
-#endif // CHROME_RENDERER_HISTOGRAM_SNAPSHOTS_H_
diff --git a/chrome_frame/chrome_frame_npapi.cc b/chrome_frame/chrome_frame_npapi.cc
deleted file mode 100644
index 0baab27..0000000
--- a/chrome_frame/chrome_frame_npapi.cc
+++ /dev/null
@@ -1,1139 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome_frame/chrome_frame_npapi.h"
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "base/message_loop.h"
-#include "base/string_split.h"
-#include "base/string_util.h"
-#include "base/stringprintf.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/test/automation/tab_proxy.h"
-#include "chrome_frame/np_utils.h"
-#include "chrome_frame/utils.h"
-
-MessageLoop* ChromeFrameNPAPI::message_loop_ = NULL;
-int ChromeFrameNPAPI::instance_count_ = 0;
-
-NPClass ChromeFrameNPAPI::plugin_class_ = {
- NP_CLASS_STRUCT_VERSION,
- ChromeFrameNPAPI::AllocateObject,
- ChromeFrameNPAPI::DeallocateObject,
- ChromeFrameNPAPI::Invalidate,
- ChromeFrameNPAPI::HasMethod,
- ChromeFrameNPAPI::Invoke,
- NULL, // invokeDefault
- ChromeFrameNPAPI::HasProperty,
- ChromeFrameNPAPI::GetProperty,
- ChromeFrameNPAPI::SetProperty,
- NULL, // remove property
- NULL, // enumeration
- NULL, // construct
-};
-
-NPIdentifier
- ChromeFrameNPAPI::plugin_property_identifiers_[PLUGIN_PROPERTY_COUNT]
- = {0};
-
-const NPUTF8* ChromeFrameNPAPI::plugin_property_identifier_names_[] = {
- "version",
- "src",
- "onload",
- "onloaderror",
- "onmessage",
- "readystate",
- "usechromenetwork",
- "onclose",
-};
-
-const NPUTF8* ChromeFrameNPAPI::plugin_method_identifier_names_[] = {
- "postMessage",
-};
-
-ChromeFrameNPAPI::PluginMethod ChromeFrameNPAPI::plugin_methods_[] = {
- &ChromeFrameNPAPI::postMessage,
-};
-
-NPIdentifier
- ChromeFrameNPAPI::plugin_method_identifiers_[arraysize(plugin_methods_)]
- = {0};
-
-
-void ChromeFrameNPAPI::CompileAsserts() {
- NOTREACHED(); // This function should never be invoked.
-
- COMPILE_ASSERT(arraysize(plugin_method_identifier_names_) ==
- arraysize(plugin_methods_),
- you_must_add_both_plugin_method_and_name);
-
- COMPILE_ASSERT(arraysize(plugin_property_identifier_names_) ==
- arraysize(plugin_property_identifiers_),
- you_must_add_both_plugin_property_and_name);
-}
-
-static const char kPluginSrcAttribute[] = "src";
-static const char kPluginForceFullPageAttribute[] = "force_full_page";
-static const char kPluginOnloadAttribute[] = "onload";
-static const char kPluginOnErrorAttribute[] = "onloaderror";
-static const char kPluginOnMessageAttribute[] = "onmessage";
-static const char kPluginOnPrivateMessageAttribute[] = "onprivatemessage";
-static const char kPluginOnCloseAttribute[] = "onclose";
-
-// If chrome network stack is to be used
-static const char kPluginUseChromeNetwork[] = "usechromenetwork";
-
-// ChromeFrameNPAPI member defines.
-
-// TODO(tommi): remove ignore_setfocus_ since that's not how focus is
-// handled anymore.
-
-ChromeFrameNPAPI::ChromeFrameNPAPI()
- : instance_(NULL),
- mode_(NP_EMBED),
- force_full_page_plugin_(false),
- ready_state_(READYSTATE_LOADING),
- enabled_popups_(false),
- navigate_after_initialization_(false) {
-}
-
-ChromeFrameNPAPI::~ChromeFrameNPAPI() {
- if (IsWindow()) {
- if (!UnsubclassWindow()) {
- // TODO(tommi): Figure out why this can sometimes happen in the
- // WidgetModeFF_Resize unittest.
- DLOG(ERROR) << "Couldn't unsubclass safely!";
- UnsubclassWindow(TRUE);
- }
- }
- m_hWnd = NULL;
-
- instance_count_--;
- if (instance_count_ <= 0) {
- delete message_loop_;
- message_loop_ = NULL;
- }
-
- Uninitialize();
-}
-
-std::string ChromeFrameNPAPI::GetLocation() {
- // Note that GetWindowObject() will cache the window object here.
- return np_utils::GetLocation(instance_, GetWindowObject());
-}
-
-bool ChromeFrameNPAPI::Initialize(NPMIMEType mime_type, NPP instance,
- uint16 mode, int16 argc, char* argn[],
- char* argv[]) {
- if (!Base::Initialize())
- return false;
-
- instance_ = instance;
- mime_type_ = mime_type;
- mode_ = mode;
- document_url_ = GetLocation();
-
- if (instance_count_ == 0) {
- DCHECK(message_loop_ == NULL);
- message_loop_ = new MessageLoop();
- }
-
- instance_count_++;
-
- for (int i = 0; i < argc; ++i) {
- if (LowerCaseEqualsASCII(argn[i], kPluginSrcAttribute)) {
- src_ = ResolveURL(GetDocumentUrl(), argv[i]);
- } else if (LowerCaseEqualsASCII(argn[i], kPluginForceFullPageAttribute)) {
- force_full_page_plugin_ = atoi(argv[i]) ? true : false;
- } else if (LowerCaseEqualsASCII(argn[i], kPluginOnErrorAttribute)) {
- onerror_handler_ = JavascriptToNPObject(argv[i]);
- } else if (LowerCaseEqualsASCII(argn[i], kPluginOnMessageAttribute)) {
- onmessage_handler_ = JavascriptToNPObject(argv[i]);
- } else if (LowerCaseEqualsASCII(argn[i], kPluginOnCloseAttribute)) {
- onclose_handler_ = JavascriptToNPObject(argv[i]);
- }
- }
-
- std::wstring profile_name(GetHostProcessName(false));
- std::wstring extra_arguments;
-
- static const wchar_t kHandleTopLevelRequests[] = L"HandleTopLevelRequests";
- bool top_level_requests = GetConfigBool(true, kHandleTopLevelRequests);
- automation_client_->set_handle_top_level_requests(top_level_requests);
- automation_client_->set_route_all_top_level_navigations(true);
-
- // Setup Url fetcher.
- url_fetcher_.set_NPPInstance(instance_);
- url_fetcher_.set_frame_busting(!is_privileged());
- automation_client_->SetUrlFetcher(&url_fetcher_);
-
- // TODO(joshia): Initialize navigation here and send proxy config as
- // part of LaunchSettings
- /*
- if (!src_.empty())
- automation_client_->InitiateNavigation(src_, is_privileged());
-
- std::string proxy_settings;
- bool has_prefs = pref_service_->Initialize(instance_,
- automation_client_.get());
- if (has_prefs && pref_service_->GetProxyValueJSONString(&proxy_settings)) {
- automation_client_->SetProxySettings(proxy_settings);
- }
- */
-
- // We can't call SubscribeToFocusEvents here since
- // when Initialize gets called, Opera is in a state where
- // it can't handle calls back and the thread will hang.
- // Instead, we call SubscribeToFocusEvents when we initialize
- // our plugin window.
-
- // TODO(stoyan): Ask host for specific interface whether to honor
- // host's in-private mode.
- return InitializeAutomation(profile_name, extra_arguments,
- GetBrowserIncognitoMode(), true,
- GURL(src_), GURL(), true);
-}
-
-void ChromeFrameNPAPI::Uninitialize() {
- if (ready_state_ != READYSTATE_UNINITIALIZED)
- SetReadyState(READYSTATE_UNINITIALIZED);
-
- window_object_.Free();
- onerror_handler_.Free();
- onmessage_handler_.Free();
- onprivatemessage_handler_.Free();
- onclose_handler_.Free();
-
- Base::Uninitialize();
-}
-
-void ChromeFrameNPAPI::OnFinalMessage(HWND window) {
- // The automation server should be gone by now.
- Uninitialize();
-}
-
-bool ChromeFrameNPAPI::SetWindow(NPWindow* window_info) {
- if (!window_info || !automation_client_.get()) {
- NOTREACHED();
- return false;
- }
-
- HWND window = reinterpret_cast<HWND>(window_info->window);
- if (!::IsWindow(window)) {
- // No window created yet. Ignore this call.
- return false;
- }
-
- if (IsWindow()) {
- // We've already subclassed, make sure that SetWindow doesn't get called
- // with an HWND other than the one we subclassed during our lifetime.
- DCHECK(window == m_hWnd);
- return true;
- }
-
- automation_client_->SetParentWindow(window);
-
- if (force_full_page_plugin_) {
- // By default full page mode is only enabled when the plugin is loaded off
- // a separate file, i.e. it is the primary content in the window. Even if
- // we specify the width/height attributes for the plugin as 100% each, FF
- // instantiates the plugin passing in a width/height of 100px each. To
- // workaround this we resize the plugin window passed in by FF to the size
- // of its parent.
- HWND plugin_parent_window = ::GetParent(window);
- RECT plugin_parent_rect = {0};
- ::GetClientRect(plugin_parent_window, &plugin_parent_rect);
- ::SetWindowPos(window, NULL, plugin_parent_rect.left,
- plugin_parent_rect.top,
- plugin_parent_rect.right - plugin_parent_rect.left,
- plugin_parent_rect.bottom - plugin_parent_rect.top, 0);
- }
-
- // Subclass the browser's plugin window here.
- if (SubclassWindow(window)) {
- DWORD new_style_flags = WS_CLIPCHILDREN;
- ModifyStyle(0, new_style_flags, 0);
-
- if (ready_state_ < READYSTATE_INTERACTIVE) {
- SetReadyState(READYSTATE_INTERACTIVE);
- }
- }
-
- return true;
-}
-
-void ChromeFrameNPAPI::Print(NPPrint* print_info) {
- if (!print_info) {
- NOTREACHED();
- return;
- }
-
- // We dont support full tab mode yet.
- if (print_info->mode != NP_EMBED) {
- NOTREACHED();
- return;
- }
-
- NPWindow window = print_info->print.embedPrint.window;
-
- RECT print_bounds = {0};
- print_bounds.left = window.x;
- print_bounds.top = window.y;
- print_bounds.right = window.x + window.width;
- print_bounds.bottom = window.x + window.height;
-
- automation_client_->Print(
- reinterpret_cast<HDC>(print_info->print.embedPrint.platformPrint),
- print_bounds);
-}
-
-void ChromeFrameNPAPI::UrlNotify(const char* url, NPReason reason,
- void* notify_data) {
- if (enabled_popups_) {
- // We have opened the URL so tell the browser to restore popup settings
- enabled_popups_ = false;
- npapi::PopPopupsEnabledState(instance_);
- }
-
- url_fetcher_.UrlNotify(url, reason, notify_data);
-}
-
-void ChromeFrameNPAPI::OnAcceleratorPressed(const MSG& accel_message) {
- DVLOG(1) << __FUNCTION__
- << " msg:" << base::StringPrintf("0x%04X", accel_message.message)
- << " key:" << accel_message.wParam;
-
- // The host browser does call TranslateMessage on messages like WM_KEYDOWN
- // WM_KEYUP, etc, which will result in messages like WM_CHAR, WM_SYSCHAR, etc
- // being posted to the message queue. We don't post these messages here to
- // avoid these messages from getting handled twice.
- if (accel_message.message != WM_CHAR &&
- accel_message.message != WM_DEADCHAR &&
- accel_message.message != WM_SYSCHAR &&
- accel_message.message != WM_SYSDEADCHAR) {
- // A very primitive way to handle keystrokes.
- // TODO(tommi): When we've implemented a way for chrome to
- // know when keystrokes are handled (deterministically) on that side,
- // then this function should get called and not otherwise.
- ::PostMessage(::GetParent(m_hWnd), accel_message.message,
- accel_message.wParam, accel_message.lParam);
- }
-
- if (automation_client_.get()) {
- TabProxy* tab = automation_client_->tab();
- if (tab) {
- tab->ProcessUnhandledAccelerator(accel_message);
- }
- }
-}
-
-void ChromeFrameNPAPI::OnTabbedOut(bool reverse) {
- DVLOG(1) << __FUNCTION__;
-
- ignore_setfocus_ = true;
-
- // Previously we set the focus to our parent window before sending the
- // keyboard event but the browser architecture has changed, so we release
- // our focus first by calling <object>.blur() and then tabbing to the
- // next element.
- ScopedNpObject<NPObject> object;
- npapi::GetValue(instance_, NPNVPluginElementNPObject, object.Receive());
- if (object.get()) {
- ScopedNpVariant result;
- bool invoke = npapi::Invoke(instance_, object,
- npapi::GetStringIdentifier("blur"), NULL, 0, &result);
- DLOG_IF(WARNING, !invoke) << "blur failed";
- } else {
- DLOG(WARNING) << "Failed to get the plugin element";
- }
-
- INPUT input = {0};
- input.type = INPUT_KEYBOARD;
- input.ki.wVk = VK_TAB;
- SendInput(1, &input, sizeof(input));
- input.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &input, sizeof(input));
-
- ignore_setfocus_ = false;
-}
-
-void ChromeFrameNPAPI::OnOpenURL(const GURL& url,
- const GURL& referrer,
- int open_disposition) {
- std::string target;
- switch (open_disposition) {
- case NEW_FOREGROUND_TAB:
- target = "_blank";
- break;
- case NEW_BACKGROUND_TAB:
- target = "_blank";
- break;
- case NEW_WINDOW:
- case NEW_POPUP:
- target = "_new";
- break;
- default:
- break;
- }
-
- // Tell the browser to temporarily allow popups
- enabled_popups_ = true;
- npapi::PushPopupsEnabledState(instance_, TRUE);
- npapi::GetURLNotify(instance_, url.spec().c_str(), target.c_str(), NULL);
-}
-
-bool ChromeFrameNPAPI::HasMethod(NPObject* obj, NPIdentifier name) {
- for (int i = 0; i < arraysize(plugin_methods_); ++i) {
- if (name == plugin_method_identifiers_[i])
- return true;
- }
-
- DLOG(INFO) << "Do not have method: " << npapi::StringFromIdentifier(name);
-
- return false;
-}
-
-bool ChromeFrameNPAPI::Invoke(NPObject* header, NPIdentifier name,
- const NPVariant* args, uint32_t arg_count,
- NPVariant* result) {
- ChromeFrameNPAPI* plugin_instance = ChromeFrameInstanceFromNPObject(header);
- if (!plugin_instance || !plugin_instance->automation_client_.get())
- return false;
-
- bool success = false;
- for (int i = 0; i < arraysize(plugin_methods_); ++i) {
- if (name == plugin_method_identifiers_[i]) {
- PluginMethod method = plugin_methods_[i];
- success = (plugin_instance->*method)(header, args, arg_count, result);
- break;
- }
- }
-
- return success;
-}
-
-void ChromeFrameNPAPI::InitializeIdentifiers() {
- npapi::GetStringIdentifiers(plugin_method_identifier_names_,
- arraysize(plugin_methods_),
- plugin_method_identifiers_);
-
- npapi::GetStringIdentifiers(plugin_property_identifier_names_,
- PLUGIN_PROPERTY_COUNT,
- plugin_property_identifiers_);
-}
-
-NPObject* ChromeFrameNPAPI::AllocateObject(NPP instance, NPClass* class_name) {
- static bool identifiers_initialized = false;
-
- ChromeFrameNPObject* plugin_object = new ChromeFrameNPObject();
- DCHECK(plugin_object != NULL);
-
- plugin_object->chrome_frame_plugin_instance = new ChromeFrameNPAPI();
- DCHECK(plugin_object->chrome_frame_plugin_instance != NULL);
-
- plugin_object->npp = NULL;
-
- COMPILE_ASSERT(arraysize(plugin_method_identifiers_) ==
- arraysize(plugin_method_identifier_names_),
- method_count_mismatch);
-
- COMPILE_ASSERT(arraysize(plugin_method_identifiers_) ==
- arraysize(plugin_methods_),
- method_count_mismatch);
-
- if (!identifiers_initialized) {
- InitializeIdentifiers();
- identifiers_initialized = true;
- }
-
- return reinterpret_cast<NPObject*>(plugin_object);
-}
-
-void ChromeFrameNPAPI::DeallocateObject(NPObject* header) {
- ChromeFrameNPObject* plugin_object =
- reinterpret_cast<ChromeFrameNPObject*>(header);
- DCHECK(plugin_object != NULL);
-
- if (plugin_object) {
- delete plugin_object->chrome_frame_plugin_instance;
- delete plugin_object;
- }
-}
-
-void ChromeFrameNPAPI::Invalidate(NPObject* header) {
- DCHECK(header);
- ChromeFrameNPObject* plugin_object =
- reinterpret_cast<ChromeFrameNPObject*>(header);
- if (plugin_object) {
- DCHECK(plugin_object->chrome_frame_plugin_instance);
- plugin_object->chrome_frame_plugin_instance->Uninitialize();
- }
-}
-
-ChromeFrameNPAPI* ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(
- NPP instance) {
- if ((instance == NULL) || (instance->pdata == NULL)) {
- NOTREACHED();
- return NULL;
- }
-
- return ChromeFrameInstanceFromNPObject(instance->pdata);
-}
-
-ChromeFrameNPAPI* ChromeFrameNPAPI::ChromeFrameInstanceFromNPObject(
- void* object) {
- ChromeFrameNPObject* plugin_object =
- reinterpret_cast<ChromeFrameNPObject*>(object);
- if (!plugin_object) {
- NOTREACHED();
- return NULL;
- }
-
- DCHECK(plugin_object->chrome_frame_plugin_instance);
- return plugin_object->chrome_frame_plugin_instance;
-}
-
-bool ChromeFrameNPAPI::HasProperty(NPObject* obj, NPIdentifier name) {
- for (int i = 0; i < PLUGIN_PROPERTY_COUNT; ++i) {
- if (name == plugin_property_identifiers_[i])
- return true;
- }
- return false;
-}
-
-bool ChromeFrameNPAPI::GetProperty(NPIdentifier name,
- NPVariant* variant) {
- if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_ONERROR]) {
- if (onerror_handler_) {
- variant->type = NPVariantType_Object;
- variant->value.objectValue = onerror_handler_.Copy();
- return true;
- }
- } else if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_ONMESSAGE]) {
- if (onmessage_handler_) {
- variant->type = NPVariantType_Object;
- variant->value.objectValue = onmessage_handler_.Copy();
- return true;
- }
- } else if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_ONCLOSE]) {
- if (onclose_handler_) {
- variant->type = NPVariantType_Object;
- variant->value.objectValue = onclose_handler_.Copy();
- return true;
- }
- } else if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_SRC]) {
- AllocateStringVariant(src_, variant);
- return true;
- } else if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_VERSION]) {
- const std::wstring version =
- automation_client_->GetVersion();
- AllocateStringVariant(WideToUTF8(version), variant);
- return true;
- } else if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_READYSTATE]) {
- INT32_TO_NPVARIANT(ready_state_, *variant);
- return true;
- } else if (name ==
- plugin_property_identifiers_[PLUGIN_PROPERTY_USECHROMENETWORK]) {
- BOOLEAN_TO_NPVARIANT(automation_client_->use_chrome_network(), *variant);
- return true;
- }
-
- return false;
-}
-
-bool ChromeFrameNPAPI::GetProperty(NPObject* object, NPIdentifier name,
- NPVariant* variant) {
- if (!object || !variant) {
- NOTREACHED();
- return false;
- }
-
- ChromeFrameNPAPI* plugin_instance = ChromeFrameInstanceFromNPObject(object);
- if (!plugin_instance) {
- NOTREACHED();
- return false;
- }
-
- return plugin_instance->GetProperty(name, variant);
-}
-
-bool ChromeFrameNPAPI::SetProperty(NPIdentifier name,
- const NPVariant* variant) {
- if (NPVARIANT_IS_OBJECT(*variant)) {
- if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_ONERROR]) {
- onerror_handler_.Free();
- onerror_handler_ = variant->value.objectValue;
- return true;
- } else if (
- name == plugin_property_identifiers_[PLUGIN_PROPERTY_ONMESSAGE]) {
- onmessage_handler_.Free();
- onmessage_handler_ = variant->value.objectValue;
- return true;
- } else if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_ONCLOSE]) {
- onclose_handler_.Free();
- onclose_handler_ = variant->value.objectValue;
- return true;
- }
- } else if (NPVARIANT_IS_STRING(*variant) || NPVARIANT_IS_NULL(*variant)) {
- if (name == plugin_property_identifiers_[PLUGIN_PROPERTY_SRC]) {
- return NavigateToURL(variant, 1, NULL);
- }
- } else if (NPVARIANT_IS_BOOLEAN(*variant)) {
- if (name ==
- plugin_property_identifiers_[PLUGIN_PROPERTY_USECHROMENETWORK]) {
- automation_client_->set_use_chrome_network(
- NPVARIANT_TO_BOOLEAN(*variant));
- }
- }
-
- return false;
-}
-
-bool ChromeFrameNPAPI::SetProperty(NPObject* object, NPIdentifier name,
- const NPVariant* variant) {
- if (!object || !variant) {
- DLOG(ERROR) << "Cannot set property: " << npapi::StringFromIdentifier(name);
- return false;
- }
-
- ChromeFrameNPAPI* plugin_instance = ChromeFrameInstanceFromNPObject(object);
- if (!plugin_instance) {
- NOTREACHED();
- return false;
- }
-
- return plugin_instance->SetProperty(name, variant);
-}
-
-LRESULT CALLBACK ChromeFrameNPAPI::DropKillFocusHook(int code, WPARAM wparam,
- LPARAM lparam) {
- LRESULT ret = 0;
- CWPSTRUCT* wp = reinterpret_cast<CWPSTRUCT*>(lparam);
- if ((code < 0) || (wp->message != WM_KILLFOCUS))
- ret = ::CallNextHookEx(NULL, code, wparam, lparam);
-
- return ret;
-}
-
-LRESULT ChromeFrameNPAPI::OnSetFocus(UINT message, WPARAM wparam,
- LPARAM lparam, BOOL& handled) { // NO_LINT
- // Opera has a WH_CALLWNDPROC hook that handles WM_KILLFOCUS and
- // prevents us from setting the focus to the tab.
- // To work around that, we set a temporary hook here that does nothing
- // (not even call other hooks) when it sees WM_KILLFOCUS.
- HHOOK hook = NULL;
- hook = ::SetWindowsHookEx(WH_CALLWNDPROC, DropKillFocusHook, NULL,
- ::GetCurrentThreadId());
- // Since we chain message maps, make sure we are not calling base class
- // twice for WM_SETFOCUS.
- BOOL handled_by_base = TRUE;
- LRESULT ret = Base::OnSetFocus(message, wparam, lparam, handled_by_base);
- if (hook)
- ::UnhookWindowsHookEx(hook);
-
- return ret;
-}
-
-void ChromeFrameNPAPI::OnLoad(const GURL& gurl) {
- DVLOG(1) << "Firing onload";
- FireEvent("load", gurl.spec());
-}
-
-void ChromeFrameNPAPI::OnLoadFailed(int error_code, const std::string& url) {
- FireEvent("loaderror", url);
-
- ScopedNpVariant result;
- InvokeDefault(onerror_handler_, url, &result);
-}
-
-void ChromeFrameNPAPI::OnMessageFromChromeFrame(const std::string& message,
- const std::string& origin,
- const std::string& target) {
- bool private_message = false;
- if (target.compare("*") != 0) {
- if (is_privileged()) {
- private_message = true;
- } else {
- if (!HaveSameOrigin(target, document_url_)) {
- DLOG(WARNING) << "Dropping posted message since target doesn't match "
- "the current document's origin. target=" << target;
- return;
- }
- }
- }
-
- // Create a MessageEvent object that contains the message and origin
- // as well as supporting other MessageEvent (see the HTML5 spec) properties.
- // Then call the onmessage handler.
- ScopedNpObject<NPObject> event;
- bool ok = CreateMessageEvent(false, true, message, origin, event.Receive());
- if (ok) {
- // Don't call FireEvent here (or we'll have an event wrapped by an event).
- DispatchEvent(event);
-
- ScopedNpVariant result;
- NPVariant params[2];
- OBJECT_TO_NPVARIANT(event, params[0]);
- bool invoke = false;
- if (private_message) {
- DCHECK(is_privileged());
- STRINGN_TO_NPVARIANT(target.c_str(), target.length(), params[1]);
- invoke = InvokeDefault(onprivatemessage_handler_,
- arraysize(params),
- params,
- &result);
- } else {
- invoke = InvokeDefault(onmessage_handler_, params[0], &result);
- }
- DLOG_IF(WARNING, !invoke) << "InvokeDefault failed";
- } else {
- DLOG(WARNING) << "CreateMessageEvent failed, probably exiting";
- }
-}
-
-void ChromeFrameNPAPI::OnAutomationServerReady() {
- Base::OnAutomationServerReady();
-
- if (navigate_after_initialization_ && !src_.empty()) {
- navigate_after_initialization_ = false;
- if (!automation_client_->InitiateNavigation(src_,
- GetDocumentUrl(),
- this)) {
- DLOG(ERROR) << "Failed to navigate to: " << src_;
- src_.clear();
- }
- }
-
- SetReadyState(READYSTATE_COMPLETE);
-}
-
-void ChromeFrameNPAPI::OnAutomationServerLaunchFailed(
- AutomationLaunchResult reason, const std::string& server_version) {
- SetReadyState(READYSTATE_UNINITIALIZED);
-
- // In IE, we don't display warnings for privileged CF instances because
- // there are 2 CFs created for each tab (so we decide on the CEEE side
- // whether to show a warning). In FF however, there is only one privileged
- // CF instance per Firefox window, so OK to show the warning there without
- // any further logic.
- if (reason == AUTOMATION_VERSION_MISMATCH) {
- UMA_HISTOGRAM_COUNTS("ChromeFrame.VersionMismatchDisplayed", 1);
- DisplayVersionMismatchWarning(m_hWnd, server_version);
- }
-}
-
-void ChromeFrameNPAPI::OnCloseTab() {
- std::string arg;
- FireEvent("close", arg);
- ScopedNpVariant result;
- InvokeDefault(onclose_handler_, arg, &result);
-}
-
-bool ChromeFrameNPAPI::InvokeDefault(NPObject* object,
- unsigned param_count,
- const NPVariant* params,
- NPVariant* result) {
- if (!object)
- return false;
-
- bool ret = npapi::InvokeDefault(instance_, object, params, param_count,
- result);
- // InvokeDefault can return false in FF even though we do see the call
- // go through. It's not clear to me what the circumstances are, so
- // we log it as a warning while tracking it down.
- DLOG_IF(WARNING, !ret) << "npapi::InvokeDefault failed";
- return ret;
-}
-
-bool ChromeFrameNPAPI::InvokeDefault(NPObject* object, const std::string& param,
- NPVariant* result) {
- NPVariant arg;
- STRINGN_TO_NPVARIANT(param.c_str(), param.length(), arg);
- return InvokeDefault(object, arg, result);
-}
-
-bool ChromeFrameNPAPI::InvokeDefault(NPObject* object, const NPVariant& param,
- NPVariant* result) {
- return InvokeDefault(object, 1, &param, result);
-}
-
-bool ChromeFrameNPAPI::CreateEvent(const std::string& type, bool bubbles,
- bool cancelable, NPObject** basic_event) {
- DCHECK(basic_event);
- NPObject* window = GetWindowObject();
- if (!window) {
- // Can fail if the browser is closing (seen in Opera).
- return false;
- }
-
- const char* identifier_names[] = {
- "document",
- "createEvent",
- "initEvent",
- };
-
- NPIdentifier identifiers[arraysize(identifier_names)];
- npapi::GetStringIdentifiers(identifier_names, arraysize(identifier_names),
- identifiers);
-
- // Fetch the document object from the window.
- ScopedNpVariant document;
- bool ok = npapi::GetProperty(instance_, window, identifiers[0], &document);
- if (!ok) {
- // This could happen if the page is being unloaded.
- DLOG(WARNING) << "Failed to fetch the document object";
- return false;
- }
-
- bool success = false;
- if (ok && NPVARIANT_IS_OBJECT(document)) {
- // Call document.createEvent("Event") to create a basic event object.
- NPVariant event_type;
- STRINGN_TO_NPVARIANT("Event", sizeof("Event") - 1, event_type);
- ScopedNpVariant result;
- success = npapi::Invoke(instance_, NPVARIANT_TO_OBJECT(document),
- identifiers[1], &event_type, 1, &result);
- if (!NPVARIANT_IS_OBJECT(result)) {
- DLOG(WARNING) << "Failed to invoke createEvent";
- success = false;
- } else {
- NPVariant init_args[3];
- STRINGN_TO_NPVARIANT(type.c_str(), type.length(), init_args[0]);
- BOOLEAN_TO_NPVARIANT(bubbles, init_args[1]);
- BOOLEAN_TO_NPVARIANT(cancelable, init_args[2]);
-
- // Now initialize the event object by calling
- // event.initEvent(type, bubbles, cancelable);
- ScopedNpVariant init_results;
- ok = npapi::Invoke(instance_, NPVARIANT_TO_OBJECT(result), identifiers[2],
- init_args, arraysize(init_args), &init_results);
- if (ok) {
- success = true;
- // Finally, pass the ownership to the caller.
- *basic_event = NPVARIANT_TO_OBJECT(result);
- VOID_TO_NPVARIANT(result); // Prevent the object from being released.
- } else {
- DLOG(ERROR) << "initEvent failed";
- success = false;
- }
- }
- }
-
- return success;
-}
-
-bool ChromeFrameNPAPI::CreateMessageEvent(bool bubbles, bool cancelable,
- const std::string& data,
- const std::string& origin,
- NPObject** message_event) {
- DCHECK(message_event);
- ScopedNpObject<NPObject> event;
- bool ok = CreateEvent("message", false, true, event.Receive());
- if (ok) {
- typedef enum {
- DATA,
- ORIGIN,
- LAST_EVENT_ID,
- SOURCE,
- MESSAGE_PORT,
- IDENTIFIER_COUNT, // Must be last.
- } StringIdentifiers;
-
- static NPIdentifier identifiers[IDENTIFIER_COUNT] = {0};
- if (!identifiers[0]) {
- const NPUTF8* identifier_names[] = {
- "data",
- "origin",
- "lastEventId",
- "source",
- "messagePort",
- };
- COMPILE_ASSERT(arraysize(identifier_names) == arraysize(identifiers),
- mismatched_array_size);
- npapi::GetStringIdentifiers(identifier_names, IDENTIFIER_COUNT,
- identifiers);
- }
-
- NPVariant arg;
- STRINGN_TO_NPVARIANT(data.c_str(), data.length(), arg);
- npapi::SetProperty(instance_, event, identifiers[DATA], &arg);
- STRINGN_TO_NPVARIANT(origin.c_str(), origin.length(), arg);
- npapi::SetProperty(instance_, event, identifiers[ORIGIN], &arg);
- STRINGN_TO_NPVARIANT("", 0, arg);
- npapi::SetProperty(instance_, event, identifiers[LAST_EVENT_ID], &arg);
- NULL_TO_NPVARIANT(arg);
- npapi::SetProperty(instance_, event, identifiers[SOURCE], &arg);
- npapi::SetProperty(instance_, event, identifiers[MESSAGE_PORT], &arg);
- *message_event = event.Detach();
- }
-
- return ok;
-}
-
-
-void ChromeFrameNPAPI::DispatchEvent(NPObject* event) {
- DCHECK(event != NULL);
-
- ScopedNpObject<NPObject> embed;
- npapi::GetValue(instance_, NPNVPluginElementNPObject, &embed);
- if (embed != NULL) {
- NPVariant param;
- OBJECT_TO_NPVARIANT(event, param);
- ScopedNpVariant result;
- bool invoke = npapi::Invoke(instance_, embed,
- npapi::GetStringIdentifier("dispatchEvent"), &param, 1, &result);
- DLOG_IF(WARNING, !invoke) << "dispatchEvent failed";
- } else {
- DLOG(WARNING) << "ChromeFrameNPAPI::DispatchEvent failed, probably exiting";
- }
-}
-
-bool ChromeFrameNPAPI::ExecuteScript(const std::string& script,
- NPVariant* result) {
- NPObject* window = GetWindowObject();
- if (!window) {
- NOTREACHED();
- return false;
- }
-
- NPString script_for_execution;
- script_for_execution.UTF8Characters = script.c_str();
- script_for_execution.UTF8Length = script.length();
-
- return npapi::Evaluate(instance_, window, &script_for_execution, result);
-}
-
-NPObject* ChromeFrameNPAPI::JavascriptToNPObject(const std::string& script) {
- // Convert the passed in script to an invocable NPObject
- // To achieve this we save away the function in a dummy window property
- // which is then read to get the script object representing the function.
-
- std::string script_code =
- "javascript:window.__cf_get_function_object =";
-
- // If we are able to look up the name in the javascript namespace, then it
- // means that the caller passed in a function name. Convert the function
- // name to a NPObject we can invoke on.
- if (IsValidJavascriptFunction(script)) {
- script_code += script;
- } else {
- script_code += "new Function(\"";
- script_code += script;
- script_code += "\");";
- }
-
- NPVariant result;
- if (!ExecuteScript(script_code, &result)) {
- NOTREACHED();
- return NULL;
- }
-
- DCHECK(result.type == NPVariantType_Object);
- DCHECK(result.value.objectValue != NULL);
- return result.value.objectValue;
-}
-
-bool ChromeFrameNPAPI::IsValidJavascriptFunction(const std::string& script) {
- std::string script_code = "javascript:window['";
- script_code += script;
- script_code += "'];";
-
- ScopedNpVariant result;
- if (!ExecuteScript(script_code, &result)) {
- NOTREACHED();
- return NULL;
- }
-
- return result.type == NPVariantType_Object;
-}
-
-bool ChromeFrameNPAPI::NavigateToURL(const NPVariant* args, uint32_t arg_count,
- NPVariant* result) {
- // Note that 'result' might be NULL.
- if (arg_count != 1 || !(NPVARIANT_IS_STRING(args[0]) ||
- NPVARIANT_IS_NULL(args[0]))) {
- NOTREACHED();
- return false;
- }
-
- if (ready_state_ == READYSTATE_UNINITIALIZED) {
- // Error(L"Chrome Frame failed to initialize.");
- // TODO(tommi): call NPN_SetException
- DLOG(WARNING) << "NavigateToURL called after failed initialization";
- return false;
- }
-
- std::string url("about:blank");
- if (!NPVARIANT_IS_NULL(args[0])) {
- const NPString& str = args[0].value.stringValue;
- if (str.UTF8Length) {
- url.assign(std::string(str.UTF8Characters, str.UTF8Length));
- }
- }
-
- GURL document_url(GetDocumentUrl());
- if (document_url.SchemeIsSecure()) {
- GURL source_url(url);
- if (!source_url.SchemeIsSecure()) {
- DLOG(WARNING) << __FUNCTION__ << " Prevnting navigation to HTTP url"
- " since the containing document is HTTPS. URL: " << source_url <<
- " Document URL: " << document_url;
- return false;
- }
- }
-
- std::string full_url = ResolveURL(GetDocumentUrl(), url);
-
- src_ = full_url;
- // Navigate only if we completed initialization i.e. proxy is set etc.
- if (ready_state_ == READYSTATE_COMPLETE) {
- if (!automation_client_->InitiateNavigation(full_url,
- GetDocumentUrl(),
- this)) {
- // TODO(tommi): call NPN_SetException.
- src_.clear();
- return false;
- }
- } else {
- navigate_after_initialization_ = true;
- }
- return true;
-}
-
-bool ChromeFrameNPAPI::postMessage(NPObject* npobject, const NPVariant* args,
- uint32_t arg_count, NPVariant* result) {
- // TODO(tommi) See if we can factor these checks out somehow.
- if (arg_count < 1 || arg_count > 2 || !NPVARIANT_IS_STRING(args[0])) {
- NOTREACHED();
- return false;
- }
-
- const NPString& str = args[0].value.stringValue;
- std::string message(str.UTF8Characters, str.UTF8Length);
- std::string target;
- if (arg_count == 2 && NPVARIANT_IS_STRING(args[1])) {
- const NPString& str = args[1].value.stringValue;
- target.assign(str.UTF8Characters, str.UTF8Length);
- if (target.compare("*") != 0) {
- GURL resolved(target);
- if (!resolved.is_valid()) {
- npapi::SetException(npobject,
- "Unable to parse the specified target URL.");
- return false;
- }
- target = resolved.spec();
- }
- } else {
- target = "*";
- }
-
- GURL url(GURL(document_url_).GetOrigin());
- std::string origin(url.is_empty() ? "null" : url.spec());
-
- automation_client_->ForwardMessageFromExternalHost(message, origin, target);
-
- return true;
-}
-
-void ChromeFrameNPAPI::FireEvent(const std::string& event_type,
- const std::string& data) {
- NPVariant arg;
- STRINGN_TO_NPVARIANT(data.c_str(), data.length(), arg);
- FireEvent(event_type, arg);
-}
-
-void ChromeFrameNPAPI::FireEvent(const std::string& event_type,
- const NPVariant& data) {
- // Check that we're not bundling an event inside an event.
- // Right now we're only expecting simple types for the data argument.
- DCHECK(NPVARIANT_IS_OBJECT(data) == false);
-
- ScopedNpObject<NPObject> ev;
- CreateEvent(event_type, false, false, ev.Receive());
- if (ev) {
- // Add the 'data' member to the event.
- bool set = npapi::SetProperty(instance_, ev,
- npapi::GetStringIdentifier("data"), const_cast<NPVariant*>(&data));
- DCHECK(set);
- DispatchEvent(ev);
- }
-}
-
-NPObject* ChromeFrameNPAPI::GetWindowObject() const {
- if (!window_object_.get() && instance_) {
- NPError ret = npapi::GetValue(instance_, NPNVWindowNPObject,
- window_object_.Receive());
- DLOG_IF(ERROR, ret != NPERR_NO_ERROR) << "NPNVWindowNPObject failed";
- }
- return window_object_;
-}
-
-bool ChromeFrameNPAPI::GetBrowserIncognitoMode() {
- bool incognito_mode = false;
-
- // Check disabled for Opera due to bug:
- // http://code.google.com/p/chromium/issues/detail?id=24287
- if (GetBrowserType() != BROWSER_OPERA) {
- // Check whether host browser is in private mode;
- NPBool private_mode = FALSE;
- NPError err = npapi::GetValue(instance_,
- NPNVprivateModeBool,
- &private_mode);
- if (err == NPERR_NO_ERROR && private_mode) {
- incognito_mode = true;
- }
- } else {
- DLOG(WARNING) << "Not checking for private mode in Opera";
- }
-
- return incognito_mode;
-}
-
-bool ChromeFrameNPAPI::PreProcessContextMenu(HMENU menu) {
- // TODO: Remove this overridden method once HandleContextMenuCommand
- // implements "About Chrome Frame" handling.
- if (!is_privileged()) {
- // Call base class (adds 'About' item).
- return ChromeFramePlugin::PreProcessContextMenu(menu);
- }
- return true;
-}
-
-bool ChromeFrameNPAPI::HandleContextMenuCommand(
- UINT cmd, const MiniContextMenuParams& params) {
- if (cmd == IDC_ABOUT_CHROME_FRAME) {
- // TODO: implement "About Chrome Frame"
- }
- return false;
-}
-
-NPError ChromeFrameNPAPI::NewStream(NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16* stream_type) {
- return url_fetcher_.NewStream(type, stream, seekable, stream_type);
-}
-
-int32 ChromeFrameNPAPI::WriteReady(NPStream* stream) {
- return url_fetcher_.WriteReady(stream);
-}
-
-int32 ChromeFrameNPAPI::Write(NPStream* stream, int32 offset, int32 len,
- void* buffer) {
- return url_fetcher_.Write(stream, offset, len, buffer);
-}
-
-NPError ChromeFrameNPAPI::DestroyStream(NPStream* stream, NPReason reason) {
- return url_fetcher_.DestroyStream(stream, reason);
-}
-
-void ChromeFrameNPAPI::URLRedirectNotify(const char* url, int status,
- void* notify_data) {
- DVLOG(1) << __FUNCTION__
- << "Received redirect notification for url:"
- << url;
- // Inform chrome about the redirect and disallow the current redirect
- // attempt.
- url_fetcher_.UrlRedirectNotify(url, status, notify_data);
- npapi::URLRedirectResponse(instance_, notify_data, false);
-}
diff --git a/chrome_frame/chrome_frame_npapi.h b/chrome_frame/chrome_frame_npapi.h
deleted file mode 100644
index 135c6ee..0000000
--- a/chrome_frame/chrome_frame_npapi.h
+++ /dev/null
@@ -1,298 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_FRAME_CHROME_FRAME_NPAPI_H_
-#define CHROME_FRAME_CHROME_FRAME_NPAPI_H_
-
-#include <atlbase.h>
-#include <atlwin.h>
-#include <string>
-
-#include "chrome_frame/chrome_frame_automation.h"
-#include "chrome_frame/chrome_frame_plugin.h"
-#include "chrome_frame/np_browser_functions.h"
-#include "chrome_frame/npapi_url_request.h"
-
-class MessageLoop;
-class nsICookieService;
-class nsIURI;
-
-// ChromeFrameNPAPI: Implementation of the NPAPI plugin, which is responsible
-// for hosting a chrome frame, i.e. an iframe like widget which hosts the the
-// chrome window. This object delegates to Chrome.exe (via the Chrome
-// IPC-based automation mechanism) for the actual rendering.
-class ChromeFrameNPAPI
- : public CWindowImpl<ChromeFrameNPAPI>,
- public ChromeFramePlugin<ChromeFrameNPAPI> {
- public:
- typedef ChromeFramePlugin<ChromeFrameNPAPI> Base;
-
- // NPObject structure which is exposed by us.
- struct ChromeFrameNPObject : public NPObject {
- NPP npp;
- ChromeFrameNPAPI* chrome_frame_plugin_instance;
- };
-
- typedef enum {
- PLUGIN_PROPERTY_VERSION,
- PLUGIN_PROPERTY_SRC,
- PLUGIN_PROPERTY_ONLOAD,
- PLUGIN_PROPERTY_ONERROR,
- PLUGIN_PROPERTY_ONMESSAGE,
- PLUGIN_PROPERTY_READYSTATE,
- PLUGIN_PROPERTY_USECHROMENETWORK,
- PLUGIN_PROPERTY_ONCLOSE,
- PLUGIN_PROPERTY_COUNT // must be last
- } PluginPropertyId;
-
- static const int kWmSwitchFocusToChromeFrame = WM_APP + 0x100;
-
- static NPClass plugin_class_;
- static NPClass* PluginClass() {
- return &plugin_class_;
- }
-
- ChromeFrameNPAPI();
- ~ChromeFrameNPAPI();
-
- bool Initialize(NPMIMEType mime_type, NPP instance, uint16 mode,
- int16 argc, char* argn[], char* argv[]);
- void Uninitialize();
-
- bool SetWindow(NPWindow* window_info);
- void UrlNotify(const char* url, NPReason reason, void* notify_data);
- NPError NewStream(NPMIMEType type, NPStream* stream, NPBool seekable,
- uint16* stream_type);
- int32 WriteReady(NPStream* stream);
- int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer);
- NPError DestroyStream(NPStream* stream, NPReason reason);
-
- void Print(NPPrint* print_info);
- void URLRedirectNotify(const char* url, int status, void* notify_data);
-
- // NPObject functions, which ensure that the plugin object is scriptable.
- static bool HasMethod(NPObject* obj, NPIdentifier name);
- static bool Invoke(NPObject* header, NPIdentifier name,
- const NPVariant* args, uint32_t arg_count,
- NPVariant* result);
- static NPObject* AllocateObject(NPP instance, NPClass* class_name);
- static void DeallocateObject(NPObject* header);
-
- // Called by the scripting environment when the native code is shutdown.
- // Any attempt to message a NPObject instance after the invalidate callback
- // has been called will result in undefined behavior, even if the native code
- // is still retaining those NPObject instances.
- static void Invalidate(NPObject* header);
-
- // The following functions need to be implemented to ensure that FF3
- // invokes methods on the plugin. If these methods are not implemented
- // then invokes on the plugin NPObject from the script fail with a
- // bad NPObject error.
- static bool HasProperty(NPObject* obj, NPIdentifier name);
- static bool GetProperty(NPObject* obj, NPIdentifier name, NPVariant *variant);
- static bool SetProperty(NPObject* obj, NPIdentifier name,
- const NPVariant *variant);
-
- // Returns the ChromeFrameNPAPI object pointer from the NPP instance structure
- // passed in by the browser.
- static ChromeFrameNPAPI* ChromeFrameInstanceFromPluginInstance(NPP instance);
-
- // Returns the ChromeFrameNPAPI object pointer from the NPObject structure
- // which represents our plugin class.
- static ChromeFrameNPAPI* ChromeFrameInstanceFromNPObject(void* object);
-
-BEGIN_MSG_MAP(ChromeFrameNPAPI)
- MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
- CHAIN_MSG_MAP(Base)
-END_MSG_MAP()
-
- LRESULT OnSetFocus(UINT message, WPARAM wparam, LPARAM lparam,
- BOOL& handled); // NO_LINT
- // Implementation of SetProperty, public to allow unittesting.
- bool SetProperty(NPIdentifier name, const NPVariant *variant);
- // Implementation of GetProperty, public to allow unittesting.
- bool GetProperty(NPIdentifier name, NPVariant *variant);
-
- // Initialize string->identifier mapping, public to allow unittesting.
- static void InitializeIdentifiers();
-
- bool PreProcessContextMenu(HMENU menu);
- bool HandleContextMenuCommand(UINT cmd, const MiniContextMenuParams& params);
- protected:
- // Handler for accelerator messages passed on from the hosted chrome
- // instance.
- virtual void OnAcceleratorPressed(const MSG& accel_message);
- virtual void OnTabbedOut(bool reverse);
- virtual void OnOpenURL(const GURL& url, const GURL& referrer,
- int open_disposition);
- virtual void OnLoad(const GURL& url);
- virtual void OnMessageFromChromeFrame(const std::string& message,
- const std::string& origin,
- const std::string& target);
- // ChromeFrameDelegate overrides
- virtual void OnLoadFailed(int error_code, const std::string& url);
- virtual void OnAutomationServerReady();
- virtual void OnAutomationServerLaunchFailed(
- AutomationLaunchResult reason, const std::string& server_version);
- virtual void OnCloseTab();
-
- private:
- // Equivalent of:
- // event = window.document.createEvent("Event");
- // event.initEvent(type, bubbles, cancelable);
- // and then returns the event object.
- bool CreateEvent(const std::string& type, bool bubbles, bool cancelable,
- NPObject** basic_event);
-
- // Creates and initializes an event object of type "message".
- // Used for postMessage.
- bool CreateMessageEvent(bool bubbles, bool cancelable,
- const std::string& data, const std::string& origin,
- NPObject** message_event);
-
- // Calls chrome_frame.dispatchEvent to fire events to event listeners.
- void DispatchEvent(NPObject* event);
-
- // Prototype for all methods that can be invoked from script.
- typedef bool (ChromeFrameNPAPI::*PluginMethod)(NPObject* npobject,
- const NPVariant* args,
- uint32_t arg_count,
- NPVariant* result);
-
- // Implementations of scriptable methods.
-
- bool NavigateToURL(const NPVariant* args, uint32_t arg_count,
- NPVariant* result);
-
- bool postMessage(NPObject* npobject, const NPVariant* args,
- uint32_t arg_count, NPVariant* result);
-
- // Pointers to method implementations.
- static PluginMethod plugin_methods_[];
-
- // NPObject method ids exposed by the plugin.
- static NPIdentifier plugin_method_identifiers_[];
-
- // NPObject method names exposed by the plugin.
- static const NPUTF8* plugin_method_identifier_names_[];
-
- // NPObject property ids exposed by the plugin.
- static NPIdentifier plugin_property_identifiers_[];
-
- // NPObject property names exposed by the plugin.
- static const NPUTF8*
- plugin_property_identifier_names_[];
-
- virtual void OnFinalMessage(HWND window);
-
- // Helper function to invoke a function on a NPObject.
- bool InvokeDefault(NPObject* object, const std::string& param,
- NPVariant* result);
-
- bool InvokeDefault(NPObject* object, const NPVariant& param,
- NPVariant* result);
-
- bool InvokeDefault(NPObject* object, unsigned param_count,
- const NPVariant* params, NPVariant* result);
-
- // Helper function to convert javascript code to a NPObject we can
- // invoke on.
- virtual NPObject* JavascriptToNPObject(const std::string& function_name);
-
- // Helper function to execute a script.
- // Returns S_OK on success.
- bool ExecuteScript(const std::string& script, NPVariant* result);
-
- // Returns true if the script passed in is a valid function in the DOM.
- bool IsValidJavascriptFunction(const std::string& script);
-
- // Converts the data parameter to an NPVariant and forwards the call to the
- // other FireEvent method.
- void FireEvent(const std::string& event_type, const std::string& data);
-
- // Creates an event object, assigns the data parameter to a |data| property
- // on the event object and then calls DispatchEvent to fire the event to
- // listeners. event_type is the name of the event being fired.
- void FireEvent(const std::string& event_type, const NPVariant& data);
-
- // Returns our associated windows' location.
- virtual std::string GetLocation();
-
- // Returns true iff we're successfully able to query for the browser's
- // incognito mode, and the browser returns true.
- virtual bool GetBrowserIncognitoMode();
-
- // Returns the window script object for the page.
- // This function will cache the window object to avoid calling
- // npapi::GetValue which can cause problems in Opera.
- NPObject* GetWindowObject() const;
-
- virtual void SetReadyState(READYSTATE new_state) {
- ready_state_ = new_state;
- NPVariant var;
- INT32_TO_NPVARIANT(ready_state_, var);
- FireEvent("readystatechanged", var);
- }
-
- // Host function to compile-time asserts over members of this class.
- static void CompileAsserts();
-
- static LRESULT CALLBACK DropKillFocusHook(int code, WPARAM wparam,
- LPARAM lparam); // NO_LINT
-
- // The plugins opaque instance handle
- NPP instance_;
-
- // The plugin instantiation mode (NP_FULL or NP_EMBED)
- int16 mode_;
- // The plugins mime type.
- std::string mime_type_;
-
- // Set to true if we need a full page plugin.
- bool force_full_page_plugin_;
-
- // In some cases the IPC channel proxy object is instantiated on the UI
- // thread in FF. It then tries to use the IPC logger, which relies on
- // the message loop being around. Declaring a dummy message loop
- // is a hack to get around this. Eventually the automation code needs to
- // be fixed to ensure that the channel proxy always gets created on a thread
- // with a message loop.
- static MessageLoop* message_loop_;
- static int instance_count_;
-
- // The following members contain the NPObject pointers representing the
- // onload/onerror/onmessage handlers on the page.
- ScopedNpObject<NPObject> onerror_handler_;
- ScopedNpObject<NPObject> onmessage_handler_;
- ScopedNpObject<NPObject> onprivatemessage_handler_;
- ScopedNpObject<NPObject> onclose_handler_;
-
- // As a workaround for a problem in Opera we cache the window object.
- // The problem stems from two things: window messages aren't always removed
- // from the message queue and messages can be pumped inside GetValue.
- // This can cause an infinite recursion of processing the same message
- // repeatedly.
- mutable ScopedNpObject<NPObject> window_object_;
-
- // Note since 'onload' is a registered event name, the browser will
- // automagically create a code block for the handling code and hook it
- // up to the CF object via addEventListener.
- // See this list of known event types:
- // http://www.w3.org/TR/DOM-Level-3-Events/events.html#Event-types
-
- READYSTATE ready_state_;
-
- // Popups are enabled
- bool enabled_popups_;
-
- // The value of src property keeping the current URL.
- std::string src_;
- // Used to fetch network resources when host network stack is in use.
- NPAPIUrlRequestManager url_fetcher_;
-
- // Set if we receive a navigation request before initializing Chrome.
- bool navigate_after_initialization_;
-};
-
-#endif // CHROME_FRAME_CHROME_FRAME_NPAPI_H_
diff --git a/chrome_frame/chrome_frame_npapi_entrypoints.cc b/chrome_frame/chrome_frame_npapi_entrypoints.cc
deleted file mode 100644
index 17eba60..0000000
--- a/chrome_frame/chrome_frame_npapi_entrypoints.cc
+++ /dev/null
@@ -1,218 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome_frame/chrome_frame_npapi_entrypoints.h"
-#include "chrome_frame/chrome_frame_npapi.h"
-
-#define NPAPI WINAPI
-
-// Plugin entry points.
-extern "C" {
- NPError NPAPI NP_Initialize(NPNetscapeFuncs* browser_funcs);
- NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs);
- void NPAPI NP_Shutdown();
-}
-
-NPError NPAPI NP_Initialize(NPNetscapeFuncs* browser_funcs) {
- DVLOG(1) << __FUNCTION__;
- _pAtlModule->Lock();
- npapi::InitializeBrowserFunctions(browser_funcs);
- return NPERR_NO_ERROR;
-}
-
-NPError NPAPI NP_GetEntryPoints(NPPluginFuncs* plugin_funcs) {
- plugin_funcs->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
- plugin_funcs->size = sizeof(plugin_funcs);
- plugin_funcs->newp = chrome_frame::NPP_New;
- plugin_funcs->destroy = chrome_frame::NPP_Destroy;
- plugin_funcs->setwindow = chrome_frame::NPP_SetWindow;
- plugin_funcs->newstream = chrome_frame::NPP_NewStream;
- plugin_funcs->destroystream = chrome_frame::NPP_DestroyStream;
- plugin_funcs->asfile = NULL;
- plugin_funcs->writeready = chrome_frame::NPP_WriteReady;
- plugin_funcs->write = chrome_frame::NPP_Write;
- plugin_funcs->print = chrome_frame::NPP_Print;
- plugin_funcs->event = NULL;
- plugin_funcs->urlnotify = chrome_frame::NPP_URLNotify;
- plugin_funcs->getvalue = chrome_frame::NPP_GetValue;
- plugin_funcs->setvalue = chrome_frame::NPP_SetValue;
- plugin_funcs->urlredirectnotify = chrome_frame::NPP_URLRedirectNotify;
- return NPERR_NO_ERROR;
-}
-
-void NPAPI NP_Shutdown() {
- DVLOG(1) << __FUNCTION__;
-
- npapi::UninitializeBrowserFunctions();
-
- _pAtlModule->Unlock(); // matches Lock() inside NP_Initialize
-
- DLOG_IF(ERROR, _pAtlModule->GetLockCount() != 0)
- << "Being shut down but still have " << _pAtlModule->GetLockCount()
- << " living objects";
-}
-
-
-namespace chrome_frame {
-
-NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc,
- char* argn[], char* argv[], NPSavedData* saved) {
- if (instance == NULL)
- return NPERR_INVALID_INSTANCE_ERROR;
-
- ChromeFrameNPAPI::ChromeFrameNPObject* chrome_frame_npapi_obj =
- reinterpret_cast<ChromeFrameNPAPI::ChromeFrameNPObject*>(
- npapi::CreateObject(instance, ChromeFrameNPAPI::PluginClass()));
- DCHECK(chrome_frame_npapi_obj != NULL);
-
- ChromeFrameNPAPI* plugin_instance =
- chrome_frame_npapi_obj->chrome_frame_plugin_instance;
- DCHECK(plugin_instance != NULL);
-
- // Note that we MUST set instance->pdata BEFORE calling Initialize. This is
- // because Initialize can call back into the NPAPI host which will need the
- // pdata field to be set.
- chrome_frame_npapi_obj->chrome_frame_plugin_instance =
- plugin_instance;
- instance->pdata = chrome_frame_npapi_obj;
-
- bool init = plugin_instance->Initialize(plugin_type, instance,
- mode, argc, argn, argv);
- DCHECK(init);
-
- return NPERR_NO_ERROR;
-}
-
-NPError NPP_Destroy(NPP instance, NPSavedData** save) {
- // Takes ownership and releases the object at the end of scope.
- ScopedNpObject<ChromeFrameNPAPI::ChromeFrameNPObject> chrome_frame_npapi_obj(
- reinterpret_cast<ChromeFrameNPAPI::ChromeFrameNPObject*>(
- instance->pdata));
-
- if (chrome_frame_npapi_obj.get()) {
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
-
- plugin_instance->Uninitialize();
- instance->pdata = NULL;
- }
-
- return NPERR_NO_ERROR;
-}
-
-NPError NPP_SetWindow(NPP instance, NPWindow* window_info) {
- if (window_info == NULL) {
- NOTREACHED();
- return NPERR_GENERIC_ERROR;
- }
-
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
-
- if (plugin_instance == NULL) {
- return NPERR_INVALID_INSTANCE_ERROR;
- }
-
- plugin_instance->SetWindow(window_info);
- return NPERR_NO_ERROR;
-}
-
-NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16* stream_type) {
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
- if (plugin_instance == NULL) {
- return NPERR_INVALID_INSTANCE_ERROR;
- }
-
- return plugin_instance->NewStream(type, stream, seekable, stream_type);
-}
-
-NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason) {
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
- if (plugin_instance == NULL) {
- return NPERR_INVALID_INSTANCE_ERROR;
- }
-
- return plugin_instance->DestroyStream(stream, reason);
-}
-
-NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value) {
- if (variable == NPPVpluginScriptableNPObject) {
- void** plugin = reinterpret_cast<void**>(value);
- ChromeFrameNPAPI::ChromeFrameNPObject* chrome_frame_npapi_obj =
- reinterpret_cast<ChromeFrameNPAPI::ChromeFrameNPObject*>(
- instance->pdata);
- // Return value is expected to be retained
- npapi::RetainObject(reinterpret_cast<NPObject*>(chrome_frame_npapi_obj));
- *plugin = chrome_frame_npapi_obj;
- return NPERR_NO_ERROR;
- }
- return NPERR_GENERIC_ERROR;
-}
-
-NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value) {
- return NPERR_GENERIC_ERROR;
-}
-
-int32 NPP_WriteReady(NPP instance, NPStream* stream) {
- static const int kMaxBytesForPluginConsumption = 0x7FFFFFFF;
-
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
-
- if (plugin_instance == NULL) {
- return kMaxBytesForPluginConsumption;
- }
-
- return plugin_instance->WriteReady(stream);
-}
-
-int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
- void* buffer) {
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
-
- if (plugin_instance == NULL)
- return len;
-
- return plugin_instance->Write(stream, offset, len, buffer);
-}
-
-void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
- void* notifyData) {
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
- if (plugin_instance) {
- plugin_instance->UrlNotify(url, reason, notifyData);
- }
-}
-
-void NPP_Print(NPP instance, NPPrint* print_info) {
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
-
- if (plugin_instance == NULL) {
- NOTREACHED() << "Failed to find plugin instance";
- return;
- }
-
- plugin_instance->Print(print_info);
-}
-
-void NPP_URLRedirectNotify(NPP instance, const char* url, int status,
- void* notify_data) {
- ChromeFrameNPAPI* plugin_instance =
- ChromeFrameNPAPI::ChromeFrameInstanceFromPluginInstance(instance);
-
- if (plugin_instance == NULL) {
- NOTREACHED() << "Failed to find plugin instance";
- npapi::URLRedirectResponse(instance, notify_data, false);
- return;
- }
- plugin_instance->URLRedirectNotify(url, status, notify_data);
-}
-
-} // namespace chrome_frame
diff --git a/chrome_frame/chrome_frame_npapi_entrypoints.h b/chrome_frame/chrome_frame_npapi_entrypoints.h
deleted file mode 100644
index e3925a8..0000000
--- a/chrome_frame/chrome_frame_npapi_entrypoints.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_FRAME_CHROME_FRAME_NPAPI_ENTRYPOINTS_H_
-#define CHROME_FRAME_CHROME_FRAME_NPAPI_ENTRYPOINTS_H_
-
-#include "chrome_frame/np_browser_functions.h"
-
-namespace chrome_frame {
-
-NPError NPP_New(NPMIMEType plugin_type, NPP instance, uint16 mode, int16 argc,
- char* argn[], char* argv[], NPSavedData* saved);
-
-NPError NPP_Destroy(NPP instance, NPSavedData** save);
-
-NPError NPP_SetWindow(NPP instance, NPWindow* window_info);
-
-NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16* stream_type);
-
-NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
-
-NPError NPP_GetValue(NPP instance, NPPVariable variable, void* value);
-
-NPError NPP_SetValue(NPP instance, NPNVariable variable, void* value);
-
-int32 NPP_WriteReady(NPP instance, NPStream* stream);
-
-int32 NPP_Write(NPP instance, NPStream* stream, int32 offset, int32 len,
- void* buffer);
-void NPP_URLNotify(NPP instance, const char* url, NPReason reason,
- void* notifyData);
-
-void NPP_Print(NPP instance, NPPrint* print_info);
-void NPP_URLRedirectNotify(NPP instance, const char* url, int status,
- void* notify_data);
-} // namespace chrome_frame
-
-#endif // CHROME_FRAME_CHROME_FRAME_NPAPI_ENTRYPOINTS_H_
diff --git a/chrome_frame/chrome_frame_npapi_unittest.cc b/chrome_frame/chrome_frame_npapi_unittest.cc
deleted file mode 100644
index c570cd0..0000000
--- a/chrome_frame/chrome_frame_npapi_unittest.cc
+++ /dev/null
@@ -1,176 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gtest/gtest.h"
-#include "gmock/gmock.h"
-#include "chrome_frame/chrome_frame_automation.h"
-#include "chrome_frame/chrome_frame_npapi.h"
-
-TEST(ChromeFrameNPAPI, DoesNotCrashOnConstruction) {
- ChromeFrameNPAPI* api = new ChromeFrameNPAPI();
- delete api;
-}
-
-// All mocks in the anonymous namespace.
-namespace {
-
-using ::testing::_;
-using ::testing::Eq;
-using ::testing::Field;
-using ::testing::Invoke;
-using ::testing::Return;
-using ::testing::StrEq;
-
-const char* kMimeType = "application/chromeframe";
-// The default profile name is by default derived from the currently
-// running executable's name.
-const wchar_t* kDefaultProfileName = L"chrome_frame_unittests";
-
-
-class MockNPAPI: public ChromeFrameNPAPI {
- public:
- MockNPAPI() : mock_automation_client_(NULL) {}
- MOCK_METHOD0(GetLocation, std::string());
- MOCK_METHOD0(GetBrowserIncognitoMode, bool());
-
- MOCK_METHOD1(JavascriptToNPObject, virtual NPObject*(const std::string&));
-
- // Make public for test purposes
- void OnAutomationServerReady() {
- ChromeFrameNPAPI::OnAutomationServerReady();
- }
-
- ChromeFrameAutomationClient* CreateAutomationClient() {
- return mock_automation_client_;
- }
-
- ChromeFrameAutomationClient* mock_automation_client_;
-};
-
-class MockAutomationClient: public ChromeFrameAutomationClient {
- public:
- MOCK_METHOD2(Initialize, bool(ChromeFrameDelegate*,
- ChromeFrameLaunchParams*));
-};
-
-namespace {
-
-MATCHER_P4(LaunchParamEq, version_check, extra, incognito, widget,
- "Basic check for ChromeFrameLaunchParams") {
- return arg->version_check() == version_check &&
- arg->extra_arguments().compare(extra) == 0 &&
- arg->incognito() == incognito,
- arg->widget_mode() == widget;
-}
-
-
-static const NPIdentifier kOnPrivateMessageId =
- reinterpret_cast<NPIdentifier>(0x100);
-static const NPIdentifier kPostPrivateMessageId =
- reinterpret_cast<NPIdentifier>(0x100);
-}
-
-class MockNetscapeFuncs {
- public:
- MockNetscapeFuncs() {
- CHECK(NULL == current_);
- current_ = this;
- }
-
- ~MockNetscapeFuncs() {
- CHECK(this == current_);
- current_ = NULL;
- }
-
- MOCK_METHOD3(GetValue, NPError(NPP, NPNVariable, void *));
- MOCK_METHOD3(GetStringIdentifiers, void(const NPUTF8 **,
- int32_t,
- NPIdentifier *)); // NOLINT
- MOCK_METHOD1(RetainObject, NPObject*(NPObject*)); // NOLINT
- MOCK_METHOD1(ReleaseObject, void(NPObject*)); // NOLINT
-
- static const NPNetscapeFuncs* netscape_funcs() {
- return &netscape_funcs_;
- }
-
- private:
- static NPError MockGetValue(NPP instance,
- NPNVariable variable,
- void *ret_value) {
- DCHECK(current_);
- return current_->GetValue(instance, variable, ret_value);
- }
-
- static void MockGetStringIdentifiers(const NPUTF8 **names,
- int32_t name_count,
- NPIdentifier *identifiers) {
- DCHECK(current_);
- return current_->GetStringIdentifiers(names, name_count, identifiers);
- }
-
- static NPObject* MockRetainObject(NPObject* obj) {
- DCHECK(current_);
- return current_->RetainObject(obj);
- }
-
- static void MockReleaseObject(NPObject* obj) {
- DCHECK(current_);
- current_->ReleaseObject(obj);
- }
-
- static MockNetscapeFuncs* current_;
- static NPNetscapeFuncs netscape_funcs_;
-};
-
-// Test fixture to allow testing the privileged NPAPI APIs
-class TestNPAPIPrivilegedApi: public ::testing::Test {
- public:
- virtual void SetUp() {
- memset(&instance, 0, sizeof(instance));
- npapi::InitializeBrowserFunctions(
- const_cast<NPNetscapeFuncs*>(mock_funcs.netscape_funcs()));
-
- // Gets owned & destroyed by mock_api (in the
- // ChromeFramePlugin<T>::Uninitialize() function).
- mock_automation = new MockAutomationClient;
-
- mock_api.mock_automation_client_ = mock_automation;
- }
-
- virtual void TearDown() {
- // Make sure to uninitialize the mock NPAPI before we uninitialize the
- // browser function, otherwise we will get a DCHECK in the NPAPI dtor
- // when it tries to perform the uninitialize there.
- mock_api.Uninitialize();
- npapi::UninitializeBrowserFunctions();
- }
-
- void SetupPrivilegeTest(bool is_incognito,
- bool expect_privilege_check,
- bool is_privileged,
- const std::wstring& profile_name,
- const std::wstring& language,
- const std::wstring& extra_args) {
- EXPECT_CALL(mock_api, GetLocation())
- .WillOnce(Return(std::string("http://www.google.com")));
- EXPECT_CALL(mock_api, GetBrowserIncognitoMode())
- .WillOnce(Return(is_incognito));
-
- scoped_refptr<ChromeFrameLaunchParams> launch_params(
- new ChromeFrameLaunchParams(GURL(), GURL(), FilePath(), profile_name,
- language, extra_args, is_incognito, true, false));
-
- EXPECT_CALL(*mock_automation,
- Initialize(_, LaunchParamEq(true, extra_args, is_incognito, true)))
- .WillOnce(Return(true));
- }
-
- public:
- MockNetscapeFuncs mock_funcs;
- MockNPAPI mock_api;
- MockAutomationClient* mock_automation;
- NPP_t instance;
-};
-
-} // namespace
diff --git a/chrome_frame/chrome_frame_plugin.h b/chrome_frame/chrome_frame_plugin.h
index b1a52bc..af4242a 100644
--- a/chrome_frame/chrome_frame_plugin.h
+++ b/chrome_frame/chrome_frame_plugin.h
@@ -27,7 +27,7 @@ void ChromeFramePluginGetParamsCoordinates(
int* y);
// A class to implement common functionality for all types of
-// plugins: NPAPI. ActiveX and ActiveDoc
+// plugins: ActiveX and ActiveDoc
template <typename T>
class ChromeFramePlugin
: public ChromeFrameDelegateImpl,
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc
index 61f9a18..4952cee 100644
--- a/chrome_frame/chrome_tab.cc
+++ b/chrome_frame/chrome_tab.cc
@@ -485,8 +485,6 @@ enum RegistrationFlags {
BHO_REGISTRATION = 0x0010,
TYPELIB = 0x0020,
- NPAPI_PLUGIN = 0x1000,
-
ALL = 0xFFFF
};
@@ -571,8 +569,11 @@ STDAPI CustomRegistration(UINT reg_flags, BOOL reg, bool is_system) {
UtilUnRegisterTypeLib(_AtlComModule.m_hInstTypeLib, NULL, !is_system);
}
- if ((hr == S_OK) && (flags & NPAPI_PLUGIN)) {
- hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, reg);
+ // Unconditionally remove NPAPI registration when unregistering any component.
+ if ((hr == S_OK) && !reg) {
+ // Ignore failures.
+ _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI, reg);
+ UtilRemovePersistentNPAPIMarker();
}
if (hr == S_OK) {
@@ -596,10 +597,6 @@ STDAPI DllRegisterServer() {
UINT flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL |
BHO_CLSID | BHO_REGISTRATION;
- if (UtilIsPersistentNPAPIMarkerSet()) {
- flags |= NPAPI_PLUGIN;
- }
-
HRESULT hr = CustomRegistration(flags, TRUE, true);
if (SUCCEEDED(hr)) {
SetupRunOnce();
@@ -619,10 +616,6 @@ STDAPI DllRegisterUserServer() {
UINT flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL |
BHO_CLSID | BHO_REGISTRATION;
- if (UtilIsPersistentNPAPIMarkerSet()) {
- flags |= NPAPI_PLUGIN;
- }
-
HRESULT hr = CustomRegistration(flags, TRUE, false);
if (SUCCEEDED(hr)) {
SetupRunOnce();
@@ -637,42 +630,6 @@ STDAPI DllUnregisterUserServer() {
return hr;
}
-// Registers the NPAPI plugin and sets the persistent marker that tells us
-// to re-register it through updates.
-STDAPI RegisterNPAPIPlugin() {
- HRESULT hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI,
- TRUE);
- if (SUCCEEDED(hr) && _AtlModule.do_system_registration_) {
- if (!UtilChangePersistentNPAPIMarker(true)) {
- hr = E_FAIL;
- }
- }
- return hr;
-}
-
-// Unregisters the NPAPI plugin and clears the persistent marker that tells us
-// to re-register it through updates.
-STDAPI UnregisterNPAPIPlugin() {
- HRESULT hr = _AtlModule.UpdateRegistryFromResourceS(IDR_CHROMEFRAME_NPAPI,
- FALSE);
- if (SUCCEEDED(hr) && _AtlModule.do_system_registration_) {
- if (!UtilChangePersistentNPAPIMarker(false)) {
- hr = E_FAIL;
- }
- }
- return hr;
-}
-
-STDAPI RegisterNPAPIUserPlugin() {
- _AtlModule.do_system_registration_ = false;
- return RegisterNPAPIPlugin();
-}
-
-STDAPI UnregisterNPAPIUserPlugin() {
- _AtlModule.do_system_registration_ = false;
- return UnregisterNPAPIPlugin();
-}
-
class SecurityDescBackup {
public:
explicit SecurityDescBackup(const std::wstring& backup_key)
diff --git a/chrome_frame/chrome_tab.def b/chrome_frame/chrome_tab.def
index 9acafe3..f22ffc1 100644
--- a/chrome_frame/chrome_tab.def
+++ b/chrome_frame/chrome_tab.def
@@ -9,10 +9,3 @@ EXPORTS
DllUnregisterServer PRIVATE
DllRegisterUserServer PRIVATE
DllUnregisterUserServer PRIVATE
- NP_Initialize PRIVATE
- NP_GetEntryPoints PRIVATE
- NP_Shutdown PRIVATE
- RegisterNPAPIPlugin PRIVATE
- UnregisterNPAPIPlugin PRIVATE
- RegisterNPAPIUserPlugin PRIVATE
- UnregisterNPAPIUserPlugin PRIVATE
diff --git a/chrome_frame/external_tab.h b/chrome_frame/external_tab.h
index ab10614..66844df07 100644
--- a/chrome_frame/external_tab.h
+++ b/chrome_frame/external_tab.h
@@ -76,9 +76,8 @@ struct CreateTabParams {
class NavigationConstraints;
/////////////////////////////////////////////////////////////////////////
-// ExternalTabProxy is a mediator between ChromeProxy (which runs mostly in
-// background IPC-channel thread and the UI object (ActiveX, NPAPI,
-// ActiveDocument).
+// ExternalTabProxy is a mediator between ChromeProxy (which runs mostly in the
+// background IPC-channel thread) and the UI object (ActiveX, ActiveDocument).
// The lifetime of ExternalTabProxy is determined by the UI object.
//
// When ExternalTabProxy dies:
diff --git a/chrome_frame/metrics_service.cc b/chrome_frame/metrics_service.cc
index da55b6e..fa1a5a7 100644
--- a/chrome_frame/metrics_service.cc
+++ b/chrome_frame/metrics_service.cc
@@ -81,8 +81,6 @@ base::LazyInstance<base::ThreadLocalPointer<MetricsService> >
base::Lock MetricsService::metrics_service_lock_;
-extern base::LazyInstance<base::StatisticsRecorder> g_statistics_recorder_;
-
// This class provides functionality to upload the ChromeFrame UMA data to the
// server. An instance of this class is created whenever we have data to be
// uploaded to the server.
@@ -269,7 +267,6 @@ void MetricsService::InitializeMetricsState() {
CrashMetricsReporter::SESSION_ID);
// Ensure that an instance of the StatisticsRecorder object is created.
- g_statistics_recorder_.Get();
CrashMetricsReporter::GetInstance()->set_active(true);
}
diff --git a/chrome_frame/navigation_constraints.h b/chrome_frame/navigation_constraints.h
index fe24558..2aefe5c 100644
--- a/chrome_frame/navigation_constraints.h
+++ b/chrome_frame/navigation_constraints.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -38,7 +38,6 @@ class NavigationConstraintsImpl : public NavigationConstraints {
base::win::ScopedComPtr<IInternetSecurityManager> security_manager_;
// The plugin is privileged if it is:
- // * Invoked by a window running under the system principal in FireFox.
// * Being hosted by a custom host exposing the SID_ChromeFramePrivileged
// service.
//
diff --git a/chrome_frame/np_browser_functions.cc b/chrome_frame/np_browser_functions.cc
deleted file mode 100644
index 804efdc..0000000
--- a/chrome_frame/np_browser_functions.cc
+++ /dev/null
@@ -1,533 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome_frame/np_browser_functions.h"
-
-#include "base/logging.h"
-
-namespace npapi {
-
-// global function pointers (within this namespace) for the NPN functions.
-struct NpVersion {
- struct {
- uint8 minor;
- uint8 major;
- } v;
-
- void set_version(uint16 version) {
- v.minor = version & 0xFF;
- v.major = version >> 8;
- }
-
- uint16 version() const {
- return v.minor | (v.major << 8);
- }
-};
-
-NpVersion g_version = {0};
-
-NPN_GetURLProcPtr g_geturl = NULL;
-NPN_PostURLProcPtr g_posturl = NULL;
-NPN_RequestReadProcPtr g_requestread = NULL;
-NPN_NewStreamProcPtr g_newstream = NULL;
-NPN_WriteProcPtr g_write = NULL;
-NPN_DestroyStreamProcPtr g_destroystream = NULL;
-NPN_StatusProcPtr g_status = NULL;
-NPN_UserAgentProcPtr g_useragent = NULL;
-NPN_MemAllocProcPtr g_memalloc = NULL;
-NPN_MemFreeProcPtr g_memfree = NULL;
-NPN_MemFlushProcPtr g_memflush = NULL;
-NPN_ReloadPluginsProcPtr g_reloadplugins = NULL;
-NPN_GetJavaEnvProcPtr g_getJavaEnv = NULL;
-NPN_GetJavaPeerProcPtr g_getJavaPeer = NULL;
-NPN_GetURLNotifyProcPtr g_geturlnotify = NULL;
-NPN_PostURLNotifyProcPtr g_posturlnotify = NULL;
-NPN_GetValueProcPtr g_getvalue = NULL;
-NPN_SetValueProcPtr g_setvalue = NULL;
-NPN_InvalidateRectProcPtr g_invalidaterect = NULL;
-NPN_InvalidateRegionProcPtr g_invalidateregion = NULL;
-NPN_ForceRedrawProcPtr g_forceredraw = NULL;
-NPN_GetStringIdentifierProcPtr g_getstringidentifier = NULL;
-NPN_GetStringIdentifiersProcPtr g_getstringidentifiers = NULL;
-NPN_GetIntIdentifierProcPtr g_getintidentifier = NULL;
-NPN_IdentifierIsStringProcPtr g_identifierisstring = NULL;
-NPN_UTF8FromIdentifierProcPtr g_utf8fromidentifier = NULL;
-NPN_IntFromIdentifierProcPtr g_intfromidentifier = NULL;
-NPN_CreateObjectProcPtr g_createobject = NULL;
-NPN_RetainObjectProcPtr g_retainobject = NULL;
-NPN_ReleaseObjectProcPtr g_releaseobject = NULL;
-NPN_InvokeProcPtr g_invoke = NULL;
-NPN_InvokeDefaultProcPtr g_invoke_default = NULL;
-NPN_EvaluateProcPtr g_evaluate = NULL;
-NPN_GetPropertyProcPtr g_getproperty = NULL;
-NPN_SetPropertyProcPtr g_setproperty = NULL;
-NPN_RemovePropertyProcPtr g_removeproperty = NULL;
-NPN_HasPropertyProcPtr g_hasproperty = NULL;
-NPN_HasMethodProcPtr g_hasmethod = NULL;
-NPN_ReleaseVariantValueProcPtr g_releasevariantvalue = NULL;
-NPN_SetExceptionProcPtr g_setexception = NULL;
-NPN_PushPopupsEnabledStateProcPtr g_pushpopupsenabledstate = NULL;
-NPN_PopPopupsEnabledStateProcPtr g_poppopupsenabledstate = NULL;
-NPN_EnumerateProcPtr g_enumerate = NULL;
-NPN_PluginThreadAsyncCallProcPtr g_pluginthreadasynccall = NULL;
-NPN_ConstructProcPtr g_construct = NULL;
-NPN_GetValueForURLPtr g_getvalueforurl = NULL;
-NPN_SetValueForURLPtr g_setvalueforurl = NULL;
-NPN_GetAuthenticationInfoPtr g_getauthenticationinfo = NULL;
-NPN_URLRedirectResponsePtr g_urlredirectresponse = NULL;
-
-// Must be called prior to calling any of the browser functions below.
-void InitializeBrowserFunctions(NPNetscapeFuncs* functions) {
- CHECK(functions);
- DCHECK(g_geturl == NULL || g_geturl == functions->geturl);
-
- g_version.set_version(functions->version);
-
- g_geturl = functions->geturl;
- g_posturl = functions->posturl;
- g_requestread = functions->requestread;
- g_newstream = functions->newstream;
- g_write = functions->write;
- g_destroystream = functions->destroystream;
- g_status = functions->status;
- g_useragent = functions->uagent;
- g_memalloc = functions->memalloc;
- g_memfree = functions->memfree;
- g_memflush = functions->memflush;
- g_reloadplugins = functions->reloadplugins;
- g_getJavaEnv = functions->getJavaEnv;
- g_getJavaPeer = functions->getJavaPeer;
- g_geturlnotify = functions->geturlnotify;
- g_posturlnotify = functions->posturlnotify;
- g_getvalue = functions->getvalue;
- g_setvalue = functions->setvalue;
- g_invalidaterect = functions->invalidaterect;
- g_invalidateregion = functions->invalidateregion;
- g_forceredraw = functions->forceredraw;
- g_getstringidentifier = functions->getstringidentifier;
- g_getstringidentifiers = functions->getstringidentifiers;
- g_getintidentifier = functions->getintidentifier;
- g_identifierisstring = functions->identifierisstring;
- g_utf8fromidentifier = functions->utf8fromidentifier;
- g_intfromidentifier = functions->intfromidentifier;
- g_createobject = functions->createobject;
- g_retainobject = functions->retainobject;
- g_releaseobject = functions->releaseobject;
- g_invoke = functions->invoke;
- g_invoke_default = functions->invokeDefault;
- g_evaluate = functions->evaluate;
- g_getproperty = functions->getproperty;
- g_setproperty = functions->setproperty;
- g_removeproperty = functions->removeproperty;
- g_hasproperty = functions->hasproperty;
- g_hasmethod = functions->hasmethod;
- g_releasevariantvalue = functions->releasevariantvalue;
- g_setexception = functions->setexception;
- g_pushpopupsenabledstate = functions->pushpopupsenabledstate;
- g_poppopupsenabledstate = functions->poppopupsenabledstate;
- g_enumerate = functions->enumerate;
- g_pluginthreadasynccall = functions->pluginthreadasynccall;
- g_construct = functions->construct;
- g_urlredirectresponse = functions->urlredirectresponse;
-
- if (g_version.v.minor >= NPVERS_HAS_URL_AND_AUTH_INFO) {
- g_getvalueforurl = functions->getvalueforurl;
- g_setvalueforurl = functions->setvalueforurl;
- g_getauthenticationinfo = functions->getauthenticationinfo;
- }
-}
-
-void UninitializeBrowserFunctions() {
- g_version.set_version(0);
-
- // We skip doing this in the official build as it doesn't serve much purpose
-// during shutdown. The reason for it being here in the other types of builds
-// is to spot potential browser bugs whereby the browser leaves living objects
-// in our DLL after shutdown has been called. In theory those objects could
-// trigger a call to the browser functions after shutdown has been called
-// and for non official builds we want that to simply crash.
-// For official builds we leave the function pointers around since they
-// continue to valid.
- g_geturl = NULL;
- g_posturl = NULL;
- g_requestread = NULL;
- g_newstream = NULL;
- g_write = NULL;
- g_destroystream = NULL;
- g_status = NULL;
- g_useragent = NULL;
- g_memalloc = NULL;
- g_memfree = NULL;
- g_memflush = NULL;
- g_reloadplugins = NULL;
- g_getJavaEnv = NULL;
- g_getJavaPeer = NULL;
- g_geturlnotify = NULL;
- g_posturlnotify = NULL;
- g_getvalue = NULL;
- g_setvalue = NULL;
- g_invalidaterect = NULL;
- g_invalidateregion = NULL;
- g_forceredraw = NULL;
- g_getstringidentifier = NULL;
- g_getstringidentifiers = NULL;
- g_getintidentifier = NULL;
- g_identifierisstring = NULL;
- g_utf8fromidentifier = NULL;
- g_intfromidentifier = NULL;
- g_createobject = NULL;
- g_retainobject = NULL;
- g_releaseobject = NULL;
- g_invoke = NULL;
- g_invoke_default = NULL;
- g_evaluate = NULL;
- g_getproperty = NULL;
- g_setproperty = NULL;
- g_removeproperty = NULL;
- g_hasproperty = NULL;
- g_hasmethod = NULL;
- g_releasevariantvalue = NULL;
- g_setexception = NULL;
- g_pushpopupsenabledstate = NULL;
- g_poppopupsenabledstate = NULL;
- g_enumerate = NULL;
- g_pluginthreadasynccall = NULL;
- g_construct = NULL;
- g_getvalueforurl = NULL;
- g_setvalueforurl = NULL;
- g_getauthenticationinfo = NULL;
-}
-
-bool IsInitialized() {
- // We only check one function for convenience.
- return g_getvalue != NULL;
-}
-
-// Function stubs for functions that the host browser implements.
-uint8 VersionMinor() {
- return g_version.v.minor;
-}
-
-uint8 VersionMajor() {
- return g_version.v.major;
-}
-
-NPError GetURL(NPP instance, const char* URL, const char* window) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_geturl(instance, URL, window);
-}
-
-NPError PostURL(NPP instance, const char* URL, const char* window, uint32 len,
- const char* buf, NPBool file) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_posturl(instance, URL, window, len, buf, file);
-}
-
-NPError RequestRead(NPStream* stream, NPByteRange* rangeList) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_requestread(stream, rangeList);
-}
-
-NPError NewStream(NPP instance, NPMIMEType type, const char* window,
- NPStream** stream) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_newstream(instance, type, window, stream);
-}
-
-int32 Write(NPP instance, NPStream* stream, int32 len, void* buffer) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_write(instance, stream, len, buffer);
-}
-
-NPError DestroyStream(NPP instance, NPStream* stream, NPReason reason) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_destroystream(instance, stream, reason);
-}
-
-void Status(NPP instance, const char* message) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_status(instance, message);
-}
-
-const char* UserAgent(NPP instance) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_useragent(instance);
-}
-
-void* MemAlloc(uint32 size) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_memalloc(size);
-}
-
-void MemFree(void* ptr) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_memfree(ptr);
-}
-
-uint32 MemFlush(uint32 size) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_memflush(size);
-}
-
-void ReloadPlugins(NPBool reloadPages) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_reloadplugins(reloadPages);
-}
-
-void* GetJavaEnv() {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_getJavaEnv();
-}
-
-void* GetJavaPeer(NPP instance) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_getJavaPeer(instance);
-}
-
-NPError GetURLNotify(NPP instance, const char* URL, const char* window,
- void* notifyData) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_geturlnotify(instance, URL, window, notifyData);
-}
-
-NPError PostURLNotify(NPP instance, const char* URL, const char* window,
- uint32 len, const char* buf, NPBool file,
- void* notifyData) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_posturlnotify(instance, URL, window, len, buf, file, notifyData);
-}
-
-NPError GetValue(NPP instance, NPNVariable variable, void* ret_value) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_getvalue(instance, variable, ret_value);
-}
-
-NPError SetValue(NPP instance, NPPVariable variable, void* value) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_setvalue(instance, variable, value);
-}
-
-void InvalidateRect(NPP instance, NPRect* rect) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_invalidaterect(instance, rect);
-}
-
-void InvalidateRegion(NPP instance, NPRegion region) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_invalidateregion(instance, region);
-}
-
-void ForceRedraw(NPP instance) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_forceredraw(instance);
-}
-
-void ReleaseVariantValue(NPVariant* variant) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_releasevariantvalue(variant);
-}
-
-NPIdentifier GetStringIdentifier(const NPUTF8* name) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_getstringidentifier(name);
-}
-
-void GetStringIdentifiers(const NPUTF8** names, int nameCount,
- NPIdentifier* identifiers) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_getstringidentifiers(names, nameCount, identifiers);
-}
-
-NPIdentifier GetIntIdentifier(int32_t intid) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_getintidentifier(intid);
-}
-
-int32_t IntFromIdentifier(NPIdentifier identifier) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_intfromidentifier(identifier);
-}
-
-bool IdentifierIsString(NPIdentifier identifier) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_identifierisstring(identifier);
-
-}
-
-NPUTF8* UTF8FromIdentifier(NPIdentifier identifier) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_utf8fromidentifier(identifier);
-
-}
-
-NPObject* CreateObject(NPP instance, NPClass* aClass) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_createobject(instance, aClass);
-
-}
-
-NPObject* RetainObject(NPObject* obj) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_retainobject(obj);
-
-}
-
-void ReleaseObject(NPObject* obj) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_releaseobject(obj);
-
-}
-
-bool Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
- const NPVariant* args, unsigned argCount, NPVariant* result) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_invoke(npp, obj, methodName, args, argCount, result);
-}
-
-bool InvokeDefault(NPP npp, NPObject* obj, const NPVariant* args,
- unsigned argCount, NPVariant* result) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_invoke_default(npp, obj, args, argCount, result);
-}
-
-bool Evaluate(NPP npp, NPObject* obj, NPString* script, NPVariant* result) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_evaluate(npp, obj, script, result);
-}
-
-bool GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
- NPVariant* result) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_getproperty(npp, obj, propertyName, result);
-}
-
-bool SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
- const NPVariant* value) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_setproperty(npp, obj, propertyName, value);
-}
-
-bool HasProperty(NPP npp, NPObject* npobj, NPIdentifier propertyName) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_hasproperty(npp, npobj, propertyName);
-}
-
-bool HasMethod(NPP npp, NPObject* npobj, NPIdentifier methodName) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_hasmethod(npp, npobj, methodName);
-}
-
-bool RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_removeproperty(npp, obj, propertyName);
-}
-
-void SetException(NPObject* obj, const NPUTF8* message) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_setexception(obj, message);
-}
-
-void PushPopupsEnabledState(NPP npp, NPBool enabled) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_pushpopupsenabledstate(npp, enabled);
-}
-
-void PopPopupsEnabledState(NPP npp) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_poppopupsenabledstate(npp);
-}
-
-bool Enumerate(NPP npp, NPObject* obj, NPIdentifier** identifier,
- uint32_t* count) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_enumerate(npp, obj, identifier, count);
-}
-
-void PluginThreadAsyncCall(NPP instance, void (*func)(void*), void* userData) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_pluginthreadasynccall(instance, func, userData);
-}
-
-bool Construct(NPP npp, NPObject* obj, const NPVariant* args, uint32_t argCount,
- NPVariant* result) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- return g_construct(npp, obj, args, argCount, result);
-}
-
-NPError GetValueForURL(NPP instance, NPNURLVariable variable, const char* url,
- char** value, uint32* len) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- DCHECK(npapi::VersionMinor() >= NPVERS_HAS_URL_AND_AUTH_INFO);
- if (!g_getvalueforurl) {
- NOTREACHED();
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
-
- return g_getvalueforurl(instance, variable, url, value, len);
-}
-
-NPError SetValueForURL(NPP instance, NPNURLVariable variable, const char* url,
- const char* value, uint32 len) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- DCHECK(npapi::VersionMinor() >= NPVERS_HAS_URL_AND_AUTH_INFO);
- if (!g_setvalueforurl) {
- NOTREACHED();
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
-
- return g_setvalueforurl(instance, variable, url, value, len);
-}
-
-NPError GetAuthenticationInfo(NPP instance, const char* protocol,
- const char* host, int32 port, const char* scheme,
- const char *realm, char** username, uint32* ulen,
- char** password, uint32* plen) {
- DCHECK(IsInitialized()) << __FUNCTION__;
- DCHECK(npapi::VersionMinor() >= NPVERS_HAS_URL_AND_AUTH_INFO);
- if (g_getauthenticationinfo) {
- NOTREACHED();
- return NPERR_INCOMPATIBLE_VERSION_ERROR;
- }
-
- return g_getauthenticationinfo(instance, protocol, host, port, scheme,
- realm, username, ulen, password, plen);
-}
-
-void URLRedirectResponse(NPP instance, void* notify_data, NPBool allow) {
- if (!g_urlredirectresponse) {
- NOTREACHED() << "Unexpected call to NPN_URLRedirectResponse";
- return;
- }
- return g_urlredirectresponse(instance, notify_data, allow);
-}
-
-std::string StringFromIdentifier(NPIdentifier identifier) {
- std::string ret;
- NPUTF8* utf8 = UTF8FromIdentifier(identifier);
- if (utf8) {
- ret = utf8;
- MemFree(utf8);
- }
- return ret;
-}
-
-} // namespace npapi
-
-void AllocateStringVariant(const std::string& str, NPVariant* var) {
- DCHECK(var);
-
- int len = str.length();
- NPUTF8* buffer = reinterpret_cast<NPUTF8*>(npapi::MemAlloc(len + 1));
- if (buffer) {
- buffer[len] = '\0';
- memcpy(buffer, str.c_str(), len);
- STRINGN_TO_NPVARIANT(buffer, len, *var);
- } else {
- NULL_TO_NPVARIANT(*var);
- }
-}
-
-bool BrowserSupportsRedirectNotification() {
- return npapi::g_urlredirectresponse != NULL;
-}
diff --git a/chrome_frame/np_browser_functions.h b/chrome_frame/np_browser_functions.h
deleted file mode 100644
index da2a1c8..0000000
--- a/chrome_frame/np_browser_functions.h
+++ /dev/null
@@ -1,283 +0,0 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_
-#define CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_
-
-#include "base/logging.h"
-#include "third_party/npapi/bindings/npapi.h"
-#include "third_party/npapi/bindings/nphostapi.h"
-
-namespace npapi {
-
-// Must be called prior to calling any of the browser functions below.
-void InitializeBrowserFunctions(NPNetscapeFuncs* functions);
-void UninitializeBrowserFunctions();
-
-// Returns true iff InitializeBrowserFunctions has been called successully.
-bool IsInitialized();
-
-// Function stubs for functions that the host browser implements.
-
-uint8 VersionMinor();
-uint8 VersionMajor();
-
-NPError GetURL(NPP instance, const char* URL, const char* window);
-
-NPError PostURL(NPP instance, const char* URL, const char* window, uint32 len,
- const char* buf, NPBool file);
-
-NPError RequestRead(NPStream* stream, NPByteRange* rangeList);
-
-NPError NewStream(NPP instance, NPMIMEType type, const char* window,
- NPStream** stream);
-
-int32 Write(NPP instance, NPStream* stream, int32 len, void* buffer);
-
-NPError DestroyStream(NPP instance, NPStream* stream, NPReason reason);
-
-void Status(NPP instance, const char* message);
-
-const char* UserAgent(NPP instance);
-
-void* MemAlloc(uint32 size);
-
-void MemFree(void* ptr);
-
-uint32 MemFlush(uint32 size);
-
-void ReloadPlugins(NPBool reloadPages);
-
-void* GetJavaEnv();
-
-void* GetJavaPeer(NPP instance);
-
-NPError GetURLNotify(NPP instance, const char* URL, const char* window,
- void* notifyData);
-
-NPError PostURLNotify(NPP instance, const char* URL, const char* window,
- uint32 len, const char* buf, NPBool file,
- void* notifyData);
-
-NPError GetValue(NPP instance, NPNVariable variable, void* ret_value);
-
-NPError SetValue(NPP instance, NPPVariable variable, void* value);
-
-void InvalidateRect(NPP instance, NPRect* rect);
-
-void InvalidateRegion(NPP instance, NPRegion region);
-
-void ForceRedraw(NPP instance);
-
-void ReleaseVariantValue(NPVariant* variant);
-
-NPIdentifier GetStringIdentifier(const NPUTF8* name);
-
-void GetStringIdentifiers(const NPUTF8** names, int nameCount,
- NPIdentifier* identifiers);
-
-NPIdentifier GetIntIdentifier(int32_t intid);
-
-int32_t IntFromIdentifier(NPIdentifier identifier);
-
-bool IdentifierIsString(NPIdentifier identifier);
-
-NPUTF8* UTF8FromIdentifier(NPIdentifier identifier);
-
-NPObject* CreateObject(NPP, NPClass* aClass);
-
-NPObject* RetainObject(NPObject* obj);
-
-void ReleaseObject(NPObject* obj);
-
-bool Invoke(NPP npp, NPObject* obj, NPIdentifier methodName,
- const NPVariant* args, unsigned argCount, NPVariant* result);
-
-bool InvokeDefault(NPP npp, NPObject* obj, const NPVariant* args,
- unsigned argCount, NPVariant* result);
-
-bool Evaluate(NPP npp, NPObject* obj, NPString* script, NPVariant* result);
-
-bool GetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
- NPVariant* result);
-
-bool SetProperty(NPP npp, NPObject* obj, NPIdentifier propertyName,
- const NPVariant* value);
-
-bool HasProperty(NPP npp, NPObject* npobj, NPIdentifier propertyName);
-
-bool HasMethod(NPP npp, NPObject* npobj, NPIdentifier methodName);
-
-bool RemoveProperty(NPP npp, NPObject* obj, NPIdentifier propertyName);
-
-void SetException(NPObject* obj, const NPUTF8* message);
-
-void PushPopupsEnabledState(NPP npp, NPBool enabled);
-
-void PopPopupsEnabledState(NPP npp);
-
-bool Enumerate(NPP npp, NPObject* obj, NPIdentifier** identifier,
- uint32_t* count);
-
-void PluginThreadAsyncCall(NPP instance, void (*func)(void*), void* userData);
-
-bool Construct(NPP npp, NPObject* obj, const NPVariant* args, uint32_t argCount,
- NPVariant* result);
-
-NPError GetValueForURL(NPP instance, NPNURLVariable variable, const char* url,
- char** value, uint32* len);
-NPError SetValueForURL(NPP instance, NPNURLVariable variable, const char* url,
- const char* value, uint32 len);
-NPError GetAuthenticationInfo(NPP instance, const char* protocol,
- const char* host, int32 port, const char* scheme,
- const char *realm, char** username, uint32* ulen,
- char** password, uint32* plen);
-uint32 ScheduleTimer(NPP instance, uint32 interval, NPBool repeat,
- void (*timerFunc)(NPP npp, uint32 timerID));
-void UnscheduleTimer(NPP instance, uint32 timerID);
-NPError PopUpContextMenu(NPP instance, NPMenu* menu);
-NPBool ConvertPoint(NPP instance, double sourceX, double sourceY,
- NPCoordinateSpace sourceSpace, double *destX,
- double *destY, NPCoordinateSpace destSpace);
-void URLRedirectResponse(NPP instance, void* notify_data, NPBool allow);
-
-// Helper routine that wraps UTF8FromIdentifier to convert a string identifier
-// to an STL string. It's not super efficient since it could possibly do two
-// heap allocations (STL string has a stack based buffer for smaller strings).
-// For debugging purposes it is useful.
-std::string StringFromIdentifier(NPIdentifier identifier);
-
-} // namespace npapi
-
-// Simple helper class for freeing NPVariants at the end of a scope.
-class ScopedNpVariant : public NPVariant {
- public:
- ScopedNpVariant() {
- VOID_TO_NPVARIANT(*this);
- }
-
- ~ScopedNpVariant() {
- Free();
- }
-
- void Free() {
- npapi::ReleaseVariantValue(this);
- VOID_TO_NPVARIANT(*this);
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ScopedNpVariant);
-};
-
-// Simple helper class for freeing NPObjects at the end of a scope.
-template <typename NpoType = NPObject>
-class ScopedNpObject {
- public:
- ScopedNpObject() : npo_(NULL) {
- }
-
- explicit ScopedNpObject(NpoType* npo) : npo_(npo) {
- }
-
- ~ScopedNpObject() {
- Free();
- }
-
- NpoType* get() const {
- return npo_;
- }
-
- operator NpoType*() const {
- return npo_;
- }
-
- NpoType* operator->() const {
- return npo_;
- }
-
- ScopedNpObject<NpoType>& operator=(NpoType* npo) {
- if (npo != npo_) {
- DCHECK(npo_ == NULL);
- npapi::RetainObject(npo);
- npo_ = npo;
- }
- return *this;
- }
-
- void Free() {
- if (npo_) {
- npapi::ReleaseObject(npo_);
- npo_ = NULL;
- }
- }
-
- NpoType** Receive() {
- DCHECK(npo_ == NULL) << "Object leak. Pointer must be NULL";
- return &npo_;
- }
-
- NpoType* Detach() {
- NpoType* p = npo_;
- npo_ = NULL;
- return p;
- }
-
- void Attach(NpoType* p) {
- DCHECK(npo_ == NULL);
- npo_ = p;
- }
-
- NpoType* Copy() const {
- if (npo_ != NULL)
- npapi::RetainObject(npo_);
- return npo_;
- }
-
- bool Invoke0(NPP npp, NPIdentifier id, NPVariant* result) {
- return npapi::Invoke(npp, npo_, id, NULL, 0, result);
- }
- bool Invoke0(NPP npp, const NPUTF8* name, NPVariant* result) {
- return Invoke0(npp, npapi::GetStringIdentifier(name), result);
- }
-
- bool Invoke1(NPP npp, NPIdentifier id, const NPVariant &arg1,
- NPVariant* result) {
- return npapi::Invoke(npp, npo_, id, &arg1, 1, result);
- }
- bool Invoke1(NPP npp, const NPUTF8* name, const NPVariant &arg1,
- NPVariant* result) {
- return Invoke1(npp, npapi::GetStringIdentifier(name), arg1, result);
- }
- bool InvokeN(NPP npp, NPIdentifier id, const NPVariant* args, unsigned argc,
- NPVariant* result) {
- return npapi::Invoke(npp, npo_, id, args, argc, result);
- }
- bool InvokeN(NPP npp, const NPUTF8* name, const NPVariant* args,
- unsigned argc, NPVariant* result) {
- return Invoke1(npp, npapi::GetStringIdentifier(name), args, argc, result);
- }
-
- bool GetProperty(NPP npp, NPIdentifier id, NPVariant* result) {
- return npapi::GetProperty(npp, npo_, id, result);
- }
-
- bool GetProperty(NPP npp, const NPUTF8* name, NPVariant* result) {
- return GetProperty(npp, npapi::GetStringIdentifier(name), result);
- }
-
- private:
- NpoType* npo_;
- DISALLOW_COPY_AND_ASSIGN(ScopedNpObject);
-};
-
-// Allocates a new NPUTF8 string and assigns it to the variant.
-// If memory allocation fails, the variant type will be set to NULL.
-// The memory allocation is done via the npapi browser functions.
-void AllocateStringVariant(const std::string& str, NPVariant* var);
-
-// Returns true if the host browser supports the NPAPI redirect notification
-// spec. https://wiki.mozilla.org/NPAPI:HTTPRedirectHandling
-bool BrowserSupportsRedirectNotification();
-
-#endif // CHROME_FRAME_NP_BROWSER_FUNCTIONS_H_
diff --git a/chrome_frame/np_utils.cc b/chrome_frame/np_utils.cc
deleted file mode 100644
index 18f25d1..0000000
--- a/chrome_frame/np_utils.cc
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#define NO_NSPR_10_SUPPORT
-#include "chrome_frame/np_utils.h"
-
-#include "chrome_frame/np_browser_functions.h"
-
-namespace np_utils {
-
-std::string GetLocation(NPP instance, NPObject* window) {
- if (!window) {
- // Can fail if the browser is closing (seen in Opera).
- return "";
- }
-
- std::string result;
- ScopedNpVariant href;
- ScopedNpVariant location;
-
- bool ok = npapi::GetProperty(instance,
- window,
- npapi::GetStringIdentifier("location"),
- &location);
- DCHECK(ok);
- DCHECK(location.type == NPVariantType_Object);
-
- if (ok) {
- ok = npapi::GetProperty(instance,
- location.value.objectValue,
- npapi::GetStringIdentifier("href"),
- &href);
- DCHECK(ok);
- DCHECK(href.type == NPVariantType_String);
- if (ok) {
- result.assign(href.value.stringValue.UTF8Characters,
- href.value.stringValue.UTF8Length);
- }
- }
-
- return result;
-}
-
-} // namespace np_utils
diff --git a/chrome_frame/np_utils.h b/chrome_frame/np_utils.h
deleted file mode 100644
index 5d3efc9..0000000
--- a/chrome_frame/np_utils.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_FRAME_NP_UTILS_H_
-#define CHROME_FRAME_NP_UTILS_H_
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "chrome_frame/np_browser_functions.h"
-
-namespace np_utils {
-
-std::string GetLocation(NPP instance, NPObject* window);
-
-} // namespace np_utils
-
-#endif // CHROME_FRAME_NP_UTILS_H_
diff --git a/chrome_frame/npapi_url_request.cc b/chrome_frame/npapi_url_request.cc
deleted file mode 100644
index 63dc976..0000000
--- a/chrome_frame/npapi_url_request.cc
+++ /dev/null
@@ -1,448 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome_frame/npapi_url_request.h"
-
-#include "base/string_number_conversions.h"
-#include "base/threading/platform_thread.h"
-#include "chrome/common/automation_messages.h"
-#include "chrome_frame/chrome_frame_npapi.h"
-#include "chrome_frame/np_browser_functions.h"
-#include "chrome_frame/np_utils.h"
-#include "net/base/net_errors.h"
-
-class NPAPIUrlRequest : public PluginUrlRequest {
- public:
- explicit NPAPIUrlRequest(NPP instance);
- ~NPAPIUrlRequest();
-
- virtual bool Start();
- virtual void Stop();
- virtual bool Read(int bytes_to_read);
-
- // Called from NPAPI
- NPError OnStreamCreated(const char* mime_type, NPStream* stream);
- NPError OnStreamDestroyed(NPReason reason);
- int OnWriteReady();
- int OnWrite(void* buffer, int len);
-
- // Thread unsafe implementation of ref counting, since
- // this will be called on the plugin UI thread only.
- virtual unsigned long API_CALL AddRef();
- virtual unsigned long API_CALL Release();
-
- const net::URLRequestStatus& status() const {
- return status_;
- }
-
- NPP instance() const {
- return instance_;
- }
-
- private:
- unsigned long ref_count_;
- NPP instance_;
- NPStream* stream_;
- size_t pending_read_size_;
- net::URLRequestStatus status_;
-
- base::PlatformThreadId thread_;
- static int instance_count_;
- DISALLOW_COPY_AND_ASSIGN(NPAPIUrlRequest);
-};
-
-int NPAPIUrlRequest::instance_count_ = 0;
-
-NPAPIUrlRequest::NPAPIUrlRequest(NPP instance)
- : ref_count_(0), instance_(instance), stream_(NULL),
- pending_read_size_(0),
- status_(net::URLRequestStatus::FAILED, net::ERR_FAILED),
- thread_(base::PlatformThread::CurrentId()) {
- DVLOG(1) << "Created request. Count: " << ++instance_count_;
-}
-
-NPAPIUrlRequest::~NPAPIUrlRequest() {
- DVLOG(1) << "Deleted request. Count: " << --instance_count_;
-}
-
-// NPAPIUrlRequest member defines.
-bool NPAPIUrlRequest::Start() {
- NPError result = NPERR_GENERIC_ERROR;
- DVLOG(1) << "Starting URL request: " << url();
- // Initialize the net::HostPortPair structure from the url
- socket_address_ = net::HostPortPair::FromURL(GURL(url()));
-
- if (LowerCaseEqualsASCII(method(), "get")) {
- // TODO(joshia): if we have extra headers for HTTP GET, then implement
- // it using XHR
- result = npapi::GetURLNotify(instance_, url().c_str(), NULL, this);
- } else if (LowerCaseEqualsASCII(method(), "post")) {
- uint32 data_len = static_cast<uint32>(post_data_len());
-
- std::string buffer;
- if (extra_headers().length() > 0) {
- buffer += extra_headers();
- TrimWhitespace(buffer, TRIM_ALL, &buffer);
-
- // Firefox looks specifically for "Content-length: \d+\r\n\r\n"
- // to detect if extra headers are added to the message buffer.
- buffer += "\r\nContent-length: ";
- buffer += base::IntToString(data_len);
- buffer += "\r\n\r\n";
- }
-
- std::string data;
- data.resize(data_len);
- uint32 bytes_read;
- upload_data_->Read(&data[0], data_len,
- reinterpret_cast<ULONG*>(&bytes_read));
- DCHECK_EQ(data_len, bytes_read);
- buffer += data;
-
- result = npapi::PostURLNotify(instance_, url().c_str(), NULL,
- buffer.length(), buffer.c_str(), false, this);
- } else {
- NOTREACHED() << "PluginUrlRequest only supports 'GET'/'POST'";
- }
-
- if (NPERR_NO_ERROR != result) {
- int os_error = net::ERR_FAILED;
- switch (result) {
- case NPERR_INVALID_URL:
- os_error = net::ERR_INVALID_URL;
- break;
- default:
- break;
- }
-
- delegate_->OnResponseEnd(id(),
- net::URLRequestStatus(net::URLRequestStatus::FAILED, os_error));
- return false;
- }
-
- return true;
-}
-
-void NPAPIUrlRequest::Stop() {
- DVLOG(1) << "Finished request: Url - " << url()
- << " result: " << static_cast<int>(status_.status());
-
- status_.set_status(net::URLRequestStatus::CANCELED);
- if (stream_) {
- npapi::DestroyStream(instance_, stream_, NPRES_USER_BREAK);
- stream_ = NULL;
- }
-}
-
-bool NPAPIUrlRequest::Read(int bytes_to_read) {
- pending_read_size_ = bytes_to_read;
- return true;
-}
-
-NPError NPAPIUrlRequest::OnStreamCreated(const char* mime_type,
- NPStream* stream) {
- stream_ = stream;
- status_.set_status(net::URLRequestStatus::IO_PENDING);
- // TODO(iyengar)
- // Add support for passing persistent cookies and information about any URL
- // redirects to Chrome.
- delegate_->OnResponseStarted(id(), mime_type, stream->headers, stream->end,
- base::Time::FromTimeT(stream->lastmodified), std::string(), 0,
- socket_address_);
- return NPERR_NO_ERROR;
-}
-
-NPError NPAPIUrlRequest::OnStreamDestroyed(NPReason reason) {
- // If the request has been aborted, then ignore the |reason| argument.
- // Normally the execution flow is such than NPRES_USER_BREAK will be passed
- // when the stream is aborted, but sometimes NPRES_NETWORK_ERROR is passed
- // instead. To prevent Chrome from receiving a notification of a failed
- // network connection, when Chrome actually canceled the request, we ignore
- // the status here.
- if (net::URLRequestStatus::CANCELED != status_.status()) {
- switch (reason) {
- case NPRES_DONE:
- status_.set_status(net::URLRequestStatus::SUCCESS);
- status_.set_os_error(0);
- break;
- case NPRES_USER_BREAK:
- status_.set_status(net::URLRequestStatus::CANCELED);
- status_.set_os_error(net::ERR_ABORTED);
- break;
- case NPRES_NETWORK_ERR:
- default:
- status_.set_status(net::URLRequestStatus::FAILED);
- status_.set_os_error(net::ERR_CONNECTION_CLOSED);
- break;
- }
- }
-
- delegate_->OnResponseEnd(id(), status_);
- return NPERR_NO_ERROR;
-}
-
-int NPAPIUrlRequest::OnWriteReady() {
- return pending_read_size_;
-}
-
-int NPAPIUrlRequest::OnWrite(void* buffer, int len) {
- pending_read_size_ = 0;
- std::string data(reinterpret_cast<char*>(buffer), len);
- delegate_->OnReadComplete(id(), data);
- return len;
-}
-
-STDMETHODIMP_(ULONG) NPAPIUrlRequest::AddRef() {
- DCHECK_EQ(base::PlatformThread::CurrentId(), thread_);
- ++ref_count_;
- return ref_count_;
-}
-
-STDMETHODIMP_(ULONG) NPAPIUrlRequest::Release() {
- DCHECK_EQ(base::PlatformThread::CurrentId(), thread_);
- unsigned long ret = --ref_count_;
- if (!ret)
- delete this;
-
- return ret;
-}
-
-NPAPIUrlRequestManager::NPAPIUrlRequestManager() : instance_(NULL) {
-}
-
-NPAPIUrlRequestManager::~NPAPIUrlRequestManager() {
- StopAll();
-}
-
-// PluginUrlRequestManager implementation
-PluginUrlRequestManager::ThreadSafeFlags
- NPAPIUrlRequestManager::GetThreadSafeFlags() {
- return PluginUrlRequestManager::NOT_THREADSAFE;
-}
-
-void NPAPIUrlRequestManager::StartRequest(int request_id,
- const AutomationURLRequest& request_info) {
- scoped_refptr<NPAPIUrlRequest> new_request(new NPAPIUrlRequest(instance_));
- DCHECK(new_request);
- if (new_request->Initialize(this, request_id, request_info.url,
- request_info.method, request_info.referrer,
- request_info.extra_request_headers,
- request_info.upload_data,
- static_cast<ResourceType::Type>(request_info.resource_type),
- enable_frame_busting_,
- request_info.load_flags)) {
- DCHECK(request_map_.find(request_id) == request_map_.end());
- if (new_request->Start()) {
- request_map_[request_id] = new_request;
- // Keep additional reference on request for NPSTREAM
- // This will be released in NPP_UrlNotify
- new_request->AddRef();
- }
- }
-}
-
-void NPAPIUrlRequestManager::ReadRequest(int request_id, int bytes_to_read) {
- scoped_refptr<NPAPIUrlRequest> request = LookupRequest(request_id);
- if (request)
- request->Read(bytes_to_read);
-}
-
-void NPAPIUrlRequestManager::EndRequest(int request_id) {
- scoped_refptr<NPAPIUrlRequest> request = LookupRequest(request_id);
- if (request)
- request->Stop();
-}
-
-void NPAPIUrlRequestManager::StopAll() {
- std::vector<scoped_refptr<NPAPIUrlRequest> > request_list;
- // We copy the pending requests into a temporary vector as the Stop
- // function in the request could also try to delete the request from
- // the request map and the iterator could end up being invalid.
- for (RequestMap::iterator it = request_map_.begin();
- it != request_map_.end(); ++it) {
- DCHECK(it->second != NULL);
- request_list.push_back(it->second);
- }
-
- for (std::vector<scoped_refptr<NPAPIUrlRequest> >::size_type index = 0;
- index < request_list.size(); ++index) {
- request_list[index]->Stop();
- }
-}
-
-void NPAPIUrlRequestManager::SetCookiesForUrl(const GURL& url,
- const std::string& cookie) {
- if (npapi::VersionMinor() >= NPVERS_HAS_URL_AND_AUTH_INFO) {
- npapi::SetValueForURL(instance_, NPNURLVCookie, url.spec().c_str(),
- cookie.c_str(), cookie.length());
- } else {
- NOTREACHED() << "Unsupported version";
- }
-}
-
-void NPAPIUrlRequestManager::GetCookiesForUrl(const GURL& url, int cookie_id) {
- std::string cookie_string;
- bool success = false;
-
- if (npapi::VersionMinor() >= NPVERS_HAS_URL_AND_AUTH_INFO) {
- char* cookies = NULL;
- unsigned int cookie_length = 0;
- NPError ret = npapi::GetValueForURL(instance_, NPNURLVCookie,
- url.spec().c_str(), &cookies,
- &cookie_length);
- if (ret == NPERR_NO_ERROR) {
- DVLOG(1) << "Obtained cookies:" << cookies << " from host";
- cookie_string.append(cookies, cookie_length);
- npapi::MemFree(cookies);
- success = true;
- }
- } else {
- NOTREACHED() << "Unsupported version";
- }
-
- if (!success)
- DVLOG(1) << "Failed to return cookies for url:" << url.spec();
-
- OnCookiesRetrieved(success, url, cookie_string, cookie_id);
-}
-
-// PluginRequestDelegate implementation.
-// Callbacks from NPAPIUrlRequest. Simply forward to the delegate.
-void NPAPIUrlRequestManager::OnResponseStarted(int request_id,
- const char* mime_type, const char* headers, int size,
- base::Time last_modified, const std::string& redirect_url,
- int redirect_status, const net::HostPortPair& socket_address) {
- delegate_->OnResponseStarted(request_id, mime_type, headers, size,
- last_modified, redirect_url, redirect_status, socket_address);
-}
-
-void NPAPIUrlRequestManager::OnReadComplete(int request_id,
- const std::string& data) {
- delegate_->OnReadComplete(request_id, data);
-}
-
-void NPAPIUrlRequestManager::OnResponseEnd(
- int request_id,
- const net::URLRequestStatus& status) {
- // Delete from map.
- RequestMap::iterator it = request_map_.find(request_id);
- DCHECK(request_map_.end() != it);
- scoped_refptr<NPAPIUrlRequest> request = (*it).second;
- request_map_.erase(it);
-
- // Inform delegate unless canceled.
- if (status.status() != net::URLRequestStatus::CANCELED)
- delegate_->OnResponseEnd(request_id, status);
-}
-
-void NPAPIUrlRequestManager::OnCookiesRetrieved(bool success, const GURL& url,
- const std::string& cookie_string, int cookie_id) {
- delegate_->OnCookiesRetrieved(success, url, cookie_string, cookie_id);
-}
-
-// Notifications from browser. Find the NPAPIUrlRequest and forward to it.
-NPError NPAPIUrlRequestManager::NewStream(NPMIMEType type,
- NPStream* stream,
- NPBool seekable,
- uint16* stream_type) {
- NPAPIUrlRequest* request = RequestFromNotifyData(stream->notifyData);
- if (!request)
- return NPERR_NO_ERROR;
-
- // This stream is being constructed for a request that has already been
- // canceled. Signal its immediate termination.
- if (net::URLRequestStatus::CANCELED == request->status().status()) {
- return npapi::DestroyStream(request->instance(),
- stream, NPRES_USER_BREAK);
- }
-
- DCHECK(request_map_.find(request->id()) != request_map_.end());
-
- // If the host browser does not support the NPAPI redirect notification
- // spec, and if the request URL is implicitly redirected, we need to
- // inform Chrome about the redirect and allow it to follow the redirect.
- // We achieve this by comparing the URL requested with the URL received in
- // the response and if they don't match we assume a redirect. This would have
- // a sideffect that two GET requests would be sent out in this case.
- if (!BrowserSupportsRedirectNotification()) {
- if (GURL(request->url().c_str()) != GURL(stream->url)) {
- DVLOG(1) << "Request URL:"
- << request->url()
- << " was redirected to:"
- << stream->url;
- delegate_->OnResponseStarted(
- request->id(), "", "", 0, base::Time(), stream->url, 302,
- net::HostPortPair(net::HostPortPair::FromURL(GURL(stream->url))));
- return NPERR_GENERIC_ERROR;
- }
- }
- // We need to return the requested stream mode if we are returning a success
- // code. If we don't do this it causes Opera to blow up.
- *stream_type = NP_NORMAL;
- return request->OnStreamCreated(type, stream);
-}
-
-int32 NPAPIUrlRequestManager::WriteReady(NPStream* stream) {
- NPAPIUrlRequest* request = RequestFromNotifyData(stream->notifyData);
- if (!request)
- return 0x7FFFFFFF;
- DCHECK(request_map_.find(request->id()) != request_map_.end());
- return request->OnWriteReady();
-}
-
-int32 NPAPIUrlRequestManager::Write(NPStream* stream, int32 offset,
- int32 len, void* buffer) {
- NPAPIUrlRequest* request = RequestFromNotifyData(stream->notifyData);
- if (!request)
- return len;
- DCHECK(request_map_.find(request->id()) != request_map_.end());
- return request->OnWrite(buffer, len);
-}
-
-NPError NPAPIUrlRequestManager::DestroyStream(NPStream* stream,
- NPReason reason) {
- NPAPIUrlRequest* request = RequestFromNotifyData(stream->notifyData);
- if (!request)
- return NPERR_NO_ERROR;
-
- // It is possible to receive notification of a destroyed stream for a
- // unregistered request: EndRequest will unregister a request in response
- // to an AutomationMsg_RequestEnd message. EndRequest will also invoke
- // npapi::DestroyStream, which will call back to this function.
- if (request_map_.find(request->id()) != request_map_.end())
- return request->OnStreamDestroyed(reason);
-
- return NPERR_NO_ERROR;
-}
-
-void NPAPIUrlRequestManager::UrlNotify(const char* url, NPReason reason,
- void* notify_data) {
- NPAPIUrlRequest* request = RequestFromNotifyData(notify_data);
- DCHECK(request != NULL);
- if (request) {
- request->Stop();
- request->Release();
- }
-}
-
-void NPAPIUrlRequestManager::UrlRedirectNotify(const char* url, int status,
- void* notify_data) {
- NPAPIUrlRequest* request = RequestFromNotifyData(notify_data);
- if (request) {
- delegate_->OnResponseStarted(
- request->id(), "", "", 0, base::Time(), url, status,
- net::HostPortPair(net::HostPortPair::FromURL(GURL(url))));
- } else {
- NOTREACHED() << "Received unexpected redirect notification for url:"
- << url;
- }
-}
-
-scoped_refptr<NPAPIUrlRequest> NPAPIUrlRequestManager::LookupRequest(
- int request_id) {
- RequestMap::iterator index = request_map_.find(request_id);
- if (index != request_map_.end())
- return index->second;
- return NULL;
-}
diff --git a/chrome_frame/npapi_url_request.h b/chrome_frame/npapi_url_request.h
deleted file mode 100644
index f4466434..0000000
--- a/chrome_frame/npapi_url_request.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_FRAME_NPAPI_URL_REQUEST_H_
-#define CHROME_FRAME_NPAPI_URL_REQUEST_H_
-
-#include <map>
-#include <string>
-
-#include "chrome_frame/plugin_url_request.h"
-#include "third_party/npapi/bindings/npapi.h"
-
-class NPAPIUrlRequest;
-class NPAPIUrlRequestManager : public PluginUrlRequestManager,
- public PluginUrlRequestDelegate {
- public:
- NPAPIUrlRequestManager();
- ~NPAPIUrlRequestManager();
-
- void set_NPPInstance(NPP instance) {
- instance_ = instance;
- }
-
- // Notifications from the browser. We find the appropriate NPAPIUrlRequest
- // and forward the call.
- NPError NewStream(NPMIMEType type, NPStream* stream,
- NPBool seekable, uint16* stream_type);
- int32 WriteReady(NPStream* stream);
- int32 Write(NPStream* stream, int32 offset, int32 len, void* buffer);
- NPError DestroyStream(NPStream* stream, NPReason reason);
- void UrlNotify(const char* url, NPReason reason, void* notify_data);
- void UrlRedirectNotify(const char* url, int status, void* notify_data);
-
- private:
- // PluginUrlRequestManager implementation. Called from AutomationClient.
- virtual PluginUrlRequestManager::ThreadSafeFlags GetThreadSafeFlags();
- virtual void StartRequest(int request_id,
- const AutomationURLRequest& request_info);
- virtual void ReadRequest(int request_id, int bytes_to_read);
- virtual void EndRequest(int request_id);
- virtual void DownloadRequestInHost(int request_id) {
- // Not yet implemented.
- }
- virtual void StopAll();
- virtual void SetCookiesForUrl(const GURL& url, const std::string& cookie);
- virtual void GetCookiesForUrl(const GURL& url, int cookie_id);
-
- // Outstanding requests map.
- typedef std::map<int, scoped_refptr<NPAPIUrlRequest> > RequestMap;
- RequestMap request_map_;
-
- scoped_refptr<NPAPIUrlRequest> LookupRequest(int request_id);
-
- // PluginUrlRequestDelegate implementation. Forwards back to delegate.
- virtual void OnResponseStarted(int request_id, const char* mime_type,
- const char* headers, int size, base::Time last_modified,
- const std::string& redirect_url, int redirect_status,
- const net::HostPortPair& socket_address);
- virtual void OnReadComplete(int request_id, const std::string& data);
- virtual void OnResponseEnd(int request_id,
- const net::URLRequestStatus& status);
- virtual void OnCookiesRetrieved(bool success, const GURL& url,
- const std::string& cookie_string, int cookie_id);
-
- static inline NPAPIUrlRequest* RequestFromNotifyData(void* notify_data) {
- return reinterpret_cast<NPAPIUrlRequest*>(notify_data);
- }
-
- NPP instance_;
-};
-
-#endif // CHROME_FRAME_NPAPI_URL_REQUEST_H_
diff --git a/chrome_frame/plugin_url_request.cc b/chrome_frame/plugin_url_request.cc
index e0166bc..deeac65 100644
--- a/chrome_frame/plugin_url_request.cc
+++ b/chrome_frame/plugin_url_request.cc
@@ -1,11 +1,10 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome_frame/plugin_url_request.h"
#include "chrome/common/automation_messages.h"
-#include "chrome_frame/np_browser_functions.h"
PluginUrlRequest::PluginUrlRequest()
: delegate_(NULL),
diff --git a/chrome_frame/test/chrome_frame_test_utils.cc b/chrome_frame/test/chrome_frame_test_utils.cc
index 2270e32..3975c70 100644
--- a/chrome_frame/test/chrome_frame_test_utils.cc
+++ b/chrome_frame/test/chrome_frame_test_utils.cc
@@ -45,9 +45,6 @@ const int kCrashServiceStartupTimeoutMs = 500;
const wchar_t kIEImageName[] = L"iexplore.exe";
const wchar_t kIEBrokerImageName[] = L"ieuser.exe";
-const wchar_t kFirefoxImageName[] = L"firefox.exe";
-const wchar_t kOperaImageName[] = L"opera.exe";
-const wchar_t kSafariImageName[] = L"safari.exe";
const char kChromeImageName[] = "chrome.exe";
const wchar_t kIEProfileName[] = L"iexplore";
const wchar_t kChromeLauncher[] = L"chrome_launcher.exe";
@@ -176,14 +173,6 @@ base::ProcessHandle LaunchExecutable(const std::wstring& executable,
return process;
}
-base::ProcessHandle LaunchFirefox(const std::wstring& url) {
- return LaunchExecutable(kFirefoxImageName, url);
-}
-
-base::ProcessHandle LaunchSafari(const std::wstring& url) {
- return LaunchExecutable(kSafariImageName, url);
-}
-
base::ProcessHandle LaunchChrome(const std::wstring& url) {
FilePath path;
PathService::Get(base::DIR_MODULE, &path);
@@ -198,16 +187,6 @@ base::ProcessHandle LaunchChrome(const std::wstring& url) {
return process;
}
-base::ProcessHandle LaunchOpera(const std::wstring& url) {
- // NOTE: For Opera tests to work it must be configured to start up with
- // a blank page. There is an command line switch, -nosession, that's supposed
- // to avoid opening up the previous session, but that switch is not working.
- // TODO(tommi): Include a special ini file (opera6.ini) for opera and launch
- // with our required settings. This file is by default stored here:
- // "%USERPROFILE%\Application Data\Opera\Opera\profile\opera6.ini"
- return LaunchExecutable(kOperaImageName, url);
-}
-
base::ProcessHandle LaunchIEOnVista(const std::wstring& url) {
typedef HRESULT (WINAPI* IELaunchURLPtr)(
const wchar_t* url,
diff --git a/chrome_frame/test/chrome_frame_test_utils.h b/chrome_frame/test/chrome_frame_test_utils.h
index a34e0a8..a93af2f 100644
--- a/chrome_frame/test/chrome_frame_test_utils.h
+++ b/chrome_frame/test/chrome_frame_test_utils.h
@@ -39,10 +39,7 @@ namespace chrome_frame_test {
int CloseVisibleWindowsOnAllThreads(HANDLE process);
-base::ProcessHandle LaunchFirefox(const std::wstring& url);
-base::ProcessHandle LaunchOpera(const std::wstring& url);
base::ProcessHandle LaunchIE(const std::wstring& url);
-base::ProcessHandle LaunchSafari(const std::wstring& url);
base::ProcessHandle LaunchChrome(const std::wstring& url);
// Attempts to close all open IE windows.
@@ -54,9 +51,6 @@ int CloseAllIEWindows();
extern const wchar_t kIEImageName[];
extern const wchar_t kIEBrokerImageName[];
-extern const wchar_t kFirefoxImageName[];
-extern const wchar_t kOperaImageName[];
-extern const wchar_t kSafariImageName[];
extern const char kChromeImageName[];
extern const wchar_t kChromeLauncher[];
extern const int kChromeFrameLongNavigationTimeoutInSeconds;
diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc
index c759815..bc08e88 100644
--- a/chrome_frame/test/test_with_web_server.cc
+++ b/chrome_frame/test/test_with_web_server.cc
@@ -80,8 +80,6 @@ void ChromeFrameTestWithWebServer::CloseAllBrowsers() {
// instances, so make really sure browsers are dead.
base::KillProcesses(chrome_frame_test::kIEImageName, 0, NULL);
base::KillProcesses(chrome_frame_test::kIEBrokerImageName, 0, NULL);
- base::KillProcesses(chrome_frame_test::kFirefoxImageName, 0, NULL);
- base::KillProcesses(chrome_frame_test::kSafariImageName, 0, NULL);
// Endeavour to only kill off Chrome Frame derived Chrome processes.
KillAllNamedProcessesWithArgument(
@@ -129,10 +127,6 @@ 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);
@@ -152,12 +146,6 @@ bool ChromeFrameTestWithWebServer::LaunchBrowser(BrowserKind browser,
browser_ = browser;
if (browser == IE) {
browser_handle_.Set(chrome_frame_test::LaunchIE(url));
- } else if (browser == FIREFOX) {
- browser_handle_.Set(chrome_frame_test::LaunchFirefox(url));
- } else if (browser == OPERA) {
- browser_handle_.Set(chrome_frame_test::LaunchOpera(url));
- } else if (browser == SAFARI) {
- browser_handle_.Set(chrome_frame_test::LaunchSafari(url));
} else if (browser == CHROME) {
browser_handle_.Set(chrome_frame_test::LaunchChrome(url));
} else {
@@ -228,35 +216,11 @@ void ChromeFrameTestWithWebServer::SimpleBrowserTestExpectedResult(
void ChromeFrameTestWithWebServer::SimpleBrowserTest(BrowserKind browser,
const wchar_t* page) {
- if (browser == FIREFOX &&
- base::win::GetVersion() == base::win::VERSION_WIN7) {
- LOG(INFO) << "Not running Firefox tests on Windows 7";
- return;
- }
SimpleBrowserTestExpectedResult(browser, page, "OK");
}
-void ChromeFrameTestWithWebServer::OptionalBrowserTest(BrowserKind browser,
- const wchar_t* page) {
- DCHECK(browser != CHROME) << "Chrome tests shouldn't be optional";
- if (!LaunchBrowser(browser, page)) {
- LOG(ERROR) << "Failed to launch browser " << ToString(browser);
- } else {
- server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
- kPostedResultSubstring);
- WaitForTestToComplete(TestTimeouts::action_max_timeout_ms());
- ASSERT_EQ("OK", server_mock_.posted_result());
- }
-}
-
void ChromeFrameTestWithWebServer::VersionTest(BrowserKind browser,
const wchar_t* page) {
- if (browser == FIREFOX &&
- base::win::GetVersion() == base::win::VERSION_WIN7) {
- LOG(INFO) << "Not running Firefox tests on Windows 7";
- return;
- }
-
FilePath plugin_path;
PathService::Get(base::DIR_MODULE, &plugin_path);
plugin_path = plugin_path.AppendASCII("servers");
@@ -410,15 +374,6 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_PostMessageBasic) {
SimpleBrowserTest(IE, kPostMessageBasicPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_PostMessageBasic) {
- SimpleBrowserTest(FIREFOX, kPostMessageBasicPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_PostMessageBasic) {
- OptionalBrowserTest(OPERA, kPostMessageBasicPage);
-}
-
TEST_F(ChromeFrameTestWithWebServer, FullTabIE_MIMEFilterBasic) {
const wchar_t kMIMEFilterBasicPage[] =
L"chrome_frame_mime_filter_test.html";
@@ -436,14 +391,6 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_Resize) {
SimpleBrowserTest(IE, L"chrome_frame_resize.html");
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_Resize) {
- SimpleBrowserTest(FIREFOX, L"chrome_frame_resize.html");
-}
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_Resize) {
- OptionalBrowserTest(OPERA, L"chrome_frame_resize.html");
-}
-
const wchar_t kNavigateURLAbsolutePage[] =
L"navigateurl_absolute_host.html";
@@ -451,16 +398,6 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_NavigateURLAbsolute) {
SimpleBrowserTest(IE, kNavigateURLAbsolutePage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_NavigateURLAbsolute) {
- SimpleBrowserTest(FIREFOX, kNavigateURLAbsolutePage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_NavigateURLAbsolute) {
- OptionalBrowserTest(OPERA, kNavigateURLAbsolutePage);
-}
-
const wchar_t kNavigateURLRelativePage[] =
L"navigateurl_relative_host.html";
@@ -468,113 +405,42 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_NavigateURLRelative) {
SimpleBrowserTest(IE, kNavigateURLRelativePage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_NavigateURLRelative) {
- SimpleBrowserTest(FIREFOX, kNavigateURLRelativePage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_NavigateURLRelative) {
- OptionalBrowserTest(OPERA, kNavigateURLRelativePage);
-}
-
const wchar_t kNavigateSimpleObjectFocus[] = L"simple_object_focus.html";
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_ObjectFocus) {
- SimpleBrowserTest(FIREFOX, kNavigateSimpleObjectFocus);
-}
-
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_ObjectFocus) {
SimpleBrowserTest(IE, kNavigateSimpleObjectFocus);
}
-// TODO(ananta)
-// Rewrite this test for opera.
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_ObjectFocus) {
- if (!LaunchBrowser(OPERA, kNavigateSimpleObjectFocus)) {
- LOG(ERROR) << "Failed to launch browser " << ToString(OPERA);
- } else {
- ASSERT_TRUE(WaitForOnLoad(TestTimeouts::action_max_timeout_ms()));
- server_mock_.ExpectAndHandlePostedResult(CFInvocation(CFInvocation::NONE),
- kPostedResultSubstring);
- BringBrowserToTop();
- // Tab through a couple of times. Once should be enough in theory
- // but in practice activating the browser can take a few milliseconds more.
- bool ok;
- for (int i = 0;
- i < 5 && (ok = (server_mock_.posted_result() == "OK")) == false;
- ++i) {
- Sleep(300);
- simulate_input::SendMnemonic(VK_TAB, simulate_input::NONE, false, false);
- }
- ASSERT_TRUE(ok);
- }
-}
-
const wchar_t kiframeBasicPage[] = L"iframe_basic_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_iframeBasic) {
SimpleBrowserTest(IE, kiframeBasicPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_iframeBasic) {
- SimpleBrowserTest(FIREFOX, kiframeBasicPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_iframeBasic) {
- OptionalBrowserTest(OPERA, kiframeBasicPage);
-}
-
const wchar_t kSrcPropertyTestPage[] = L"src_property_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_SrcProperty) {
SimpleBrowserTest(IE, kSrcPropertyTestPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_SrcProperty) {
- SimpleBrowserTest(FIREFOX, kSrcPropertyTestPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_SrcProperty) {
- OptionalBrowserTest(OPERA, kSrcPropertyTestPage);
-}
-
const wchar_t kCFInstanceBasicTestPage[] = L"CFInstance_basic_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceBasic) {
SimpleBrowserTest(IE, kCFInstanceBasicTestPage);
}
-// http://crbug.com/37085
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_CFInstanceBasic) {
- SimpleBrowserTest(FIREFOX, kCFInstanceBasicTestPage);
-}
-
const wchar_t kCFISingletonPage[] = L"CFInstance_singleton_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceSingleton) {
SimpleBrowserTest(IE, kCFISingletonPage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_CFInstanceSingleton) {
- SimpleBrowserTest(FIREFOX, kCFISingletonPage);
-}
-
const wchar_t kCFIDelayPage[] = L"CFInstance_delay_host.html";
TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeIE_CFInstanceDelay) {
SimpleBrowserTest(IE, kCFIDelayPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_CFInstanceDelay) {
- SimpleBrowserTest(FIREFOX, kCFIDelayPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_CFInstanceDelay) {
- OptionalBrowserTest(OPERA, kCFIDelayPage);
-}
-
const wchar_t kCFIFallbackPage[] = L"CFInstance_fallback_host.html";
// http://crbug.com/37088
@@ -582,31 +448,12 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_WidgetModeIE_CFInstanceFallback) {
SimpleBrowserTest(IE, kCFIFallbackPage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_CFInstanceFallback) {
- SimpleBrowserTest(FIREFOX, kCFIFallbackPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_CFInstanceFallback) {
- OptionalBrowserTest(OPERA, kCFIFallbackPage);
-}
-
const wchar_t kCFINoSrcPage[] = L"CFInstance_no_src_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceNoSrc) {
SimpleBrowserTest(IE, kCFINoSrcPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_CFInstanceNoSrc) {
- SimpleBrowserTest(FIREFOX, kCFINoSrcPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_CFInstanceNoSrc) {
- OptionalBrowserTest(OPERA, kCFINoSrcPage);
-}
-
const wchar_t kCFIIfrOnLoadPage[] = L"CFInstance_iframe_onload_host.html";
// disabled since it's unlikely that we care about this case
@@ -615,32 +462,12 @@ TEST_F(ChromeFrameTestWithWebServer,
SimpleBrowserTest(IE, kCFIIfrOnLoadPage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_CFInstanceIfrOnLoad) {
- SimpleBrowserTest(FIREFOX, kCFIIfrOnLoadPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_CFInstanceIfrOnLoad) {
- OptionalBrowserTest(OPERA, kCFIIfrOnLoadPage);
-}
-
const wchar_t kCFIZeroSizePage[] = L"CFInstance_zero_size_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceZeroSize) {
SimpleBrowserTest(IE, kCFIZeroSizePage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_CFInstanceZeroSize) {
- SimpleBrowserTest(FIREFOX, kCFIZeroSizePage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_CFInstanceZeroSize) {
- OptionalBrowserTest(OPERA, kCFIZeroSizePage);
-}
-
const wchar_t kCFIIfrPostPage[] = L"CFInstance_iframe_post_host.html";
// http://crbug.com/32321
@@ -648,26 +475,10 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_WidgetModeIE_CFInstanceIfrPost) {
SimpleBrowserTest(IE, kCFIIfrPostPage);
}
-// Flakes out on the bots, http://crbug.com/26372
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_CFInstanceIfrPost) {
- SimpleBrowserTest(FIREFOX, kCFIIfrPostPage);
-}
-
TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceIfrPost) {
SimpleBrowserTest(CHROME, kCFIIfrPostPage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeSafari_CFInstanceIfrPost) {
- OptionalBrowserTest(SAFARI, kCFIIfrPostPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_CFInstanceIfrPost) {
- OptionalBrowserTest(OPERA, kCFIIfrPostPage);
-}
-
const wchar_t kCFIPostPage[] = L"CFInstance_post_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) {
@@ -679,24 +490,10 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstancePost) {
}
// This test randomly fails on the ChromeFrame builder.
-// Bug http://code.google.com/p/chromium/issues/detail?id=31532
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_CFInstancePost) {
- SimpleBrowserTest(FIREFOX, kCFIPostPage);
-}
-
TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstancePost) {
SimpleBrowserTest(CHROME, kCFIPostPage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeSafari_CFInstancePost) {
- OptionalBrowserTest(SAFARI, kCFIPostPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_CFInstancePost) {
- OptionalBrowserTest(OPERA, kCFIPostPage);
-}
-
const wchar_t kCFIRPCPage[] = L"CFInstance_rpc_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPC) {
@@ -707,24 +504,10 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPC) {
SimpleBrowserTest(IE, kCFIRPCPage);
}
-// This test randomly fails on the ChromeFrame builder.
-// Bug http://code.google.com/p/chromium/issues/detail?id=31532
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_CFInstanceRPC) {
- SimpleBrowserTest(FIREFOX, kCFIRPCPage);
-}
-
TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPC) {
SimpleBrowserTest(CHROME, kCFIRPCPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeSafari_CFInstanceRPC) {
- OptionalBrowserTest(SAFARI, kCFIRPCPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_CFInstanceRPC) {
- OptionalBrowserTest(OPERA, kCFIRPCPage);
-}
-
const wchar_t kCFIRPCInternalPage[] =
L"CFInstance_rpc_internal_host.html";
@@ -736,21 +519,10 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceRPCInternal) {
SimpleBrowserTest(IE, kCFIRPCInternalPage);
}
-// http://code.google.com/p/chromium/issues/detail?id=37204
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_CFInstanceRPCInternal) {
- SimpleBrowserTest(FIREFOX, kCFIRPCInternalPage);
-}
-
TEST_F(ChromeFrameTestWithWebServer, WidgetModeChrome_CFInstanceRPCInternal) {
SimpleBrowserTest(CHROME, kCFIRPCInternalPage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeSafari_CFInstanceRPCInternal) {
- OptionalBrowserTest(SAFARI, kCFIRPCInternalPage);
-}
-
const wchar_t kCFIDefaultCtorPage[] =
L"CFInstance_default_ctor_host.html";
@@ -758,11 +530,6 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_CFInstanceDefaultCtor) {
SimpleBrowserTest(IE, kCFIDefaultCtorPage);
}
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_CFInstanceDefaultCtor) {
- SimpleBrowserTest(FIREFOX, kCFIDefaultCtorPage);
-}
-
const wchar_t kCFInstallBasicTestPage[] = L"CFInstall_basic.html";
TEST_F(ChromeFrameTestWithWebServer, FullTabIE_CFInstallBasic) {
@@ -813,61 +580,24 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_CFHttpHeaderFrameSet) {
SimpleBrowserTest(IE, kFullTabHttpHeaderPageFrameset);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_InitializeHidden) {
- SimpleBrowserTest(FIREFOX, kInitializeHiddenPage);
-}
-
-// Disabled due to a problem with Opera.
-// http://b/issue?id=1708275
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeOpera_InitializeHidden) {
- OptionalBrowserTest(OPERA, kInitializeHiddenPage);
-}
-
-const wchar_t kInHeadPage[] = L"in_head.html";
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_InHead) {
- SimpleBrowserTest(FIREFOX, kInHeadPage);
-}
-
const wchar_t kVersionPage[] = L"version.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_Version) {
VersionTest(IE, kVersionPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_Version) {
- VersionTest(FIREFOX, kVersionPage);
-}
-
const wchar_t kEventListenerPage[] = L"event_listener.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_EventListener) {
SimpleBrowserTest(IE, kEventListenerPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_EventListener) {
- SimpleBrowserTest(FIREFOX, kEventListenerPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_EventListener) {
- OptionalBrowserTest(OPERA, kEventListenerPage);
-}
-
const wchar_t kPrivilegedApisPage[] = L"privileged_apis_host.html";
TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_PrivilegedApis) {
SimpleBrowserTest(IE, kPrivilegedApisPage);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeFF_PrivilegedApis) {
- SimpleBrowserTest(FIREFOX, kPrivilegedApisPage);
-}
-
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_WidgetModeOpera_PrivilegedApis) {
- OptionalBrowserTest(OPERA, kPrivilegedApisPage);
-}
-
const wchar_t kMetaTagPage[] = L"meta_tag.html";
TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_MetaTag) {
SimpleBrowserTest(IE, kMetaTagPage);
@@ -948,13 +678,6 @@ TEST_F(ChromeFrameTestWithWebServer, WidgetModeIE_MultipleCFInstances) {
SimpleBrowserTest(IE, kMultipleCFInstancesTestUrl);
}
-// TODO(ananta)
-// Disabled until I figure out why this does not work on Firefox.
-TEST_F(ChromeFrameTestWithWebServer,
- DISABLED_WidgetModeFF_MultipleCFInstances) {
- SimpleBrowserTest(FIREFOX, kMultipleCFInstancesTestUrl);
-}
-
const wchar_t kXHRHeaderTestUrl[] =
L"xmlhttprequest_header_test.html";
@@ -1060,10 +783,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_WindowClose) {
SimpleBrowserTest(IE, kWindowCloseTestUrl);
}
-TEST_F(ChromeFrameTestWithWebServer, DISABLED_FullTabModeFF_WindowClose) {
- SimpleBrowserTest(FIREFOX, kWindowCloseTestUrl);
-}
-
std::string GetHeaderValue(const std::string& headers,
const char* header_name) {
net::HttpUtil::HeadersIterator it(headers.begin(), headers.end(),
diff --git a/chrome_frame/test/test_with_web_server.h b/chrome_frame/test/test_with_web_server.h
index 59e9e2c..ce86117 100644
--- a/chrome_frame/test/test_with_web_server.h
+++ b/chrome_frame/test/test_with_web_server.h
@@ -140,7 +140,7 @@ class MockWebServer : public test_server::HTTPTestServer {
// Class that:
// 1) Starts the local webserver,
-// 2) Supports launching browsers - Internet Explorer and Firefox with local url
+// 2) Supports launching browsers - Internet Explorer with local url
// 3) Wait the webserver to finish. It is supposed the test webpage to shutdown
// the server by navigating to "kill" page
// 4) Supports read the posted results from the test webpage to the "dump"
@@ -150,7 +150,7 @@ class ChromeFrameTestWithWebServer: public testing::Test {
ChromeFrameTestWithWebServer();
protected:
- enum BrowserKind { INVALID, IE, FIREFOX, OPERA, SAFARI, CHROME };
+ enum BrowserKind { INVALID, IE, CHROME };
bool LaunchBrowser(BrowserKind browser, const wchar_t* url);
bool WaitForTestToComplete(int milliseconds);
@@ -167,12 +167,6 @@ class ChromeFrameTestWithWebServer: public testing::Test {
const wchar_t* page, const char* result);
void SimpleBrowserTest(BrowserKind browser, const wchar_t* page);
- // Same as SimpleBrowserTest but if the browser isn't installed (LaunchBrowser
- // fails), the function will print out a warning but not treat the test
- // as failed.
- // Currently this is how we run Opera tests.
- void OptionalBrowserTest(BrowserKind browser, const wchar_t* page);
-
// Test if chrome frame correctly reports its version.
void VersionTest(BrowserKind browser, const wchar_t* page);
@@ -196,14 +190,8 @@ class ChromeFrameTestWithWebServer: public testing::Test {
switch (kind) {
case IE:
return "IE";
- case FIREFOX:
- return "Firefox";
- case OPERA:
- return "Opera";
case CHROME:
return "Chrome";
- case SAFARI:
- return "Safari";
default:
NOTREACHED();
break;
diff --git a/chrome_frame/test_utils.cc b/chrome_frame/test_utils.cc
index 0634d47..f90db60 100644
--- a/chrome_frame/test_utils.cc
+++ b/chrome_frame/test_utils.cc
@@ -78,20 +78,6 @@ void ScopedChromeFrameRegistrar::RegisterAtPath(
ASSERT_TRUE(register_server != NULL);
EXPECT_HRESULT_SUCCEEDED((*register_server)());
- DllRegisterServerFn register_npapi_server = NULL;
- if (registration_type == PER_USER) {
- register_npapi_server =
- reinterpret_cast<DllRegisterServerFn>(GetProcAddress(
- dll_handle, "RegisterNPAPIUserPlugin"));
- } else {
- register_npapi_server =
- reinterpret_cast<DllRegisterServerFn>(GetProcAddress(
- dll_handle, "RegisterNPAPIPlugin"));
- }
-
- if (register_npapi_server != NULL)
- EXPECT_HRESULT_SUCCEEDED((*register_npapi_server)());
-
ASSERT_TRUE(FreeLibrary(dll_handle));
}
@@ -115,20 +101,6 @@ void ScopedChromeFrameRegistrar::UnregisterAtPath(
ASSERT_TRUE(unregister_server != NULL);
EXPECT_HRESULT_SUCCEEDED((*unregister_server)());
- DllUnregisterServerFn unregister_npapi_server = NULL;
- if (registration_type == PER_USER) {
- unregister_npapi_server =
- reinterpret_cast<DllUnregisterServerFn>(GetProcAddress(
- dll_handle, "UnregisterNPAPIUserPlugin"));
- } else {
- unregister_npapi_server =
- reinterpret_cast<DllUnregisterServerFn>(GetProcAddress(
- dll_handle, "UnregisterNPAPIPlugin"));
- }
-
- if (unregister_npapi_server != NULL)
- EXPECT_HRESULT_SUCCEEDED((*unregister_npapi_server)());
-
ASSERT_TRUE(FreeLibrary(dll_handle));
}
diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc
index c1f9fe5..a55d858 100644
--- a/chrome_frame/utils.cc
+++ b/chrome_frame/utils.cc
@@ -64,10 +64,7 @@ const wchar_t kRundllProfileName[] = L"rundll32";
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";
static const wchar_t kChromeFramePersistNPAPIReg[] = L"PersistNPAPIReg";
const char kAttachExternalTabPrefix[] = "attach_external_tab";
@@ -217,54 +214,18 @@ HRESULT UtilUnRegisterTypeLib(ITypeLib* typelib,
return hr;
}
-bool UtilIsNPAPIPluginRegistered() {
- std::wstring npapi_key_name(kChromeFrameNPAPIKey);
- RegKey npapi_key(HKEY_LOCAL_MACHINE, npapi_key_name.c_str(), KEY_QUERY_VALUE);
- return npapi_key.Valid();
-}
-
-bool UtilChangePersistentNPAPIMarker(bool set) {
+bool UtilRemovePersistentNPAPIMarker() {
BrowserDistribution* cf_dist = BrowserDistribution::GetDistribution();
std::wstring cf_state_key_path(cf_dist->GetStateKey());
+ RegKey cf_state_key;
- RegKey cf_state_key(HKEY_LOCAL_MACHINE, cf_state_key_path.c_str(),
- KEY_READ | KEY_WRITE);
-
- bool success = false;
- if (cf_state_key.Valid()) {
- if (set) {
- success = (cf_state_key.WriteValue(kChromeFramePersistNPAPIReg, 1) ==
- ERROR_SUCCESS);
- } else {
- // Unfortunately, DeleteValue returns true only if the value
- // previously existed, so we do a separate existence check to
- // validate success.
- cf_state_key.DeleteValue(kChromeFramePersistNPAPIReg);
- success = !cf_state_key.ValueExists(kChromeFramePersistNPAPIReg);
- }
- }
- return success;
+ LONG result = cf_state_key.Open(HKEY_LOCAL_MACHINE, cf_state_key_path.c_str(),
+ KEY_SET_VALUE);
+ if (result == ERROR_SUCCESS)
+ result = cf_state_key.DeleteValue(kChromeFramePersistNPAPIReg);
+ return (result == ERROR_SUCCESS || result == ERROR_FILE_NOT_FOUND);
}
-bool UtilIsPersistentNPAPIMarkerSet() {
- BrowserDistribution* cf_dist = BrowserDistribution::GetDistribution();
- std::wstring cf_state_key_path(cf_dist->GetStateKey());
-
- RegKey cf_state_key(HKEY_LOCAL_MACHINE, cf_state_key_path.c_str(),
- KEY_QUERY_VALUE);
-
- bool success = false;
- if (cf_state_key.Valid()) {
- DWORD val = 0;
- if (cf_state_key.ReadValueDW(kChromeFramePersistNPAPIReg, &val) ==
- ERROR_SUCCESS) {
- success = (val != 0);
- }
- }
- return success;
-}
-
-
HRESULT UtilGetXUACompatContentValue(const std::wstring& html_string,
std::wstring* content_value) {
if (!content_value) {
@@ -371,8 +332,6 @@ bool IsChrome(RendererType renderer_type) {
namespace {
const char kIEImageName[] = "iexplore.exe";
-const char kFirefoxImageName[] = "firefox.exe";
-const char kOperaImageName[] = "opera.exe";
} // namespace
std::wstring GetHostProcessName(bool include_extension) {
@@ -395,10 +354,6 @@ BrowserType GetBrowserType() {
std::wstring::const_iterator end = exe.end();
if (LowerCaseEqualsASCII(begin, end, kIEImageName)) {
browser_type = BROWSER_IE;
- } else if (LowerCaseEqualsASCII(begin, end, kFirefoxImageName)) {
- browser_type = BROWSER_FIREFOX;
- } else if (LowerCaseEqualsASCII(begin, end, kOperaImageName)) {
- browser_type = BROWSER_OPERA;
} else {
browser_type = BROWSER_UNKNOWN;
}
diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h
index b0352e6..7c24e9e 100644
--- a/chrome_frame/utils.h
+++ b/chrome_frame/utils.h
@@ -34,7 +34,6 @@ 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[];
@@ -74,15 +73,9 @@ HRESULT UtilRegisterTypeLib(ITypeLib* typelib,
HRESULT UtilUnRegisterTypeLib(ITypeLib* typelib,
bool for_current_user_only);
-// Utility function to tell if the NPAPI plugin is registered.
-bool UtilIsNPAPIPluginRegistered();
-
-// Sets or clears a marker that causes NPAPI registration to persist across
-// updates. The marker is added if set is true and is deleted otherwise.
-bool UtilChangePersistentNPAPIMarker(bool set);
-
-// Returns true if the persistent NPAPI marker is set, false otherwise.
-bool UtilIsPersistentNPAPIMarkerSet();
+// Clears a marker that causes legacy NPAPI registration to persist across
+// updates. Returns false if the marker could not be removed.
+bool UtilRemovePersistentNPAPIMarker();
// Given an HTML fragment, this function looks for the
// <meta http-equiv="X-UA-Compatible"> tag and extracts the value of the
@@ -156,8 +149,6 @@ typedef enum BrowserType {
BROWSER_INVALID = -1,
BROWSER_UNKNOWN,
BROWSER_IE,
- BROWSER_FIREFOX,
- BROWSER_OPERA,
};
BrowserType GetBrowserType();