#include <map>
+#include "atom/browser/atom_browser_main_parts.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
.SetMethod("setSavePath", &DownloadItem::SetSavePath);
}
-void SetWrapDownloadItem(const WrapDownloadItemCallback& callback) {
- g_wrap_download_item = callback;
-}
-
-void ClearWrapDownloadItem() {
- g_wrap_download_item.Reset();
-}
-
// static
mate::Handle<DownloadItem> DownloadItem::Create(
v8::Isolate* isolate, content::DownloadItem* item) {
return &kDownloadItemSavePathKey;
}
+void ClearWrapDownloadItem() {
+ g_wrap_download_item.Reset();
+}
+
+void SetWrapDownloadItem(const WrapDownloadItemCallback& callback) {
+ g_wrap_download_item = callback;
+
+ // Cleanup the wrapper on exit.
+ atom::AtomBrowserMainParts::Get()->RegisterDestructionCallback(
+ base::Bind(ClearWrapDownloadItem));
+}
+
} // namespace api
} // namespace atom
v8::Isolate* isolate = context->GetIsolate();
mate::Dictionary dict(isolate, exports);
dict.SetMethod("_setWrapDownloadItem", &atom::api::SetWrapDownloadItem);
- dict.SetMethod("_clearWrapDownloadItem", &atom::api::ClearWrapDownloadItem);
}
} // namespace
#include "atom/browser/api/atom_api_cookies.h"
#include "atom/browser/api/atom_api_download_item.h"
-#include "atom/browser/atom_browser_context.h"
#include "atom/browser/api/atom_api_web_contents.h"
#include "atom/browser/api/save_page_handler.h"
+#include "atom/browser/atom_browser_context.h"
+#include "atom/browser/atom_browser_main_parts.h"
#include "atom/common/native_mate_converters/callback.h"
#include "atom/common/native_mate_converters/gurl_converter.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
static_cast<AtomBrowserContext*>(browser_context.get()));
}
+void ClearWrapSession() {
+ g_wrap_session.Reset();
+}
+
void SetWrapSession(const WrapSessionCallback& callback) {
g_wrap_session = callback;
-}
-void ClearWrapSession() {
- g_wrap_session.Reset();
+ // Cleanup the wrapper on exit.
+ atom::AtomBrowserMainParts::Get()->RegisterDestructionCallback(
+ base::Bind(ClearWrapSession));
}
} // namespace api
mate::Dictionary dict(isolate, exports);
dict.SetMethod("fromPartition", &atom::api::Session::FromPartition);
dict.SetMethod("_setWrapSession", &atom::api::SetWrapSession);
- dict.SetMethod("_clearWrapSession", &atom::api::ClearWrapSession);
}
} // namespace
return handle;
}
+void ClearWrapWebContents() {
+ g_wrap_web_contents.Reset();
+}
+
void SetWrapWebContents(const WrapWebContentsCallback& callback) {
g_wrap_web_contents = callback;
-}
-void ClearWrapWebContents() {
- g_wrap_web_contents.Reset();
+ // Cleanup the wrapper on exit.
+ atom::AtomBrowserMainParts::Get()->RegisterDestructionCallback(
+ base::Bind(ClearWrapWebContents));
}
} // namespace api
mate::Dictionary dict(isolate, exports);
dict.SetMethod("create", &atom::api::WebContents::Create);
dict.SetMethod("_setWrapWebContents", &atom::api::SetWrapWebContents);
- dict.SetMethod("_clearWrapWebContents", &atom::api::ClearWrapWebContents);
}
} // namespace
# Wrappers for native classes.
sessionBindings._setWrapSession wrapSession
-process.once 'exit', sessionBindings._clearWrapSession
-
downloadItemBindings._setWrapDownloadItem wrapDownloadItem
-process.once 'exit', downloadItemBindings._clearWrapDownloadItem
# Only one App object pemitted.
module.exports = app
@_printToPDF printingSetting, callback
binding._setWrapWebContents wrapWebContents
-process.once 'exit', binding._clearWrapWebContents
module.exports.create = (options={}) ->
binding.create(options)