diff options
author | initial.commit@chromium.org <initial.commit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-02 02:14:31 +0000 |
---|---|---|
committer | initial.commit@chromium.org <initial.commit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-02 02:14:31 +0000 |
commit | 5a7bdf208c28c210b39cff63d1cf91302b02821b (patch) | |
tree | 5ff484561562f78b29d2670168a9e3b40b48dcab /ceee/ie/plugin/bho/events_funnel.cc | |
parent | 26a54a5e0f4603c8fda2fe51789d331125993c9a (diff) | |
download | chromium_src-5a7bdf208c28c210b39cff63d1cf91302b02821b.zip chromium_src-5a7bdf208c28c210b39cff63d1cf91302b02821b.tar.gz chromium_src-5a7bdf208c28c210b39cff63d1cf91302b02821b.tar.bz2 |
Checking in the initial version of CEEE (Chrome Extensions Execution
Environment), an optional feature of Chrome Frame that acts as an
adapter layer for a subset of the Chrome Extension APIs. This enables
extensions that stick to the supported subset of APIs to work in the
context of Chrome Frame with minimal or sometimes no changes.
See http://www.chromium.org/developers/design-documents/ceee for an
overview of the design of CEEE.
TEST=unit tests (run ceee/smoke_tests.bat as an administrator on Windows)
BUG=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64712 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ceee/ie/plugin/bho/events_funnel.cc')
-rw-r--r-- | ceee/ie/plugin/bho/events_funnel.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/ceee/ie/plugin/bho/events_funnel.cc b/ceee/ie/plugin/bho/events_funnel.cc new file mode 100644 index 0000000..dfa0cdc --- /dev/null +++ b/ceee/ie/plugin/bho/events_funnel.cc @@ -0,0 +1,42 @@ +// 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. +// +// Common base class for funnels of Chrome Extension events that originate +// from the BHO and are sent to the Broker. + +#include "ceee/ie/plugin/bho/events_funnel.h" + +#include "base/json/json_writer.h" +#include "base/logging.h" +#include "base/values.h" +#include "ceee/ie/common/ceee_module_util.h" + + +EventsFunnel::EventsFunnel(bool keep_broker_alive) + : keep_broker_alive_(keep_broker_alive) { + if (keep_broker_alive_) + ceee_module_util::AddRefModuleWorkerThread(); +} + +EventsFunnel::~EventsFunnel() { + if (keep_broker_alive_) + ceee_module_util::ReleaseModuleWorkerThread(); +} + +HRESULT EventsFunnel::SendEvent(const char* event_name, + const Value& event_args) { + // Event arguments for FireEventToBroker always need to be stored in a list. + std::string event_args_str; + if (event_args.IsType(Value::TYPE_LIST)) { + base::JSONWriter::Write(&event_args, false, &event_args_str); + } else { + ListValue list; + list.Append(event_args.DeepCopy()); + base::JSONWriter::Write(&list, false, &event_args_str); + } + + EventsFunnel thread_locker(!keep_broker_alive_); + ceee_module_util::FireEventToBroker(event_name, event_args_str); + return S_OK; +} |