refactor: move notifications from brightray to atom (#15209)
This commit is contained in:
parent
4d085c4aae
commit
a369a4172b
46 changed files with 423 additions and 363 deletions
|
@ -5,13 +5,13 @@
|
||||||
#include "atom/browser/api/atom_api_notification.h"
|
#include "atom/browser/api/atom_api_notification.h"
|
||||||
|
|
||||||
#include "atom/browser/api/atom_api_menu.h"
|
#include "atom/browser/api/atom_api_menu.h"
|
||||||
|
#include "atom/browser/atom_browser_client.h"
|
||||||
#include "atom/browser/browser.h"
|
#include "atom/browser/browser.h"
|
||||||
#include "atom/common/native_mate_converters/gfx_converter.h"
|
#include "atom/common/native_mate_converters/gfx_converter.h"
|
||||||
#include "atom/common/native_mate_converters/image_converter.h"
|
#include "atom/common/native_mate_converters/image_converter.h"
|
||||||
#include "atom/common/native_mate_converters/string16_converter.h"
|
#include "atom/common/native_mate_converters/string16_converter.h"
|
||||||
#include "base/guid.h"
|
#include "base/guid.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "brightray/browser/browser_client.h"
|
|
||||||
#include "native_mate/constructor.h"
|
#include "native_mate/constructor.h"
|
||||||
#include "native_mate/dictionary.h"
|
#include "native_mate/dictionary.h"
|
||||||
#include "native_mate/object_template_builder.h"
|
#include "native_mate/object_template_builder.h"
|
||||||
|
@ -22,10 +22,10 @@
|
||||||
|
|
||||||
namespace mate {
|
namespace mate {
|
||||||
template <>
|
template <>
|
||||||
struct Converter<brightray::NotificationAction> {
|
struct Converter<atom::NotificationAction> {
|
||||||
static bool FromV8(v8::Isolate* isolate,
|
static bool FromV8(v8::Isolate* isolate,
|
||||||
v8::Local<v8::Value> val,
|
v8::Local<v8::Value> val,
|
||||||
brightray::NotificationAction* out) {
|
atom::NotificationAction* out) {
|
||||||
mate::Dictionary dict;
|
mate::Dictionary dict;
|
||||||
if (!ConvertFromV8(isolate, val, &dict))
|
if (!ConvertFromV8(isolate, val, &dict))
|
||||||
return false;
|
return false;
|
||||||
|
@ -38,7 +38,7 @@ struct Converter<brightray::NotificationAction> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||||
brightray::NotificationAction val) {
|
atom::NotificationAction val) {
|
||||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||||
dict.Set("text", val.text);
|
dict.Set("text", val.text);
|
||||||
dict.Set("type", val.type);
|
dict.Set("type", val.type);
|
||||||
|
@ -56,7 +56,8 @@ Notification::Notification(v8::Isolate* isolate,
|
||||||
mate::Arguments* args) {
|
mate::Arguments* args) {
|
||||||
InitWith(isolate, wrapper);
|
InitWith(isolate, wrapper);
|
||||||
|
|
||||||
presenter_ = brightray::BrowserClient::Get()->GetNotificationPresenter();
|
presenter_ = static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||||
|
->GetNotificationPresenter();
|
||||||
|
|
||||||
mate::Dictionary opts;
|
mate::Dictionary opts;
|
||||||
if (args->GetNext(&opts)) {
|
if (args->GetNext(&opts)) {
|
||||||
|
@ -119,7 +120,7 @@ base::string16 Notification::GetSound() const {
|
||||||
return sound_;
|
return sound_;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<brightray::NotificationAction> Notification::GetActions() const {
|
std::vector<atom::NotificationAction> Notification::GetActions() const {
|
||||||
return actions_;
|
return actions_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,7 +158,7 @@ void Notification::SetSound(const base::string16& new_sound) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::SetActions(
|
void Notification::SetActions(
|
||||||
const std::vector<brightray::NotificationAction>& actions) {
|
const std::vector<atom::NotificationAction>& actions) {
|
||||||
actions_ = actions;
|
actions_ = actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,7 +201,7 @@ void Notification::Show() {
|
||||||
if (presenter_) {
|
if (presenter_) {
|
||||||
notification_ = presenter_->CreateNotification(this, base::GenerateGUID());
|
notification_ = presenter_->CreateNotification(this, base::GenerateGUID());
|
||||||
if (notification_) {
|
if (notification_) {
|
||||||
brightray::NotificationOptions options;
|
atom::NotificationOptions options;
|
||||||
options.title = title_;
|
options.title = title_;
|
||||||
options.subtitle = subtitle_;
|
options.subtitle = subtitle_;
|
||||||
options.msg = body_;
|
options.msg = body_;
|
||||||
|
@ -218,7 +219,8 @@ void Notification::Show() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Notification::IsSupported() {
|
bool Notification::IsSupported() {
|
||||||
return !!brightray::BrowserClient::Get()->GetNotificationPresenter();
|
return !!static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||||
|
->GetNotificationPresenter();
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "atom/browser/api/trackable_object.h"
|
#include "atom/browser/api/trackable_object.h"
|
||||||
|
#include "atom/browser/notifications/notification.h"
|
||||||
|
#include "atom/browser/notifications/notification_delegate.h"
|
||||||
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "brightray/browser/notification.h"
|
|
||||||
#include "brightray/browser/notification_delegate.h"
|
|
||||||
#include "brightray/browser/notification_presenter.h"
|
|
||||||
#include "native_mate/handle.h"
|
#include "native_mate/handle.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace atom {
|
||||||
namespace api {
|
namespace api {
|
||||||
|
|
||||||
class Notification : public mate::TrackableObject<Notification>,
|
class Notification : public mate::TrackableObject<Notification>,
|
||||||
public brightray::NotificationDelegate {
|
public NotificationDelegate {
|
||||||
public:
|
public:
|
||||||
static mate::WrappableBase* New(mate::Arguments* args);
|
static mate::WrappableBase* New(mate::Arguments* args);
|
||||||
static bool IsSupported();
|
static bool IsSupported();
|
||||||
|
@ -55,7 +55,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||||
bool GetHasReply() const;
|
bool GetHasReply() const;
|
||||||
base::string16 GetReplyPlaceholder() const;
|
base::string16 GetReplyPlaceholder() const;
|
||||||
base::string16 GetSound() const;
|
base::string16 GetSound() const;
|
||||||
std::vector<brightray::NotificationAction> GetActions() const;
|
std::vector<atom::NotificationAction> GetActions() const;
|
||||||
base::string16 GetCloseButtonText() const;
|
base::string16 GetCloseButtonText() const;
|
||||||
|
|
||||||
// Prop Setters
|
// Prop Setters
|
||||||
|
@ -66,7 +66,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||||
void SetHasReply(bool new_has_reply);
|
void SetHasReply(bool new_has_reply);
|
||||||
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
||||||
void SetSound(const base::string16& sound);
|
void SetSound(const base::string16& sound);
|
||||||
void SetActions(const std::vector<brightray::NotificationAction>& actions);
|
void SetActions(const std::vector<atom::NotificationAction>& actions);
|
||||||
void SetCloseButtonText(const base::string16& text);
|
void SetCloseButtonText(const base::string16& text);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -80,12 +80,12 @@ class Notification : public mate::TrackableObject<Notification>,
|
||||||
bool has_reply_ = false;
|
bool has_reply_ = false;
|
||||||
base::string16 reply_placeholder_;
|
base::string16 reply_placeholder_;
|
||||||
base::string16 sound_;
|
base::string16 sound_;
|
||||||
std::vector<brightray::NotificationAction> actions_;
|
std::vector<atom::NotificationAction> actions_;
|
||||||
base::string16 close_button_text_;
|
base::string16 close_button_text_;
|
||||||
|
|
||||||
brightray::NotificationPresenter* presenter_;
|
atom::NotificationPresenter* presenter_;
|
||||||
|
|
||||||
base::WeakPtr<brightray::Notification> notification_;
|
base::WeakPtr<atom::Notification> notification_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Notification);
|
DISALLOW_COPY_AND_ASSIGN(Notification);
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,6 +23,8 @@
|
||||||
#include "atom/browser/child_web_contents_tracker.h"
|
#include "atom/browser/child_web_contents_tracker.h"
|
||||||
#include "atom/browser/io_thread.h"
|
#include "atom/browser/io_thread.h"
|
||||||
#include "atom/browser/native_window.h"
|
#include "atom/browser/native_window.h"
|
||||||
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
|
#include "atom/browser/notifications/platform_notification_service.h"
|
||||||
#include "atom/browser/session_preferences.h"
|
#include "atom/browser/session_preferences.h"
|
||||||
#include "atom/browser/web_contents_permission_helper.h"
|
#include "atom/browser/web_contents_permission_helper.h"
|
||||||
#include "atom/browser/web_contents_preferences.h"
|
#include "atom/browser/web_contents_preferences.h"
|
||||||
|
@ -675,4 +677,19 @@ AtomBrowserClient::CreateThrottlesForNavigation(
|
||||||
return throttles;
|
return throttles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NotificationPresenter* AtomBrowserClient::GetNotificationPresenter() {
|
||||||
|
if (!notification_presenter_) {
|
||||||
|
notification_presenter_.reset(NotificationPresenter::Create());
|
||||||
|
}
|
||||||
|
return notification_presenter_.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
content::PlatformNotificationService*
|
||||||
|
AtomBrowserClient::GetPlatformNotificationService() {
|
||||||
|
if (!notification_service_) {
|
||||||
|
notification_service_.reset(new PlatformNotificationService(this));
|
||||||
|
}
|
||||||
|
return notification_service_.get();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace atom
|
} // namespace atom
|
||||||
|
|
|
@ -27,6 +27,8 @@ class SSLCertRequestInfo;
|
||||||
namespace atom {
|
namespace atom {
|
||||||
|
|
||||||
class AtomResourceDispatcherHostDelegate;
|
class AtomResourceDispatcherHostDelegate;
|
||||||
|
class NotificationPresenter;
|
||||||
|
class PlatformNotificationService;
|
||||||
|
|
||||||
class AtomBrowserClient : public brightray::BrowserClient,
|
class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
public content::RenderProcessHostObserver {
|
public content::RenderProcessHostObserver {
|
||||||
|
@ -47,6 +49,12 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
static void SetCustomServiceWorkerSchemes(
|
static void SetCustomServiceWorkerSchemes(
|
||||||
const std::vector<std::string>& schemes);
|
const std::vector<std::string>& schemes);
|
||||||
|
|
||||||
|
NotificationPresenter* GetNotificationPresenter();
|
||||||
|
|
||||||
|
void WebNotificationAllowed(int render_process_id,
|
||||||
|
const base::Callback<void(bool, bool)>& callback);
|
||||||
|
|
||||||
|
// content::NavigatorDelegate
|
||||||
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
std::vector<std::unique_ptr<content::NavigationThrottle>>
|
||||||
CreateThrottlesForNavigation(content::NavigationHandle* handle) override;
|
CreateThrottlesForNavigation(content::NavigationHandle* handle) override;
|
||||||
|
|
||||||
|
@ -117,13 +125,12 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
std::unique_ptr<base::Value> GetServiceManifestOverlay(
|
std::unique_ptr<base::Value> GetServiceManifestOverlay(
|
||||||
base::StringPiece name) override;
|
base::StringPiece name) override;
|
||||||
net::NetLog* GetNetLog() override;
|
net::NetLog* GetNetLog() override;
|
||||||
|
content::PlatformNotificationService* GetPlatformNotificationService()
|
||||||
|
override;
|
||||||
|
|
||||||
// brightray::BrowserClient:
|
// brightray::BrowserClient:
|
||||||
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
|
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
|
||||||
const content::MainFunctionParams&) override;
|
const content::MainFunctionParams&) override;
|
||||||
void WebNotificationAllowed(
|
|
||||||
int render_process_id,
|
|
||||||
const base::Callback<void(bool, bool)>& callback) override;
|
|
||||||
|
|
||||||
// content::RenderProcessHostObserver:
|
// content::RenderProcessHostObserver:
|
||||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||||
|
@ -170,6 +177,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
std::unique_ptr<AtomResourceDispatcherHostDelegate>
|
std::unique_ptr<AtomResourceDispatcherHostDelegate>
|
||||||
resource_dispatcher_host_delegate_;
|
resource_dispatcher_host_delegate_;
|
||||||
|
|
||||||
|
std::unique_ptr<PlatformNotificationService> notification_service_;
|
||||||
|
std::unique_ptr<NotificationPresenter> notification_presenter_;
|
||||||
|
|
||||||
Delegate* delegate_ = nullptr;
|
Delegate* delegate_ = nullptr;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// This is generated file. Do not modify directly.
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
// Path to the code generator:
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// tools/generate_library_loader/generate_library_loader.py .
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "brightray/browser/linux/libnotify_loader.h"
|
#include "atom/browser/notifications/linux/libnotify_loader.h"
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
// This is generated file. Do not modify directly.
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
// Path to the code generator:
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// tools/generate_library_loader/generate_library_loader.py .
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_LOADER_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_LOADER_H_
|
||||||
#define BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_LOADER_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_LOADER_H_
|
||||||
|
|
||||||
|
// FIXME Generate during build using
|
||||||
|
// //tools/generate_library_loader/generate_library_loader.gni
|
||||||
|
|
||||||
#include <libnotify/notify.h>
|
#include <libnotify/notify.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -43,4 +46,4 @@ class LibNotifyLoader {
|
||||||
void operator=(const LibNotifyLoader&);
|
void operator=(const LibNotifyLoader&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_LOADER_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_LOADER_H_
|
|
@ -2,24 +2,24 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "brightray/browser/linux/libnotify_notification.h"
|
#include "atom/browser/notifications/linux/libnotify_notification.h"
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/notification_delegate.h"
|
||||||
#include "base/files/file_enumerator.h"
|
#include "base/files/file_enumerator.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "brightray/browser/notification_delegate.h"
|
|
||||||
#include "brightray/common/application_info.h"
|
#include "brightray/common/application_info.h"
|
||||||
#include "brightray/common/platform_util.h"
|
#include "brightray/common/platform_util.h"
|
||||||
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
||||||
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
|
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ bool LibnotifyNotification::Initialize() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!libnotify_loader_.notify_is_initted() &&
|
if (!libnotify_loader_.notify_is_initted() &&
|
||||||
!libnotify_loader_.notify_init(GetApplicationName().c_str())) {
|
!libnotify_loader_.notify_init(brightray::GetApplicationName().c_str())) {
|
||||||
LOG(WARNING) << "Unable to initialize libnotify; notifications disabled";
|
LOG(WARNING) << "Unable to initialize libnotify; notifications disabled";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -127,7 +127,7 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
|
||||||
// Send the desktop name to identify the application
|
// Send the desktop name to identify the application
|
||||||
// The desktop-entry is the part before the .desktop
|
// The desktop-entry is the part before the .desktop
|
||||||
std::string desktop_id;
|
std::string desktop_id;
|
||||||
if (platform_util::GetDesktopName(&desktop_id)) {
|
if (brightray::platform_util::GetDesktopName(&desktop_id)) {
|
||||||
const std::string suffix{".desktop"};
|
const std::string suffix{".desktop"};
|
||||||
if (base::EndsWith(desktop_id, suffix,
|
if (base::EndsWith(desktop_id, suffix,
|
||||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||||
|
@ -173,4 +173,4 @@ void LibnotifyNotification::OnNotificationView(NotifyNotification* notification,
|
||||||
NotificationClicked();
|
NotificationClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -2,17 +2,17 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
||||||
#define BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "brightray/browser/linux/libnotify_loader.h"
|
#include "atom/browser/notifications/linux/libnotify_loader.h"
|
||||||
#include "brightray/browser/notification.h"
|
#include "atom/browser/notifications/notification.h"
|
||||||
#include "ui/base/glib/glib_signal.h"
|
#include "ui/base/glib/glib_signal.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class LibnotifyNotification : public Notification {
|
class LibnotifyNotification : public Notification {
|
||||||
public:
|
public:
|
||||||
|
@ -42,6 +42,6 @@ class LibnotifyNotification : public Notification {
|
||||||
DISALLOW_COPY_AND_ASSIGN(LibnotifyNotification);
|
DISALLOW_COPY_AND_ASSIGN(LibnotifyNotification);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
|
@ -3,11 +3,11 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-CHROMIUM file.
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
#include "brightray/browser/linux/notification_presenter_linux.h"
|
#include "atom/browser/notifications/linux/notification_presenter_linux.h"
|
||||||
|
|
||||||
#include "brightray/browser/linux/libnotify_notification.h"
|
#include "atom/browser/notifications/linux/libnotify_notification.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
NotificationPresenter* NotificationPresenter::Create() {
|
NotificationPresenter* NotificationPresenter::Create() {
|
||||||
|
@ -25,4 +25,4 @@ Notification* NotificationPresenterLinux::CreateNotificationObject(
|
||||||
return new LibnotifyNotification(delegate, this);
|
return new LibnotifyNotification(delegate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -3,12 +3,12 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-CHROMIUM file.
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_LINUX_NOTIFICATION_PRESENTER_LINUX_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_LINUX_NOTIFICATION_PRESENTER_LINUX_H_
|
||||||
#define BRIGHTRAY_BROWSER_LINUX_NOTIFICATION_PRESENTER_LINUX_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_LINUX_NOTIFICATION_PRESENTER_LINUX_H_
|
||||||
|
|
||||||
#include "brightray/browser/notification_presenter.h"
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class NotificationPresenterLinux : public NotificationPresenter {
|
class NotificationPresenterLinux : public NotificationPresenter {
|
||||||
public:
|
public:
|
||||||
|
@ -22,6 +22,6 @@ class NotificationPresenterLinux : public NotificationPresenter {
|
||||||
DISALLOW_COPY_AND_ASSIGN(NotificationPresenterLinux);
|
DISALLOW_COPY_AND_ASSIGN(NotificationPresenterLinux);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_LINUX_NOTIFICATION_PRESENTER_LINUX_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_LINUX_NOTIFICATION_PRESENTER_LINUX_H_
|
|
@ -2,8 +2,8 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
|
||||||
#define BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
@ -11,10 +11,10 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/notification.h"
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "brightray/browser/notification.h"
|
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class CocoaNotification : public Notification {
|
class CocoaNotification : public Notification {
|
||||||
public:
|
public:
|
||||||
|
@ -45,6 +45,6 @@ class CocoaNotification : public Notification {
|
||||||
DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
|
DISALLOW_COPY_AND_ASSIGN(CocoaNotification);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
|
|
@ -2,16 +2,16 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "brightray/browser/mac/cocoa_notification.h"
|
#include "atom/browser/notifications/mac/cocoa_notification.h"
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/notification_delegate.h"
|
||||||
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "brightray/browser/notification_delegate.h"
|
|
||||||
#include "brightray/browser/notification_presenter.h"
|
|
||||||
#include "skia/ext/skia_utils_mac.h"
|
#include "skia/ext/skia_utils_mac.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
int g_identifier_ = 1;
|
int g_identifier_ = 1;
|
||||||
|
|
||||||
|
@ -171,4 +171,4 @@ void CocoaNotification::LogAction(const char* action) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -0,0 +1,22 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
||||||
|
#define ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
||||||
|
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
class NotificationPresenterMac;
|
||||||
|
}
|
||||||
|
|
||||||
|
@interface NotificationCenterDelegate
|
||||||
|
: NSObject <NSUserNotificationCenterDelegate> {
|
||||||
|
@private
|
||||||
|
atom::NotificationPresenterMac* presenter_;
|
||||||
|
}
|
||||||
|
- (instancetype)initWithPresenter:(atom::NotificationPresenterMac*)presenter;
|
||||||
|
@end
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_CENTER_DELEGATE_H_
|
|
@ -2,15 +2,14 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "brightray/browser/mac/notification_center_delegate.h"
|
#include "atom/browser/notifications/mac/notification_center_delegate.h"
|
||||||
|
|
||||||
#include "brightray/browser/mac/cocoa_notification.h"
|
#include "atom/browser/notifications/mac/cocoa_notification.h"
|
||||||
#include "brightray/browser/mac/notification_presenter_mac.h"
|
#include "atom/browser/notifications/mac/notification_presenter_mac.h"
|
||||||
|
|
||||||
@implementation NotificationCenterDelegate
|
@implementation NotificationCenterDelegate
|
||||||
|
|
||||||
- (instancetype)initWithPresenter:
|
- (instancetype)initWithPresenter:(atom::NotificationPresenterMac*)presenter {
|
||||||
(brightray::NotificationPresenterMac*)presenter {
|
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (!self)
|
if (!self)
|
||||||
return nil;
|
return nil;
|
|
@ -3,14 +3,14 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-CHROMIUM file.
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_MAC_NOTIFICATION_PRESENTER_MAC_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_PRESENTER_MAC_H_
|
||||||
#define BRIGHTRAY_BROWSER_MAC_NOTIFICATION_PRESENTER_MAC_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_PRESENTER_MAC_H_
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/mac/notification_center_delegate.h"
|
||||||
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "brightray/browser/mac/notification_center_delegate.h"
|
|
||||||
#include "brightray/browser/notification_presenter.h"
|
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class CocoaNotification;
|
class CocoaNotification;
|
||||||
|
|
||||||
|
@ -31,6 +31,6 @@ class NotificationPresenterMac : public NotificationPresenter {
|
||||||
DISALLOW_COPY_AND_ASSIGN(NotificationPresenterMac);
|
DISALLOW_COPY_AND_ASSIGN(NotificationPresenterMac);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_MAC_NOTIFICATION_PRESENTER_MAC_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_MAC_NOTIFICATION_PRESENTER_MAC_H_
|
|
@ -2,12 +2,12 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "brightray/browser/mac/notification_presenter_mac.h"
|
#include "atom/browser/notifications/mac/notification_presenter_mac.h"
|
||||||
|
|
||||||
#include "brightray/browser/mac/cocoa_notification.h"
|
#include "atom/browser/notifications/mac/cocoa_notification.h"
|
||||||
#include "brightray/browser/mac/notification_center_delegate.h"
|
#include "atom/browser/notifications/mac/notification_center_delegate.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
// static
|
// static
|
||||||
NotificationPresenter* NotificationPresenter::Create() {
|
NotificationPresenter* NotificationPresenter::Create() {
|
||||||
|
@ -47,4 +47,4 @@ Notification* NotificationPresenterMac::CreateNotificationObject(
|
||||||
return new CocoaNotification(delegate, this);
|
return new CocoaNotification(delegate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -2,12 +2,12 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "brightray/browser/notification.h"
|
#include "atom/browser/notifications/notification.h"
|
||||||
|
|
||||||
#include "brightray/browser/notification_delegate.h"
|
#include "atom/browser/notifications/notification_delegate.h"
|
||||||
#include "brightray/browser/notification_presenter.h"
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
NotificationOptions::NotificationOptions() = default;
|
NotificationOptions::NotificationOptions() = default;
|
||||||
NotificationOptions::~NotificationOptions() = default;
|
NotificationOptions::~NotificationOptions() = default;
|
||||||
|
@ -43,4 +43,4 @@ void Notification::Destroy() {
|
||||||
presenter()->RemoveNotification(this);
|
presenter()->RemoveNotification(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -2,8 +2,8 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
|
||||||
#define BRIGHTRAY_BROWSER_NOTIFICATION_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
#include "url/gurl.h"
|
#include "url/gurl.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class NotificationDelegate;
|
class NotificationDelegate;
|
||||||
class NotificationPresenter;
|
class NotificationPresenter;
|
||||||
|
@ -84,6 +84,6 @@ class Notification {
|
||||||
DISALLOW_COPY_AND_ASSIGN(Notification);
|
DISALLOW_COPY_AND_ASSIGN(Notification);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_NOTIFICATION_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
|
|
@ -2,12 +2,12 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_DELEGATE_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_
|
||||||
#define BRIGHTRAY_BROWSER_NOTIFICATION_DELEGATE_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class NotificationDelegate {
|
class NotificationDelegate {
|
||||||
public:
|
public:
|
||||||
|
@ -30,6 +30,6 @@ class NotificationDelegate {
|
||||||
~NotificationDelegate() = default;
|
~NotificationDelegate() = default;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_NOTIFICATION_DELEGATE_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_
|
|
@ -2,13 +2,13 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "brightray/browser/notification_presenter.h"
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
#include "brightray/browser/notification.h"
|
#include "atom/browser/notifications/notification.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
NotificationPresenter::NotificationPresenter() {}
|
NotificationPresenter::NotificationPresenter() {}
|
||||||
|
|
||||||
|
@ -41,4 +41,4 @@ void NotificationPresenter::CloseNotificationWithId(
|
||||||
(*it)->Dismiss();
|
(*it)->Dismiss();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -2,15 +2,15 @@
|
||||||
// Use of this source code is governed by the MIT license that can be
|
// Use of this source code is governed by the MIT license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_PRESENTER_H_
|
||||||
#define BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_PRESENTER_H_
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "base/memory/weak_ptr.h"
|
#include "base/memory/weak_ptr.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class Notification;
|
class Notification;
|
||||||
class NotificationDelegate;
|
class NotificationDelegate;
|
||||||
|
@ -43,6 +43,6 @@ class NotificationPresenter {
|
||||||
DISALLOW_COPY_AND_ASSIGN(NotificationPresenter);
|
DISALLOW_COPY_AND_ASSIGN(NotificationPresenter);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_PRESENTER_H_
|
|
@ -2,20 +2,20 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-CHROMIUM file.
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
#include "brightray/browser/platform_notification_service.h"
|
#include "atom/browser/notifications/platform_notification_service.h"
|
||||||
|
|
||||||
|
#include "atom/browser/atom_browser_client.h"
|
||||||
|
#include "atom/browser/notifications/notification.h"
|
||||||
|
#include "atom/browser/notifications/notification_delegate.h"
|
||||||
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "brightray/browser/browser_client.h"
|
|
||||||
#include "brightray/browser/notification.h"
|
|
||||||
#include "brightray/browser/notification_delegate.h"
|
|
||||||
#include "brightray/browser/notification_presenter.h"
|
|
||||||
#include "content/public/browser/notification_event_dispatcher.h"
|
#include "content/public/browser/notification_event_dispatcher.h"
|
||||||
#include "content/public/browser/render_process_host.h"
|
#include "content/public/browser/render_process_host.h"
|
||||||
#include "content/public/common/notification_resources.h"
|
#include "content/public/common/notification_resources.h"
|
||||||
#include "content/public/common/platform_notification_data.h"
|
#include "content/public/common/platform_notification_data.h"
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ void OnWebNotificationAllowed(base::WeakPtr<Notification> notification,
|
||||||
if (!notification)
|
if (!notification)
|
||||||
return;
|
return;
|
||||||
if (allowed) {
|
if (allowed) {
|
||||||
brightray::NotificationOptions options;
|
atom::NotificationOptions options;
|
||||||
options.title = data.title;
|
options.title = data.title;
|
||||||
options.msg = data.body;
|
options.msg = data.body;
|
||||||
options.tag = data.tag;
|
options.tag = data.tag;
|
||||||
|
@ -41,7 +41,7 @@ void OnWebNotificationAllowed(base::WeakPtr<Notification> notification,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NotificationDelegateImpl final : public brightray::NotificationDelegate {
|
class NotificationDelegateImpl final : public atom::NotificationDelegate {
|
||||||
public:
|
public:
|
||||||
explicit NotificationDelegateImpl(const std::string& notification_id)
|
explicit NotificationDelegateImpl(const std::string& notification_id)
|
||||||
: notification_id_(notification_id) {}
|
: notification_id_(notification_id) {}
|
||||||
|
@ -72,7 +72,7 @@ class NotificationDelegateImpl final : public brightray::NotificationDelegate {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
PlatformNotificationService::PlatformNotificationService(
|
PlatformNotificationService::PlatformNotificationService(
|
||||||
BrowserClient* browser_client)
|
AtomBrowserClient* browser_client)
|
||||||
: browser_client_(browser_client) {}
|
: browser_client_(browser_client) {}
|
||||||
|
|
||||||
PlatformNotificationService::~PlatformNotificationService() {}
|
PlatformNotificationService::~PlatformNotificationService() {}
|
||||||
|
@ -130,4 +130,4 @@ int64_t PlatformNotificationService::ReadNextPersistentNotificationId(
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -2,8 +2,8 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-CHROMIUM file.
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_H_
|
||||||
#define BRIGHTRAY_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_H_
|
||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -11,14 +11,14 @@
|
||||||
#include "content/public/browser/browser_context.h"
|
#include "content/public/browser/browser_context.h"
|
||||||
#include "content/public/browser/platform_notification_service.h"
|
#include "content/public/browser/platform_notification_service.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class BrowserClient;
|
class AtomBrowserClient;
|
||||||
|
|
||||||
class PlatformNotificationService
|
class PlatformNotificationService
|
||||||
: public content::PlatformNotificationService {
|
: public content::PlatformNotificationService {
|
||||||
public:
|
public:
|
||||||
explicit PlatformNotificationService(BrowserClient* browser_client);
|
explicit PlatformNotificationService(AtomBrowserClient* browser_client);
|
||||||
~PlatformNotificationService() override;
|
~PlatformNotificationService() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -48,11 +48,11 @@ class PlatformNotificationService
|
||||||
content::BrowserContext* browser_context) override;
|
content::BrowserContext* browser_context) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BrowserClient* browser_client_;
|
AtomBrowserClient* browser_client_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(PlatformNotificationService);
|
DISALLOW_COPY_AND_ASSIGN(PlatformNotificationService);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_H_
|
|
@ -4,12 +4,14 @@
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE-CHROMIUM file.
|
// found in the LICENSE-CHROMIUM file.
|
||||||
|
|
||||||
#include "brightray/browser/win/notification_presenter_win.h"
|
#include "atom/browser/notifications/win/notification_presenter_win.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/win/notification_presenter_win7.h"
|
||||||
|
#include "atom/browser/notifications/win/windows_toast_notification.h"
|
||||||
#include "base/environment.h"
|
#include "base/environment.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/md5.h"
|
#include "base/md5.h"
|
||||||
|
@ -17,15 +19,13 @@
|
||||||
#include "base/threading/thread_restrictions.h"
|
#include "base/threading/thread_restrictions.h"
|
||||||
#include "base/time/time.h"
|
#include "base/time/time.h"
|
||||||
#include "base/win/windows_version.h"
|
#include "base/win/windows_version.h"
|
||||||
#include "brightray/browser/win/notification_presenter_win7.h"
|
|
||||||
#include "brightray/browser/win/windows_toast_notification.h"
|
|
||||||
#include "content/public/common/platform_notification_data.h"
|
#include "content/public/common/platform_notification_data.h"
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
#include "ui/gfx/codec/png_codec.h"
|
#include "ui/gfx/codec/png_codec.h"
|
||||||
|
|
||||||
#pragma comment(lib, "runtimeobject.lib")
|
#pragma comment(lib, "runtimeobject.lib")
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -98,4 +98,4 @@ Notification* NotificationPresenterWin::CreateNotificationObject(
|
||||||
return new WindowsToastNotification(delegate, this);
|
return new WindowsToastNotification(delegate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -20,17 +20,17 @@
|
||||||
// console.log("Notification dismissed")
|
// console.log("Notification dismissed")
|
||||||
// };
|
// };
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_WIN_NOTIFICATION_PRESENTER_WIN_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_NOTIFICATION_PRESENTER_WIN_H_
|
||||||
#define BRIGHTRAY_BROWSER_WIN_NOTIFICATION_PRESENTER_WIN_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_WIN_NOTIFICATION_PRESENTER_WIN_H_
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
#include "base/files/scoped_temp_dir.h"
|
#include "base/files/scoped_temp_dir.h"
|
||||||
#include "base/strings/string16.h"
|
#include "base/strings/string16.h"
|
||||||
#include "brightray/browser/notification_presenter.h"
|
|
||||||
|
|
||||||
class GURL;
|
class GURL;
|
||||||
class SkBitmap;
|
class SkBitmap;
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class NotificationPresenterWin : public NotificationPresenter {
|
class NotificationPresenterWin : public NotificationPresenter {
|
||||||
public:
|
public:
|
||||||
|
@ -50,6 +50,6 @@ class NotificationPresenterWin : public NotificationPresenter {
|
||||||
DISALLOW_COPY_AND_ASSIGN(NotificationPresenterWin);
|
DISALLOW_COPY_AND_ASSIGN(NotificationPresenterWin);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_WIN_NOTIFICATION_PRESENTER_WIN_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_WIN_NOTIFICATION_PRESENTER_WIN_H_
|
|
@ -1,12 +1,16 @@
|
||||||
#include "brightray/browser/win/notification_presenter_win7.h"
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/win/notification_presenter_win7.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "brightray/browser/win/win32_notification.h"
|
#include "atom/browser/notifications/win/win32_notification.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
brightray::Notification* NotificationPresenterWin7::CreateNotificationObject(
|
atom::Notification* NotificationPresenterWin7::CreateNotificationObject(
|
||||||
NotificationDelegate* delegate) {
|
NotificationDelegate* delegate) {
|
||||||
return new Win32Notification(delegate, this);
|
return new Win32Notification(delegate, this);
|
||||||
}
|
}
|
||||||
|
@ -34,17 +38,17 @@ Win32Notification* NotificationPresenterWin7::GetNotificationObjectByTag(
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationPresenterWin7::OnNotificationClicked(
|
void NotificationPresenterWin7::OnNotificationClicked(
|
||||||
Notification& notification) {
|
const Notification& notification) {
|
||||||
auto* n = GetNotificationObjectByRef(notification);
|
auto* n = GetNotificationObjectByRef(notification);
|
||||||
if (n)
|
if (n)
|
||||||
n->NotificationClicked();
|
n->NotificationClicked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationPresenterWin7::OnNotificationDismissed(
|
void NotificationPresenterWin7::OnNotificationDismissed(
|
||||||
Notification& notification) {
|
const Notification& notification) {
|
||||||
auto* n = GetNotificationObjectByRef(notification);
|
auto* n = GetNotificationObjectByRef(notification);
|
||||||
if (n)
|
if (n)
|
||||||
n->NotificationDismissed();
|
n->NotificationDismissed();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
39
atom/browser/notifications/win/notification_presenter_win7.h
Normal file
39
atom/browser/notifications/win/notification_presenter_win7.h
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_NOTIFICATION_PRESENTER_WIN7_H_
|
||||||
|
#define ATOM_BROWSER_NOTIFICATIONS_WIN_NOTIFICATION_PRESENTER_WIN7_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/notification_presenter.h"
|
||||||
|
#include "atom/browser/notifications/win/win32_desktop_notifications/desktop_notification_controller.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
class Win32Notification;
|
||||||
|
|
||||||
|
class NotificationPresenterWin7 : public NotificationPresenter,
|
||||||
|
public DesktopNotificationController {
|
||||||
|
public:
|
||||||
|
NotificationPresenterWin7() = default;
|
||||||
|
|
||||||
|
Win32Notification* GetNotificationObjectByRef(
|
||||||
|
const DesktopNotificationController::Notification& ref);
|
||||||
|
|
||||||
|
Win32Notification* GetNotificationObjectByTag(const std::string& tag);
|
||||||
|
|
||||||
|
private:
|
||||||
|
atom::Notification* CreateNotificationObject(
|
||||||
|
NotificationDelegate* delegate) override;
|
||||||
|
|
||||||
|
void OnNotificationClicked(const Notification& notification) override;
|
||||||
|
void OnNotificationDismissed(const Notification& notification) override;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(NotificationPresenterWin7);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_NOTIFICATIONS_WIN_NOTIFICATION_PRESENTER_WIN7_H_
|
|
@ -1,7 +1,13 @@
|
||||||
#pragma once
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_COMMON_H_
|
||||||
|
#define ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_COMMON_H_
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
struct NotificationData {
|
struct NotificationData {
|
||||||
DesktopNotificationController* controller = nullptr;
|
DesktopNotificationController* controller = nullptr;
|
||||||
|
@ -57,4 +63,6 @@ struct ScreenMetrics {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_COMMON_H_
|
|
@ -1,20 +1,29 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef NOMINMAX
|
#ifndef NOMINMAX
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/desktop_notification_controller.h"
|
|
||||||
|
#include "atom/browser/notifications/win/win32_desktop_notifications/desktop_notification_controller.h"
|
||||||
|
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/common.h"
|
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/toast.h"
|
#include "atom/browser/notifications/win/win32_desktop_notifications/common.h"
|
||||||
|
#include "atom/browser/notifications/win/win32_desktop_notifications/toast.h"
|
||||||
|
|
||||||
using std::make_shared;
|
using std::make_shared;
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
HBITMAP CopyBitmap(HBITMAP bitmap) {
|
HBITMAP CopyBitmap(HBITMAP bitmap) {
|
||||||
HBITMAP ret = NULL;
|
HBITMAP ret = NULL;
|
||||||
|
@ -78,7 +87,7 @@ DesktopNotificationController::DesktopNotificationController(
|
||||||
|
|
||||||
DesktopNotificationController::~DesktopNotificationController() {
|
DesktopNotificationController::~DesktopNotificationController() {
|
||||||
for (auto&& inst : instances_)
|
for (auto&& inst : instances_)
|
||||||
DestroyToast(inst);
|
DestroyToast(&inst);
|
||||||
if (hwnd_controller_)
|
if (hwnd_controller_)
|
||||||
DestroyWindow(hwnd_controller_);
|
DestroyWindow(hwnd_controller_);
|
||||||
ClearAssets();
|
ClearAssets();
|
||||||
|
@ -233,7 +242,7 @@ void DesktopNotificationController::AnimateAll() {
|
||||||
it = stable_partition(it, it2, is_alive);
|
it = stable_partition(it, it2, is_alive);
|
||||||
|
|
||||||
// purge the dead items
|
// purge the dead items
|
||||||
for_each(it, it2, [this](auto&& inst) { DestroyToast(inst); });
|
for_each(it, it2, [this](auto&& inst) { DestroyToast(&inst); });
|
||||||
|
|
||||||
if (it2 == instances_.end()) {
|
if (it2 == instances_.end()) {
|
||||||
instances_.erase(it, it2);
|
instances_.erase(it, it2);
|
||||||
|
@ -285,7 +294,7 @@ DesktopNotificationController::AddNotification(std::wstring caption,
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopNotificationController::CloseNotification(
|
void DesktopNotificationController::CloseNotification(
|
||||||
Notification& notification) {
|
const Notification& notification) {
|
||||||
// Remove it from the queue
|
// Remove it from the queue
|
||||||
auto it = find(queue_.begin(), queue_.end(), notification.data_);
|
auto it = find(queue_.begin(), queue_.end(), notification.data_);
|
||||||
if (it != queue_.end()) {
|
if (it != queue_.end()) {
|
||||||
|
@ -351,12 +360,12 @@ HWND DesktopNotificationController::GetToast(
|
||||||
return (it != instances_.cend()) ? it->hwnd : NULL;
|
return (it != instances_.cend()) ? it->hwnd : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DesktopNotificationController::DestroyToast(ToastInstance& inst) {
|
void DesktopNotificationController::DestroyToast(ToastInstance* inst) {
|
||||||
if (inst.hwnd) {
|
if (inst->hwnd) {
|
||||||
auto data = Toast::Get(inst.hwnd)->GetNotification();
|
auto data = Toast::Get(inst->hwnd)->GetNotification();
|
||||||
|
|
||||||
DestroyWindow(inst.hwnd);
|
DestroyWindow(inst->hwnd);
|
||||||
inst.hwnd = NULL;
|
inst->hwnd = NULL;
|
||||||
|
|
||||||
Notification notification(data);
|
Notification notification(data);
|
||||||
OnNotificationClosed(notification);
|
OnNotificationClosed(notification);
|
||||||
|
@ -427,4 +436,4 @@ DesktopNotificationController::NotificationLink::~NotificationLink() {
|
||||||
p->controller = nullptr;
|
p->controller = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -1,11 +1,17 @@
|
||||||
#pragma once
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_DESKTOP_NOTIFICATION_CONTROLLER_H_
|
||||||
|
#define ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_DESKTOP_NOTIFICATION_CONTROLLER_H_
|
||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
struct NotificationData;
|
struct NotificationData;
|
||||||
|
|
||||||
|
@ -18,13 +24,13 @@ class DesktopNotificationController {
|
||||||
Notification AddNotification(std::wstring caption,
|
Notification AddNotification(std::wstring caption,
|
||||||
std::wstring body_text,
|
std::wstring body_text,
|
||||||
HBITMAP image);
|
HBITMAP image);
|
||||||
void CloseNotification(Notification& notification);
|
void CloseNotification(const Notification& notification);
|
||||||
|
|
||||||
// Event handlers -- override to receive the events
|
// Event handlers -- override to receive the events
|
||||||
private:
|
private:
|
||||||
virtual void OnNotificationClosed(Notification& notification) {}
|
virtual void OnNotificationClosed(const Notification& notification) {}
|
||||||
virtual void OnNotificationClicked(Notification& notification) {}
|
virtual void OnNotificationClicked(const Notification& notification) {}
|
||||||
virtual void OnNotificationDismissed(Notification& notification) {}
|
virtual void OnNotificationDismissed(const Notification& notification) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static HINSTANCE RegisterWndClasses();
|
static HINSTANCE RegisterWndClasses();
|
||||||
|
@ -73,7 +79,7 @@ class DesktopNotificationController {
|
||||||
void CheckQueue();
|
void CheckQueue();
|
||||||
void CreateToast(NotificationLink&& data);
|
void CreateToast(NotificationLink&& data);
|
||||||
HWND GetToast(const NotificationData* data) const;
|
HWND GetToast(const NotificationData* data) const;
|
||||||
void DestroyToast(ToastInstance& inst);
|
void DestroyToast(ToastInstance* inst);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const TCHAR class_name_[];
|
static const TCHAR class_name_[];
|
||||||
|
@ -103,4 +109,6 @@ class DesktopNotificationController::Notification {
|
||||||
friend class DesktopNotificationController;
|
friend class DesktopNotificationController;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_DESKTOP_NOTIFICATION_CONTROLLER_H_
|
|
@ -1,7 +1,11 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef NOMINMAX
|
#ifndef NOMINMAX
|
||||||
#define NOMINMAX
|
#define NOMINMAX
|
||||||
#endif
|
#endif
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/toast.h"
|
#include "atom/browser/notifications/win/win32_desktop_notifications/toast.h"
|
||||||
|
|
||||||
#include <combaseapi.h>
|
#include <combaseapi.h>
|
||||||
|
|
||||||
|
@ -11,9 +15,9 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/win/win32_desktop_notifications/common.h"
|
||||||
|
#include "atom/browser/notifications/win/win32_desktop_notifications/toast_uia.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/common.h"
|
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/toast_uia.h"
|
|
||||||
|
|
||||||
#pragma comment(lib, "msimg32.lib")
|
#pragma comment(lib, "msimg32.lib")
|
||||||
#pragma comment(lib, "uxtheme.lib")
|
#pragma comment(lib, "uxtheme.lib")
|
||||||
|
@ -21,7 +25,7 @@
|
||||||
using std::min;
|
using std::min;
|
||||||
using std::shared_ptr;
|
using std::shared_ptr;
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
static COLORREF GetAccentColor() {
|
static COLORREF GetAccentColor() {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
@ -346,7 +350,7 @@ LRESULT DesktopNotificationController::Toast::WndProc(HWND hwnd,
|
||||||
|
|
||||||
HWND DesktopNotificationController::Toast::Create(
|
HWND DesktopNotificationController::Toast::Create(
|
||||||
HINSTANCE hinstance,
|
HINSTANCE hinstance,
|
||||||
shared_ptr<NotificationData>& data) {
|
shared_ptr<NotificationData> data) {
|
||||||
return CreateWindowEx(WS_EX_LAYERED | WS_EX_NOACTIVATE | WS_EX_TOPMOST,
|
return CreateWindowEx(WS_EX_LAYERED | WS_EX_NOACTIVATE | WS_EX_TOPMOST,
|
||||||
class_name_, nullptr, WS_POPUP, 0, 0, 0, 0, NULL, NULL,
|
class_name_, nullptr, WS_POPUP, 0, 0, 0, 0, NULL, NULL,
|
||||||
hinstance, &data);
|
hinstance, &data);
|
||||||
|
@ -851,4 +855,4 @@ float DesktopNotificationController::Toast::AnimateStackCollapse() {
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -1,13 +1,21 @@
|
||||||
#pragma once
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/desktop_notification_controller.h"
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
namespace brightray {
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_H_
|
||||||
|
#define ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/win/win32_desktop_notifications/desktop_notification_controller.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
class DesktopNotificationController::Toast {
|
class DesktopNotificationController::Toast {
|
||||||
public:
|
public:
|
||||||
static void Register(HINSTANCE hinstance);
|
static void Register(HINSTANCE hinstance);
|
||||||
static HWND Create(HINSTANCE hinstance,
|
static HWND Create(HINSTANCE hinstance,
|
||||||
std::shared_ptr<NotificationData>& data);
|
std::shared_ptr<NotificationData> data);
|
||||||
static Toast* Get(HWND hwnd) {
|
static Toast* Get(HWND hwnd) {
|
||||||
return reinterpret_cast<Toast*>(GetWindowLongPtr(hwnd, 0));
|
return reinterpret_cast<Toast*>(GetWindowLongPtr(hwnd, 0));
|
||||||
}
|
}
|
||||||
|
@ -92,4 +100,6 @@ class DesktopNotificationController::Toast {
|
||||||
float ease_in_pos_ = 0, ease_out_pos_ = 0, stack_collapse_pos_ = 0;
|
float ease_in_pos_ = 0, ease_out_pos_ = 0, stack_collapse_pos_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_H_
|
|
@ -1,10 +1,14 @@
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/toast_uia.h"
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/win/win32_desktop_notifications/toast_uia.h"
|
||||||
#include <UIAutomation.h>
|
#include <UIAutomation.h>
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/common.h"
|
#include "atom/browser/notifications/win/win32_desktop_notifications/common.h"
|
||||||
|
|
||||||
#pragma comment(lib, "uiautomationcore.lib")
|
#pragma comment(lib, "uiautomationcore.lib")
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
DesktopNotificationController::Toast::UIAutomationInterface::
|
DesktopNotificationController::Toast::UIAutomationInterface::
|
||||||
UIAutomationInterface(Toast* toast)
|
UIAutomationInterface(Toast* toast)
|
||||||
|
@ -247,4 +251,4 @@ HRESULT DesktopNotificationController::Toast::UIAutomationInterface::
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -1,13 +1,17 @@
|
||||||
#ifndef BRIGHTRAY_BROWSER_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_UIA_H_
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
#define BRIGHTRAY_BROWSER_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_UIA_H_
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/toast.h"
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_UIA_H_
|
||||||
|
#define ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_UIA_H_
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/win/win32_desktop_notifications/toast.h"
|
||||||
|
|
||||||
#include <combaseapi.h>
|
#include <combaseapi.h>
|
||||||
|
|
||||||
#include <UIAutomationCore.h>
|
#include <UIAutomationCore.h>
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
class DesktopNotificationController::Toast::UIAutomationInterface
|
class DesktopNotificationController::Toast::UIAutomationInterface
|
||||||
: public IRawElementProviderSimple,
|
: public IRawElementProviderSimple,
|
||||||
|
@ -75,6 +79,6 @@ class DesktopNotificationController::Toast::UIAutomationInterface
|
||||||
std::wstring text_;
|
std::wstring text_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_UIA_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_UIA_H_
|
|
@ -1,8 +1,12 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
#ifndef WIN32_LEAN_AND_MEAN
|
#ifndef WIN32_LEAN_AND_MEAN
|
||||||
#define WIN32_LEAN_AND_MEAN
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "brightray/browser/win/win32_notification.h"
|
#include "atom/browser/notifications/win/win32_notification.h"
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -11,7 +15,7 @@
|
||||||
|
|
||||||
#include "third_party/skia/include/core/SkBitmap.h"
|
#include "third_party/skia/include/core/SkBitmap.h"
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
void Win32Notification::Show(const NotificationOptions& options) {
|
void Win32Notification::Show(const NotificationOptions& options) {
|
||||||
auto* presenter = static_cast<NotificationPresenterWin7*>(this->presenter());
|
auto* presenter = static_cast<NotificationPresenterWin7*>(this->presenter());
|
||||||
|
@ -60,4 +64,4 @@ void Win32Notification::Dismiss() {
|
||||||
notification_ref_.Close();
|
notification_ref_.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
38
atom/browser/notifications/win/win32_notification.h
Normal file
38
atom/browser/notifications/win/win32_notification.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// Copyright (c) 2015 GitHub, Inc.
|
||||||
|
// Use of this source code is governed by the MIT license that can be
|
||||||
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_NOTIFICATION_H_
|
||||||
|
#define ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_NOTIFICATION_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/notification.h"
|
||||||
|
#include "atom/browser/notifications/win/notification_presenter_win7.h"
|
||||||
|
|
||||||
|
namespace atom {
|
||||||
|
|
||||||
|
class Win32Notification : public atom::Notification {
|
||||||
|
public:
|
||||||
|
Win32Notification(NotificationDelegate* delegate,
|
||||||
|
NotificationPresenterWin7* presenter)
|
||||||
|
: Notification(delegate, presenter) {}
|
||||||
|
void Show(const NotificationOptions& options) override;
|
||||||
|
void Dismiss() override;
|
||||||
|
|
||||||
|
const DesktopNotificationController::Notification& GetRef() const {
|
||||||
|
return notification_ref_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& GetTag() const { return tag_; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
DesktopNotificationController::Notification notification_ref_;
|
||||||
|
std::string tag_;
|
||||||
|
|
||||||
|
DISALLOW_COPY_AND_ASSIGN(Win32Notification);
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace atom
|
||||||
|
|
||||||
|
#endif // ATOM_BROWSER_NOTIFICATIONS_WIN_WIN32_NOTIFICATION_H_
|
|
@ -6,15 +6,15 @@
|
||||||
// this code
|
// this code
|
||||||
// and released it as MIT to the world.
|
// and released it as MIT to the world.
|
||||||
|
|
||||||
#include "brightray/browser/win/windows_toast_notification.h"
|
#include "atom/browser/notifications/win/windows_toast_notification.h"
|
||||||
|
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "atom/browser/notifications/notification_delegate.h"
|
||||||
|
#include "atom/browser/notifications/win/notification_presenter_win.h"
|
||||||
#include "base/environment.h"
|
#include "base/environment.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
#include "brightray/browser/notification_delegate.h"
|
|
||||||
#include "brightray/browser/win/notification_presenter_win.h"
|
|
||||||
#include "brightray/browser/win/scoped_hstring.h"
|
#include "brightray/browser/win/scoped_hstring.h"
|
||||||
#include "brightray/common/application_info.h"
|
#include "brightray/common/application_info.h"
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
|
@ -27,7 +27,7 @@ using ABI::Windows::Data::Xml::Dom::IXmlNode;
|
||||||
using ABI::Windows::Data::Xml::Dom::IXmlNodeList;
|
using ABI::Windows::Data::Xml::Dom::IXmlNodeList;
|
||||||
using ABI::Windows::Data::Xml::Dom::IXmlText;
|
using ABI::Windows::Data::Xml::Dom::IXmlText;
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -58,13 +58,13 @@ bool WindowsToastNotification::Initialize() {
|
||||||
&toast_manager_)))
|
&toast_manager_)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (IsRunningInDesktopBridge()) {
|
if (brightray::IsRunningInDesktopBridge()) {
|
||||||
// Ironically, the Desktop Bridge / UWP environment
|
// Ironically, the Desktop Bridge / UWP environment
|
||||||
// requires us to not give Windows an appUserModelId.
|
// requires us to not give Windows an appUserModelId.
|
||||||
return SUCCEEDED(toast_manager_->CreateToastNotifier(&toast_notifier_));
|
return SUCCEEDED(toast_manager_->CreateToastNotifier(&toast_notifier_));
|
||||||
} else {
|
} else {
|
||||||
ScopedHString app_id;
|
ScopedHString app_id;
|
||||||
if (!GetAppUserModelID(&app_id))
|
if (!brightray::GetAppUserModelID(&app_id))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return SUCCEEDED(
|
return SUCCEEDED(
|
||||||
|
@ -444,4 +444,4 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
|
@ -6,8 +6,8 @@
|
||||||
// this code
|
// this code
|
||||||
// and released it as MIT to the world.
|
// and released it as MIT to the world.
|
||||||
|
|
||||||
#ifndef BRIGHTRAY_BROWSER_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
||||||
#define BRIGHTRAY_BROWSER_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
#define ATOM_BROWSER_NOTIFICATIONS_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <windows.ui.notifications.h>
|
#include <windows.ui.notifications.h>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "brightray/browser/notification.h"
|
#include "atom/browser/notifications/notification.h"
|
||||||
|
|
||||||
using Microsoft::WRL::ClassicCom;
|
using Microsoft::WRL::ClassicCom;
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
|
@ -25,7 +25,7 @@ using Microsoft::WRL::RuntimeClassFlags;
|
||||||
|
|
||||||
class ScopedHString;
|
class ScopedHString;
|
||||||
|
|
||||||
namespace brightray {
|
namespace atom {
|
||||||
|
|
||||||
using DesktopToastActivatedEventHandler =
|
using DesktopToastActivatedEventHandler =
|
||||||
ABI::Windows::Foundation::ITypedEventHandler<
|
ABI::Windows::Foundation::ITypedEventHandler<
|
||||||
|
@ -126,6 +126,6 @@ class ToastEventHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>,
|
||||||
DISALLOW_COPY_AND_ASSIGN(ToastEventHandler);
|
DISALLOW_COPY_AND_ASSIGN(ToastEventHandler);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace brightray
|
} // namespace atom
|
||||||
|
|
||||||
#endif // BRIGHTRAY_BROWSER_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
#endif // ATOM_BROWSER_NOTIFICATIONS_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
|
@ -50,22 +50,10 @@ static_library("brightray") {
|
||||||
"browser/inspectable_web_contents_view_delegate.h",
|
"browser/inspectable_web_contents_view_delegate.h",
|
||||||
"browser/inspectable_web_contents_view_mac.h",
|
"browser/inspectable_web_contents_view_mac.h",
|
||||||
"browser/inspectable_web_contents_view_mac.mm",
|
"browser/inspectable_web_contents_view_mac.mm",
|
||||||
"browser/linux/libnotify_loader.cc",
|
|
||||||
"browser/linux/libnotify_loader.h",
|
|
||||||
"browser/linux/libnotify_notification.cc",
|
|
||||||
"browser/linux/libnotify_notification.h",
|
|
||||||
"browser/linux/notification_presenter_linux.cc",
|
|
||||||
"browser/linux/notification_presenter_linux.h",
|
|
||||||
"browser/mac/bry_inspectable_web_contents_view.h",
|
"browser/mac/bry_inspectable_web_contents_view.h",
|
||||||
"browser/mac/bry_inspectable_web_contents_view.mm",
|
"browser/mac/bry_inspectable_web_contents_view.mm",
|
||||||
"browser/mac/cocoa_notification.h",
|
|
||||||
"browser/mac/cocoa_notification.mm",
|
|
||||||
"browser/mac/event_dispatching_window.h",
|
"browser/mac/event_dispatching_window.h",
|
||||||
"browser/mac/event_dispatching_window.mm",
|
"browser/mac/event_dispatching_window.mm",
|
||||||
"browser/mac/notification_center_delegate.h",
|
|
||||||
"browser/mac/notification_center_delegate.mm",
|
|
||||||
"browser/mac/notification_presenter_mac.h",
|
|
||||||
"browser/mac/notification_presenter_mac.mm",
|
|
||||||
"browser/media/media_capture_devices_dispatcher.cc",
|
"browser/media/media_capture_devices_dispatcher.cc",
|
||||||
"browser/media/media_capture_devices_dispatcher.h",
|
"browser/media/media_capture_devices_dispatcher.h",
|
||||||
"browser/media/media_device_id_salt.cc",
|
"browser/media/media_device_id_salt.cc",
|
||||||
|
@ -74,36 +62,14 @@ static_library("brightray") {
|
||||||
"browser/media/media_stream_devices_controller.h",
|
"browser/media/media_stream_devices_controller.h",
|
||||||
"browser/net/require_ct_delegate.cc",
|
"browser/net/require_ct_delegate.cc",
|
||||||
"browser/net/require_ct_delegate.h",
|
"browser/net/require_ct_delegate.h",
|
||||||
"browser/notification.cc",
|
|
||||||
"browser/notification.h",
|
|
||||||
"browser/notification_delegate.h",
|
|
||||||
"browser/notification_presenter.cc",
|
|
||||||
"browser/notification_presenter.h",
|
|
||||||
"browser/platform_notification_service.cc",
|
|
||||||
"browser/platform_notification_service.h",
|
|
||||||
"browser/views/inspectable_web_contents_view_views.cc",
|
"browser/views/inspectable_web_contents_view_views.cc",
|
||||||
"browser/views/inspectable_web_contents_view_views.h",
|
"browser/views/inspectable_web_contents_view_views.h",
|
||||||
"browser/views/views_delegate.cc",
|
"browser/views/views_delegate.cc",
|
||||||
"browser/views/views_delegate.h",
|
"browser/views/views_delegate.h",
|
||||||
"browser/web_ui_controller_factory.cc",
|
"browser/web_ui_controller_factory.cc",
|
||||||
"browser/web_ui_controller_factory.h",
|
"browser/web_ui_controller_factory.h",
|
||||||
"browser/win/notification_presenter_win.cc",
|
|
||||||
"browser/win/notification_presenter_win.h",
|
|
||||||
"browser/win/notification_presenter_win7.cc",
|
|
||||||
"browser/win/notification_presenter_win7.h",
|
|
||||||
"browser/win/scoped_hstring.cc",
|
"browser/win/scoped_hstring.cc",
|
||||||
"browser/win/scoped_hstring.h",
|
"browser/win/scoped_hstring.h",
|
||||||
"browser/win/win32_desktop_notifications/common.h",
|
|
||||||
"browser/win/win32_desktop_notifications/desktop_notification_controller.cc",
|
|
||||||
"browser/win/win32_desktop_notifications/desktop_notification_controller.h",
|
|
||||||
"browser/win/win32_desktop_notifications/toast.cc",
|
|
||||||
"browser/win/win32_desktop_notifications/toast.h",
|
|
||||||
"browser/win/win32_desktop_notifications/toast_uia.cc",
|
|
||||||
"browser/win/win32_desktop_notifications/toast_uia.h",
|
|
||||||
"browser/win/win32_notification.cc",
|
|
||||||
"browser/win/win32_notification.h",
|
|
||||||
"browser/win/windows_toast_notification.cc",
|
|
||||||
"browser/win/windows_toast_notification.h",
|
|
||||||
"browser/zoom_level_delegate.cc",
|
"browser/zoom_level_delegate.cc",
|
||||||
"browser/zoom_level_delegate.h",
|
"browser/zoom_level_delegate.h",
|
||||||
"common/application_info.cc",
|
"common/application_info.cc",
|
||||||
|
|
|
@ -10,8 +10,6 @@
|
||||||
#include "brightray/browser/browser_main_parts.h"
|
#include "brightray/browser/browser_main_parts.h"
|
||||||
#include "brightray/browser/devtools_manager_delegate.h"
|
#include "brightray/browser/devtools_manager_delegate.h"
|
||||||
#include "brightray/browser/media/media_capture_devices_dispatcher.h"
|
#include "brightray/browser/media/media_capture_devices_dispatcher.h"
|
||||||
#include "brightray/browser/notification_presenter.h"
|
|
||||||
#include "brightray/browser/platform_notification_service.h"
|
|
||||||
#include "content/public/browser/browser_thread.h"
|
#include "content/public/browser/browser_thread.h"
|
||||||
#include "content/public/common/url_constants.h"
|
#include "content/public/common/url_constants.h"
|
||||||
|
|
||||||
|
@ -59,20 +57,6 @@ BrowserClient::BrowserClient() : browser_main_parts_(nullptr) {
|
||||||
|
|
||||||
BrowserClient::~BrowserClient() {}
|
BrowserClient::~BrowserClient() {}
|
||||||
|
|
||||||
void BrowserClient::WebNotificationAllowed(
|
|
||||||
int render_process_id,
|
|
||||||
const base::Callback<void(bool, bool)>& callback) {
|
|
||||||
callback.Run(false, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
NotificationPresenter* BrowserClient::GetNotificationPresenter() {
|
|
||||||
if (!notification_presenter_) {
|
|
||||||
// Create a new presenter if on OS X, Linux, or Windows 7+
|
|
||||||
notification_presenter_.reset(NotificationPresenter::Create());
|
|
||||||
}
|
|
||||||
return notification_presenter_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(
|
BrowserMainParts* BrowserClient::OverrideCreateBrowserMainParts(
|
||||||
const content::MainFunctionParams&) {
|
const content::MainFunctionParams&) {
|
||||||
return new BrowserMainParts;
|
return new BrowserMainParts;
|
||||||
|
@ -89,13 +73,6 @@ content::MediaObserver* BrowserClient::GetMediaObserver() {
|
||||||
return MediaCaptureDevicesDispatcher::GetInstance();
|
return MediaCaptureDevicesDispatcher::GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
content::PlatformNotificationService*
|
|
||||||
BrowserClient::GetPlatformNotificationService() {
|
|
||||||
if (!notification_service_)
|
|
||||||
notification_service_.reset(new PlatformNotificationService(this));
|
|
||||||
return notification_service_.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
void BrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
||||||
std::vector<std::string>* additional_schemes) {
|
std::vector<std::string>* additional_schemes) {
|
||||||
additional_schemes->push_back(content::kChromeDevToolsScheme);
|
additional_schemes->push_back(content::kChromeDevToolsScheme);
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
namespace brightray {
|
namespace brightray {
|
||||||
|
|
||||||
class BrowserMainParts;
|
class BrowserMainParts;
|
||||||
class NotificationPresenter;
|
|
||||||
class PlatformNotificationService;
|
|
||||||
|
|
||||||
class BrowserClient : public content::ContentBrowserClient {
|
class BrowserClient : public content::ContentBrowserClient {
|
||||||
public:
|
public:
|
||||||
|
@ -27,20 +25,11 @@ class BrowserClient : public content::ContentBrowserClient {
|
||||||
|
|
||||||
BrowserMainParts* browser_main_parts() { return browser_main_parts_; }
|
BrowserMainParts* browser_main_parts() { return browser_main_parts_; }
|
||||||
|
|
||||||
NotificationPresenter* GetNotificationPresenter();
|
|
||||||
|
|
||||||
// Subclasses should override this to enable or disable WebNotification.
|
|
||||||
virtual void WebNotificationAllowed(
|
|
||||||
int render_process_id,
|
|
||||||
const base::Callback<void(bool, bool)>& callback);
|
|
||||||
|
|
||||||
// Subclasses that override this (e.g., to provide their own protocol
|
// Subclasses that override this (e.g., to provide their own protocol
|
||||||
// handlers) should call this implementation after doing their own work.
|
// handlers) should call this implementation after doing their own work.
|
||||||
content::BrowserMainParts* CreateBrowserMainParts(
|
content::BrowserMainParts* CreateBrowserMainParts(
|
||||||
const content::MainFunctionParams&) override;
|
const content::MainFunctionParams&) override;
|
||||||
content::MediaObserver* GetMediaObserver() override;
|
content::MediaObserver* GetMediaObserver() override;
|
||||||
content::PlatformNotificationService* GetPlatformNotificationService()
|
|
||||||
override;
|
|
||||||
void GetAdditionalAllowedSchemesForFileSystem(
|
void GetAdditionalAllowedSchemesForFileSystem(
|
||||||
std::vector<std::string>* additional_schemes) override;
|
std::vector<std::string>* additional_schemes) override;
|
||||||
void GetAdditionalWebUISchemes(
|
void GetAdditionalWebUISchemes(
|
||||||
|
@ -59,9 +48,6 @@ class BrowserClient : public content::ContentBrowserClient {
|
||||||
private:
|
private:
|
||||||
BrowserMainParts* browser_main_parts_;
|
BrowserMainParts* browser_main_parts_;
|
||||||
|
|
||||||
std::unique_ptr<PlatformNotificationService> notification_service_;
|
|
||||||
std::unique_ptr<NotificationPresenter> notification_presenter_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
DISALLOW_COPY_AND_ASSIGN(BrowserClient);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
// Copyright (c) 2015 GitHub, Inc.
|
|
||||||
// Use of this source code is governed by the MIT license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#ifndef BROWSER_MAC_NOTIFICATION_DELEGATE_H_
|
|
||||||
#define BROWSER_MAC_NOTIFICATION_DELEGATE_H_
|
|
||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
|
||||||
|
|
||||||
namespace brightray {
|
|
||||||
class NotificationPresenterMac;
|
|
||||||
}
|
|
||||||
|
|
||||||
@interface NotificationCenterDelegate
|
|
||||||
: NSObject <NSUserNotificationCenterDelegate> {
|
|
||||||
@private
|
|
||||||
brightray::NotificationPresenterMac* presenter_;
|
|
||||||
}
|
|
||||||
- (instancetype)initWithPresenter:
|
|
||||||
(brightray::NotificationPresenterMac*)presenter;
|
|
||||||
@end
|
|
||||||
|
|
||||||
#endif // BROWSER_MAC_NOTIFICATION_DELEGATE_H_
|
|
|
@ -1,29 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include "brightray/browser/notification_presenter.h"
|
|
||||||
#include "brightray/browser/win/win32_desktop_notifications/desktop_notification_controller.h"
|
|
||||||
|
|
||||||
namespace brightray {
|
|
||||||
|
|
||||||
class Win32Notification;
|
|
||||||
|
|
||||||
class NotificationPresenterWin7 : public NotificationPresenter,
|
|
||||||
public DesktopNotificationController {
|
|
||||||
public:
|
|
||||||
NotificationPresenterWin7() = default;
|
|
||||||
|
|
||||||
Win32Notification* GetNotificationObjectByRef(
|
|
||||||
const DesktopNotificationController::Notification& ref);
|
|
||||||
|
|
||||||
Win32Notification* GetNotificationObjectByTag(const std::string& tag);
|
|
||||||
|
|
||||||
private:
|
|
||||||
brightray::Notification* CreateNotificationObject(
|
|
||||||
NotificationDelegate* delegate) override;
|
|
||||||
|
|
||||||
void OnNotificationClicked(Notification& notification) override;
|
|
||||||
void OnNotificationDismissed(Notification& notification) override;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(NotificationPresenterWin7);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brightray
|
|
|
@ -1,28 +0,0 @@
|
||||||
#pragma once
|
|
||||||
#include "brightray/browser/notification.h"
|
|
||||||
#include "brightray/browser/win/notification_presenter_win7.h"
|
|
||||||
|
|
||||||
namespace brightray {
|
|
||||||
|
|
||||||
class Win32Notification : public brightray::Notification {
|
|
||||||
public:
|
|
||||||
Win32Notification(NotificationDelegate* delegate,
|
|
||||||
NotificationPresenterWin7* presenter)
|
|
||||||
: Notification(delegate, presenter) {}
|
|
||||||
void Show(const NotificationOptions& options) override;
|
|
||||||
void Dismiss() override;
|
|
||||||
|
|
||||||
const DesktopNotificationController::Notification& GetRef() const {
|
|
||||||
return notification_ref_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& GetTag() const { return tag_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
DesktopNotificationController::Notification notification_ref_;
|
|
||||||
std::string tag_;
|
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Win32Notification);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace brightray
|
|
|
@ -321,6 +321,40 @@ filenames = {
|
||||||
"atom/browser/net/url_request_fetch_job.h",
|
"atom/browser/net/url_request_fetch_job.h",
|
||||||
"atom/browser/net/url_request_stream_job.cc",
|
"atom/browser/net/url_request_stream_job.cc",
|
||||||
"atom/browser/net/url_request_stream_job.h",
|
"atom/browser/net/url_request_stream_job.h",
|
||||||
|
"atom/browser/notifications/linux/libnotify_loader.cc",
|
||||||
|
"atom/browser/notifications/linux/libnotify_loader.h",
|
||||||
|
"atom/browser/notifications/linux/libnotify_notification.cc",
|
||||||
|
"atom/browser/notifications/linux/libnotify_notification.h",
|
||||||
|
"atom/browser/notifications/linux/notification_presenter_linux.cc",
|
||||||
|
"atom/browser/notifications/linux/notification_presenter_linux.h",
|
||||||
|
"atom/browser/notifications/mac/cocoa_notification.h",
|
||||||
|
"atom/browser/notifications/mac/cocoa_notification.mm",
|
||||||
|
"atom/browser/notifications/mac/notification_center_delegate.h",
|
||||||
|
"atom/browser/notifications/mac/notification_center_delegate.mm",
|
||||||
|
"atom/browser/notifications/mac/notification_presenter_mac.h",
|
||||||
|
"atom/browser/notifications/mac/notification_presenter_mac.mm",
|
||||||
|
"atom/browser/notifications/notification.cc",
|
||||||
|
"atom/browser/notifications/notification.h",
|
||||||
|
"atom/browser/notifications/notification_delegate.h",
|
||||||
|
"atom/browser/notifications/notification_presenter.cc",
|
||||||
|
"atom/browser/notifications/notification_presenter.h",
|
||||||
|
"atom/browser/notifications/platform_notification_service.cc",
|
||||||
|
"atom/browser/notifications/platform_notification_service.h",
|
||||||
|
"atom/browser/notifications/win/notification_presenter_win.cc",
|
||||||
|
"atom/browser/notifications/win/notification_presenter_win.h",
|
||||||
|
"atom/browser/notifications/win/notification_presenter_win7.cc",
|
||||||
|
"atom/browser/notifications/win/notification_presenter_win7.h",
|
||||||
|
"atom/browser/notifications/win/win32_desktop_notifications/common.h",
|
||||||
|
"atom/browser/notifications/win/win32_desktop_notifications/desktop_notification_controller.cc",
|
||||||
|
"atom/browser/notifications/win/win32_desktop_notifications/desktop_notification_controller.h",
|
||||||
|
"atom/browser/notifications/win/win32_desktop_notifications/toast.cc",
|
||||||
|
"atom/browser/notifications/win/win32_desktop_notifications/toast.h",
|
||||||
|
"atom/browser/notifications/win/win32_desktop_notifications/toast_uia.cc",
|
||||||
|
"atom/browser/notifications/win/win32_desktop_notifications/toast_uia.h",
|
||||||
|
"atom/browser/notifications/win/win32_notification.cc",
|
||||||
|
"atom/browser/notifications/win/win32_notification.h",
|
||||||
|
"atom/browser/notifications/win/windows_toast_notification.cc",
|
||||||
|
"atom/browser/notifications/win/windows_toast_notification.h",
|
||||||
"atom/browser/node_debugger.cc",
|
"atom/browser/node_debugger.cc",
|
||||||
"atom/browser/node_debugger.h",
|
"atom/browser/node_debugger.h",
|
||||||
"atom/browser/pref_store_delegate.cc",
|
"atom/browser/pref_store_delegate.cc",
|
||||||
|
|
|
@ -13,6 +13,7 @@ const BLACKLIST = new Set([
|
||||||
['atom', 'browser', 'mac', 'atom_application.h'],
|
['atom', 'browser', 'mac', 'atom_application.h'],
|
||||||
['atom', 'browser', 'mac', 'atom_application_delegate.h'],
|
['atom', 'browser', 'mac', 'atom_application_delegate.h'],
|
||||||
['atom', 'browser', 'resources', 'win', 'resource.h'],
|
['atom', 'browser', 'resources', 'win', 'resource.h'],
|
||||||
|
['atom', 'browser', 'notifications', 'mac', 'notification_center_delegate.h'],
|
||||||
['atom', 'browser', 'ui', 'cocoa', 'atom_menu_controller.h'],
|
['atom', 'browser', 'ui', 'cocoa', 'atom_menu_controller.h'],
|
||||||
['atom', 'browser', 'ui', 'cocoa', 'atom_ns_window.h'],
|
['atom', 'browser', 'ui', 'cocoa', 'atom_ns_window.h'],
|
||||||
['atom', 'browser', 'ui', 'cocoa', 'atom_ns_window_delegate.h'],
|
['atom', 'browser', 'ui', 'cocoa', 'atom_ns_window_delegate.h'],
|
||||||
|
@ -28,15 +29,6 @@ const BLACKLIST = new Set([
|
||||||
['atom', 'node', 'osfhandle.cc'],
|
['atom', 'node', 'osfhandle.cc'],
|
||||||
['brightray', 'browser', 'mac', 'bry_inspectable_web_contents_view.h'],
|
['brightray', 'browser', 'mac', 'bry_inspectable_web_contents_view.h'],
|
||||||
['brightray', 'browser', 'mac', 'event_dispatching_window.h'],
|
['brightray', 'browser', 'mac', 'event_dispatching_window.h'],
|
||||||
['brightray', 'browser', 'mac', 'notification_center_delegate.h'],
|
|
||||||
['brightray', 'browser', 'win', 'notification_presenter_win7.h'],
|
|
||||||
['brightray', 'browser', 'win', 'win32_desktop_notifications', 'common.h'],
|
|
||||||
['brightray', 'browser', 'win', 'win32_desktop_notifications',
|
|
||||||
'desktop_notification_controller.cc'],
|
|
||||||
['brightray', 'browser', 'win', 'win32_desktop_notifications',
|
|
||||||
'desktop_notification_controller.h'],
|
|
||||||
['brightray', 'browser', 'win', 'win32_desktop_notifications', 'toast.h'],
|
|
||||||
['brightray', 'browser', 'win', 'win32_notification.h'],
|
|
||||||
['spec', 'static', 'jquery-2.0.3.min.js']
|
['spec', 'static', 'jquery-2.0.3.min.js']
|
||||||
].map(tokens => path.join(SOURCE_ROOT, ...tokens)))
|
].map(tokens => path.join(SOURCE_ROOT, ...tokens)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue