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_menu.h"
|
||||
#include "atom/browser/atom_browser_client.h"
|
||||
#include "atom/browser/browser.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/string16_converter.h"
|
||||
#include "base/guid.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brightray/browser/browser_client.h"
|
||||
#include "native_mate/constructor.h"
|
||||
#include "native_mate/dictionary.h"
|
||||
#include "native_mate/object_template_builder.h"
|
||||
|
@ -22,10 +22,10 @@
|
|||
|
||||
namespace mate {
|
||||
template <>
|
||||
struct Converter<brightray::NotificationAction> {
|
||||
struct Converter<atom::NotificationAction> {
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
brightray::NotificationAction* out) {
|
||||
atom::NotificationAction* out) {
|
||||
mate::Dictionary dict;
|
||||
if (!ConvertFromV8(isolate, val, &dict))
|
||||
return false;
|
||||
|
@ -38,7 +38,7 @@ struct Converter<brightray::NotificationAction> {
|
|||
}
|
||||
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
brightray::NotificationAction val) {
|
||||
atom::NotificationAction val) {
|
||||
mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate);
|
||||
dict.Set("text", val.text);
|
||||
dict.Set("type", val.type);
|
||||
|
@ -56,7 +56,8 @@ Notification::Notification(v8::Isolate* isolate,
|
|||
mate::Arguments* args) {
|
||||
InitWith(isolate, wrapper);
|
||||
|
||||
presenter_ = brightray::BrowserClient::Get()->GetNotificationPresenter();
|
||||
presenter_ = static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||
->GetNotificationPresenter();
|
||||
|
||||
mate::Dictionary opts;
|
||||
if (args->GetNext(&opts)) {
|
||||
|
@ -119,7 +120,7 @@ base::string16 Notification::GetSound() const {
|
|||
return sound_;
|
||||
}
|
||||
|
||||
std::vector<brightray::NotificationAction> Notification::GetActions() const {
|
||||
std::vector<atom::NotificationAction> Notification::GetActions() const {
|
||||
return actions_;
|
||||
}
|
||||
|
||||
|
@ -157,7 +158,7 @@ void Notification::SetSound(const base::string16& new_sound) {
|
|||
}
|
||||
|
||||
void Notification::SetActions(
|
||||
const std::vector<brightray::NotificationAction>& actions) {
|
||||
const std::vector<atom::NotificationAction>& actions) {
|
||||
actions_ = actions;
|
||||
}
|
||||
|
||||
|
@ -200,7 +201,7 @@ void Notification::Show() {
|
|||
if (presenter_) {
|
||||
notification_ = presenter_->CreateNotification(this, base::GenerateGUID());
|
||||
if (notification_) {
|
||||
brightray::NotificationOptions options;
|
||||
atom::NotificationOptions options;
|
||||
options.title = title_;
|
||||
options.subtitle = subtitle_;
|
||||
options.msg = body_;
|
||||
|
@ -218,7 +219,8 @@ void Notification::Show() {
|
|||
}
|
||||
|
||||
bool Notification::IsSupported() {
|
||||
return !!brightray::BrowserClient::Get()->GetNotificationPresenter();
|
||||
return !!static_cast<AtomBrowserClient*>(AtomBrowserClient::Get())
|
||||
->GetNotificationPresenter();
|
||||
}
|
||||
|
||||
// static
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
#include <vector>
|
||||
|
||||
#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 "brightray/browser/notification.h"
|
||||
#include "brightray/browser/notification_delegate.h"
|
||||
#include "brightray/browser/notification_presenter.h"
|
||||
#include "native_mate/handle.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace atom {
|
|||
namespace api {
|
||||
|
||||
class Notification : public mate::TrackableObject<Notification>,
|
||||
public brightray::NotificationDelegate {
|
||||
public NotificationDelegate {
|
||||
public:
|
||||
static mate::WrappableBase* New(mate::Arguments* args);
|
||||
static bool IsSupported();
|
||||
|
@ -55,7 +55,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
bool GetHasReply() const;
|
||||
base::string16 GetReplyPlaceholder() const;
|
||||
base::string16 GetSound() const;
|
||||
std::vector<brightray::NotificationAction> GetActions() const;
|
||||
std::vector<atom::NotificationAction> GetActions() const;
|
||||
base::string16 GetCloseButtonText() const;
|
||||
|
||||
// Prop Setters
|
||||
|
@ -66,7 +66,7 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
void SetHasReply(bool new_has_reply);
|
||||
void SetReplyPlaceholder(const base::string16& new_reply_placeholder);
|
||||
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);
|
||||
|
||||
private:
|
||||
|
@ -80,12 +80,12 @@ class Notification : public mate::TrackableObject<Notification>,
|
|||
bool has_reply_ = false;
|
||||
base::string16 reply_placeholder_;
|
||||
base::string16 sound_;
|
||||
std::vector<brightray::NotificationAction> actions_;
|
||||
std::vector<atom::NotificationAction> actions_;
|
||||
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);
|
||||
};
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
#include "atom/browser/child_web_contents_tracker.h"
|
||||
#include "atom/browser/io_thread.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/web_contents_permission_helper.h"
|
||||
#include "atom/browser/web_contents_preferences.h"
|
||||
|
@ -675,4 +677,19 @@ AtomBrowserClient::CreateThrottlesForNavigation(
|
|||
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
|
||||
|
|
|
@ -27,6 +27,8 @@ class SSLCertRequestInfo;
|
|||
namespace atom {
|
||||
|
||||
class AtomResourceDispatcherHostDelegate;
|
||||
class NotificationPresenter;
|
||||
class PlatformNotificationService;
|
||||
|
||||
class AtomBrowserClient : public brightray::BrowserClient,
|
||||
public content::RenderProcessHostObserver {
|
||||
|
@ -47,6 +49,12 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
|||
static void SetCustomServiceWorkerSchemes(
|
||||
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>>
|
||||
CreateThrottlesForNavigation(content::NavigationHandle* handle) override;
|
||||
|
||||
|
@ -117,13 +125,12 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
|||
std::unique_ptr<base::Value> GetServiceManifestOverlay(
|
||||
base::StringPiece name) override;
|
||||
net::NetLog* GetNetLog() override;
|
||||
content::PlatformNotificationService* GetPlatformNotificationService()
|
||||
override;
|
||||
|
||||
// brightray::BrowserClient:
|
||||
brightray::BrowserMainParts* OverrideCreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) override;
|
||||
void WebNotificationAllowed(
|
||||
int render_process_id,
|
||||
const base::Callback<void(bool, bool)>& callback) override;
|
||||
|
||||
// content::RenderProcessHostObserver:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
|
@ -170,6 +177,9 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
|||
std::unique_ptr<AtomResourceDispatcherHostDelegate>
|
||||
resource_dispatcher_host_delegate_;
|
||||
|
||||
std::unique_ptr<PlatformNotificationService> notification_service_;
|
||||
std::unique_ptr<NotificationPresenter> notification_presenter_;
|
||||
|
||||
Delegate* delegate_ = nullptr;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(AtomBrowserClient);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
// This is generated file. Do not modify directly.
|
||||
// Path to the code generator:
|
||||
// tools/generate_library_loader/generate_library_loader.py .
|
||||
// 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 "brightray/browser/linux/libnotify_loader.h"
|
||||
#include "atom/browser/notifications/linux/libnotify_loader.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
// This is generated file. Do not modify directly.
|
||||
// Path to the code generator:
|
||||
// tools/generate_library_loader/generate_library_loader.py .
|
||||
// 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 BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_LOADER_H_
|
||||
#define BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_LOADER_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_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 <string>
|
||||
|
@ -43,4 +46,4 @@ class 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "brightray/browser/linux/libnotify_notification.h"
|
||||
#include "atom/browser/notifications/linux/libnotify_notification.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/notifications/notification_delegate.h"
|
||||
#include "base/files/file_enumerator.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "brightray/browser/notification_delegate.h"
|
||||
#include "brightray/common/application_info.h"
|
||||
#include "brightray/common/platform_util.h"
|
||||
#include "chrome/browser/ui/libgtkui/gtk_util.h"
|
||||
#include "chrome/browser/ui/libgtkui/skia_utils_gtk.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -66,7 +66,7 @@ bool LibnotifyNotification::Initialize() {
|
|||
return false;
|
||||
}
|
||||
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";
|
||||
return false;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void LibnotifyNotification::Show(const NotificationOptions& options) {
|
|||
// Send the desktop name to identify the application
|
||||
// The desktop-entry is the part before the .desktop
|
||||
std::string desktop_id;
|
||||
if (platform_util::GetDesktopName(&desktop_id)) {
|
||||
if (brightray::platform_util::GetDesktopName(&desktop_id)) {
|
||||
const std::string suffix{".desktop"};
|
||||
if (base::EndsWith(desktop_id, suffix,
|
||||
base::CompareCase::INSENSITIVE_ASCII)) {
|
||||
|
@ -173,4 +173,4 @@ void LibnotifyNotification::OnNotificationView(NotifyNotification* notification,
|
|||
NotificationClicked();
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace atom
|
|
@ -2,17 +2,17 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
||||
#define BRIGHTRAY_BROWSER_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "brightray/browser/linux/libnotify_loader.h"
|
||||
#include "brightray/browser/notification.h"
|
||||
#include "atom/browser/notifications/linux/libnotify_loader.h"
|
||||
#include "atom/browser/notifications/notification.h"
|
||||
#include "ui/base/glib/glib_signal.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class LibnotifyNotification : public Notification {
|
||||
public:
|
||||
|
@ -42,6 +42,6 @@ class LibnotifyNotification : public Notification {
|
|||
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
|
||||
// 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
|
||||
NotificationPresenter* NotificationPresenter::Create() {
|
||||
|
@ -25,4 +25,4 @@ Notification* NotificationPresenterLinux::CreateNotificationObject(
|
|||
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
|
||||
// found in the LICENSE-CHROMIUM file.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_LINUX_NOTIFICATION_PRESENTER_LINUX_H_
|
||||
#define BRIGHTRAY_BROWSER_LINUX_NOTIFICATION_PRESENTER_LINUX_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_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 {
|
||||
public:
|
||||
|
@ -22,6 +22,6 @@ class NotificationPresenterLinux : public NotificationPresenter {
|
|||
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
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
|
||||
#define BRIGHTRAY_BROWSER_MAC_COCOA_NOTIFICATION_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_MAC_COCOA_NOTIFICATION_H_
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
|
@ -11,10 +11,10 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "atom/browser/notifications/notification.h"
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "brightray/browser/notification.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class CocoaNotification : public Notification {
|
||||
public:
|
||||
|
@ -45,6 +45,6 @@ class CocoaNotification : public Notification {
|
|||
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
|
||||
// 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/strings/sys_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"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
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
|
||||
// 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 "brightray/browser/mac/notification_presenter_mac.h"
|
||||
#include "atom/browser/notifications/mac/cocoa_notification.h"
|
||||
#include "atom/browser/notifications/mac/notification_presenter_mac.h"
|
||||
|
||||
@implementation NotificationCenterDelegate
|
||||
|
||||
- (instancetype)initWithPresenter:
|
||||
(brightray::NotificationPresenterMac*)presenter {
|
||||
- (instancetype)initWithPresenter:(atom::NotificationPresenterMac*)presenter {
|
||||
self = [super init];
|
||||
if (!self)
|
||||
return nil;
|
|
@ -3,14 +3,14 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE-CHROMIUM file.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_MAC_NOTIFICATION_PRESENTER_MAC_H_
|
||||
#define BRIGHTRAY_BROWSER_MAC_NOTIFICATION_PRESENTER_MAC_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_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 "brightray/browser/mac/notification_center_delegate.h"
|
||||
#include "brightray/browser/notification_presenter.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class CocoaNotification;
|
||||
|
||||
|
@ -31,6 +31,6 @@ class NotificationPresenterMac : public NotificationPresenter {
|
|||
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
|
||||
// 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 "brightray/browser/mac/notification_center_delegate.h"
|
||||
#include "atom/browser/notifications/mac/cocoa_notification.h"
|
||||
#include "atom/browser/notifications/mac/notification_center_delegate.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
// static
|
||||
NotificationPresenter* NotificationPresenter::Create() {
|
||||
|
@ -47,4 +47,4 @@ Notification* NotificationPresenterMac::CreateNotificationObject(
|
|||
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
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "brightray/browser/notification.h"
|
||||
#include "atom/browser/notifications/notification.h"
|
||||
|
||||
#include "brightray/browser/notification_delegate.h"
|
||||
#include "brightray/browser/notification_presenter.h"
|
||||
#include "atom/browser/notifications/notification_delegate.h"
|
||||
#include "atom/browser/notifications/notification_presenter.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
NotificationOptions::NotificationOptions() = default;
|
||||
NotificationOptions::~NotificationOptions() = default;
|
||||
|
@ -43,4 +43,4 @@ void Notification::Destroy() {
|
|||
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
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_H_
|
||||
#define BRIGHTRAY_BROWSER_NOTIFICATION_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -13,7 +13,7 @@
|
|||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class NotificationDelegate;
|
||||
class NotificationPresenter;
|
||||
|
@ -84,6 +84,6 @@ class 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_DELEGATE_H_
|
||||
#define BRIGHTRAY_BROWSER_NOTIFICATION_DELEGATE_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_DELEGATE_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class NotificationDelegate {
|
||||
public:
|
||||
|
@ -30,6 +30,6 @@ class NotificationDelegate {
|
|||
~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
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "brightray/browser/notification_presenter.h"
|
||||
#include "atom/browser/notifications/notification_presenter.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "brightray/browser/notification.h"
|
||||
#include "atom/browser/notifications/notification.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
NotificationPresenter::NotificationPresenter() {}
|
||||
|
||||
|
@ -41,4 +41,4 @@ void NotificationPresenter::CloseNotificationWithId(
|
|||
(*it)->Dismiss();
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace atom
|
|
@ -2,15 +2,15 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_H_
|
||||
#define BRIGHTRAY_BROWSER_NOTIFICATION_PRESENTER_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_PRESENTER_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_NOTIFICATION_PRESENTER_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class Notification;
|
||||
class NotificationDelegate;
|
||||
|
@ -43,6 +43,6 @@ class 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
|
||||
// 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 "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/render_process_host.h"
|
||||
#include "content/public/common/notification_resources.h"
|
||||
#include "content/public/common/platform_notification_data.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -27,7 +27,7 @@ void OnWebNotificationAllowed(base::WeakPtr<Notification> notification,
|
|||
if (!notification)
|
||||
return;
|
||||
if (allowed) {
|
||||
brightray::NotificationOptions options;
|
||||
atom::NotificationOptions options;
|
||||
options.title = data.title;
|
||||
options.msg = data.body;
|
||||
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:
|
||||
explicit NotificationDelegateImpl(const std::string& notification_id)
|
||||
: notification_id_(notification_id) {}
|
||||
|
@ -72,7 +72,7 @@ class NotificationDelegateImpl final : public brightray::NotificationDelegate {
|
|||
} // namespace
|
||||
|
||||
PlatformNotificationService::PlatformNotificationService(
|
||||
BrowserClient* browser_client)
|
||||
AtomBrowserClient* browser_client)
|
||||
: browser_client_(browser_client) {}
|
||||
|
||||
PlatformNotificationService::~PlatformNotificationService() {}
|
||||
|
@ -130,4 +130,4 @@ int64_t PlatformNotificationService::ReadNextPersistentNotificationId(
|
|||
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
|
||||
// found in the LICENSE-CHROMIUM file.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_
|
||||
#define BRIGHTRAY_BROWSER_PLATFORM_NOTIFICATION_SERVICE_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_PLATFORM_NOTIFICATION_SERVICE_H_
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
@ -11,14 +11,14 @@
|
|||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/platform_notification_service.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class BrowserClient;
|
||||
class AtomBrowserClient;
|
||||
|
||||
class PlatformNotificationService
|
||||
: public content::PlatformNotificationService {
|
||||
public:
|
||||
explicit PlatformNotificationService(BrowserClient* browser_client);
|
||||
explicit PlatformNotificationService(AtomBrowserClient* browser_client);
|
||||
~PlatformNotificationService() override;
|
||||
|
||||
protected:
|
||||
|
@ -48,11 +48,11 @@ class PlatformNotificationService
|
|||
content::BrowserContext* browser_context) override;
|
||||
|
||||
private:
|
||||
BrowserClient* browser_client_;
|
||||
AtomBrowserClient* browser_client_;
|
||||
|
||||
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
|
||||
// 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 <string>
|
||||
#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/files/file_util.h"
|
||||
#include "base/md5.h"
|
||||
|
@ -17,15 +19,13 @@
|
|||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/time/time.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 "third_party/skia/include/core/SkBitmap.h"
|
||||
#include "ui/gfx/codec/png_codec.h"
|
||||
|
||||
#pragma comment(lib, "runtimeobject.lib")
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -98,4 +98,4 @@ Notification* NotificationPresenterWin::CreateNotificationObject(
|
|||
return new WindowsToastNotification(delegate, this);
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace atom
|
|
@ -20,17 +20,17 @@
|
|||
// console.log("Notification dismissed")
|
||||
// };
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_WIN_NOTIFICATION_PRESENTER_WIN_H_
|
||||
#define BRIGHTRAY_BROWSER_WIN_NOTIFICATION_PRESENTER_WIN_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_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/strings/string16.h"
|
||||
#include "brightray/browser/notification_presenter.h"
|
||||
|
||||
class GURL;
|
||||
class SkBitmap;
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class NotificationPresenterWin : public NotificationPresenter {
|
||||
public:
|
||||
|
@ -50,6 +50,6 @@ class NotificationPresenterWin : public NotificationPresenter {
|
|||
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 "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) {
|
||||
return new Win32Notification(delegate, this);
|
||||
}
|
||||
|
@ -34,17 +38,17 @@ Win32Notification* NotificationPresenterWin7::GetNotificationObjectByTag(
|
|||
}
|
||||
|
||||
void NotificationPresenterWin7::OnNotificationClicked(
|
||||
Notification& notification) {
|
||||
const Notification& notification) {
|
||||
auto* n = GetNotificationObjectByRef(notification);
|
||||
if (n)
|
||||
n->NotificationClicked();
|
||||
}
|
||||
|
||||
void NotificationPresenterWin7::OnNotificationDismissed(
|
||||
Notification& notification) {
|
||||
const Notification& notification) {
|
||||
auto* n = GetNotificationObjectByRef(notification);
|
||||
if (n)
|
||||
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>
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
struct NotificationData {
|
||||
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
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#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 <algorithm>
|
||||
#include <utility>
|
||||
#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::shared_ptr;
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
HBITMAP CopyBitmap(HBITMAP bitmap) {
|
||||
HBITMAP ret = NULL;
|
||||
|
@ -78,7 +87,7 @@ DesktopNotificationController::DesktopNotificationController(
|
|||
|
||||
DesktopNotificationController::~DesktopNotificationController() {
|
||||
for (auto&& inst : instances_)
|
||||
DestroyToast(inst);
|
||||
DestroyToast(&inst);
|
||||
if (hwnd_controller_)
|
||||
DestroyWindow(hwnd_controller_);
|
||||
ClearAssets();
|
||||
|
@ -233,7 +242,7 @@ void DesktopNotificationController::AnimateAll() {
|
|||
it = stable_partition(it, it2, is_alive);
|
||||
|
||||
// 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()) {
|
||||
instances_.erase(it, it2);
|
||||
|
@ -285,7 +294,7 @@ DesktopNotificationController::AddNotification(std::wstring caption,
|
|||
}
|
||||
|
||||
void DesktopNotificationController::CloseNotification(
|
||||
Notification& notification) {
|
||||
const Notification& notification) {
|
||||
// Remove it from the queue
|
||||
auto it = find(queue_.begin(), queue_.end(), notification.data_);
|
||||
if (it != queue_.end()) {
|
||||
|
@ -351,12 +360,12 @@ HWND DesktopNotificationController::GetToast(
|
|||
return (it != instances_.cend()) ? it->hwnd : NULL;
|
||||
}
|
||||
|
||||
void DesktopNotificationController::DestroyToast(ToastInstance& inst) {
|
||||
if (inst.hwnd) {
|
||||
auto data = Toast::Get(inst.hwnd)->GetNotification();
|
||||
void DesktopNotificationController::DestroyToast(ToastInstance* inst) {
|
||||
if (inst->hwnd) {
|
||||
auto data = Toast::Get(inst->hwnd)->GetNotification();
|
||||
|
||||
DestroyWindow(inst.hwnd);
|
||||
inst.hwnd = NULL;
|
||||
DestroyWindow(inst->hwnd);
|
||||
inst->hwnd = NULL;
|
||||
|
||||
Notification notification(data);
|
||||
OnNotificationClosed(notification);
|
||||
|
@ -427,4 +436,4 @@ DesktopNotificationController::NotificationLink::~NotificationLink() {
|
|||
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 <deque>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
struct NotificationData;
|
||||
|
||||
|
@ -18,13 +24,13 @@ class DesktopNotificationController {
|
|||
Notification AddNotification(std::wstring caption,
|
||||
std::wstring body_text,
|
||||
HBITMAP image);
|
||||
void CloseNotification(Notification& notification);
|
||||
void CloseNotification(const Notification& notification);
|
||||
|
||||
// Event handlers -- override to receive the events
|
||||
private:
|
||||
virtual void OnNotificationClosed(Notification& notification) {}
|
||||
virtual void OnNotificationClicked(Notification& notification) {}
|
||||
virtual void OnNotificationDismissed(Notification& notification) {}
|
||||
virtual void OnNotificationClosed(const Notification& notification) {}
|
||||
virtual void OnNotificationClicked(const Notification& notification) {}
|
||||
virtual void OnNotificationDismissed(const Notification& notification) {}
|
||||
|
||||
private:
|
||||
static HINSTANCE RegisterWndClasses();
|
||||
|
@ -73,7 +79,7 @@ class DesktopNotificationController {
|
|||
void CheckQueue();
|
||||
void CreateToast(NotificationLink&& data);
|
||||
HWND GetToast(const NotificationData* data) const;
|
||||
void DestroyToast(ToastInstance& inst);
|
||||
void DestroyToast(ToastInstance* inst);
|
||||
|
||||
private:
|
||||
static const TCHAR class_name_[];
|
||||
|
@ -103,4 +109,6 @@ class DesktopNotificationController::Notification {
|
|||
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
|
||||
#define NOMINMAX
|
||||
#endif
|
||||
#include "brightray/browser/win/win32_desktop_notifications/toast.h"
|
||||
#include "atom/browser/notifications/win/win32_desktop_notifications/toast.h"
|
||||
|
||||
#include <combaseapi.h>
|
||||
|
||||
|
@ -11,9 +15,9 @@
|
|||
#include <algorithm>
|
||||
#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 "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, "uxtheme.lib")
|
||||
|
@ -21,7 +25,7 @@
|
|||
using std::min;
|
||||
using std::shared_ptr;
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
static COLORREF GetAccentColor() {
|
||||
bool success = false;
|
||||
|
@ -346,7 +350,7 @@ LRESULT DesktopNotificationController::Toast::WndProc(HWND hwnd,
|
|||
|
||||
HWND DesktopNotificationController::Toast::Create(
|
||||
HINSTANCE hinstance,
|
||||
shared_ptr<NotificationData>& data) {
|
||||
shared_ptr<NotificationData> data) {
|
||||
return CreateWindowEx(WS_EX_LAYERED | WS_EX_NOACTIVATE | WS_EX_TOPMOST,
|
||||
class_name_, nullptr, WS_POPUP, 0, 0, 0, 0, NULL, NULL,
|
||||
hinstance, &data);
|
||||
|
@ -851,4 +855,4 @@ float DesktopNotificationController::Toast::AnimateStackCollapse() {
|
|||
return pos;
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace atom
|
|
@ -1,13 +1,21 @@
|
|||
#pragma once
|
||||
#include "brightray/browser/win/win32_desktop_notifications/desktop_notification_controller.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.
|
||||
|
||||
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 {
|
||||
public:
|
||||
static void Register(HINSTANCE hinstance);
|
||||
static HWND Create(HINSTANCE hinstance,
|
||||
std::shared_ptr<NotificationData>& data);
|
||||
std::shared_ptr<NotificationData> data);
|
||||
static Toast* Get(HWND hwnd) {
|
||||
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;
|
||||
};
|
||||
|
||||
} // 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 "brightray/browser/win/win32_desktop_notifications/common.h"
|
||||
#include "atom/browser/notifications/win/win32_desktop_notifications/common.h"
|
||||
|
||||
#pragma comment(lib, "uiautomationcore.lib")
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
DesktopNotificationController::Toast::UIAutomationInterface::
|
||||
UIAutomationInterface(Toast* toast)
|
||||
|
@ -247,4 +251,4 @@ HRESULT DesktopNotificationController::Toast::UIAutomationInterface::
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace atom
|
|
@ -1,13 +1,17 @@
|
|||
#ifndef BRIGHTRAY_BROWSER_WIN_WIN32_DESKTOP_NOTIFICATIONS_TOAST_UIA_H_
|
||||
#define 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 "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 <UIAutomationCore.h>
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
class DesktopNotificationController::Toast::UIAutomationInterface
|
||||
: public IRawElementProviderSimple,
|
||||
|
@ -75,6 +79,6 @@ class DesktopNotificationController::Toast::UIAutomationInterface
|
|||
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
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include "brightray/browser/win/win32_notification.h"
|
||||
#include "atom/browser/notifications/win/win32_notification.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
|
@ -11,7 +15,7 @@
|
|||
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
void Win32Notification::Show(const NotificationOptions& options) {
|
||||
auto* presenter = static_cast<NotificationPresenterWin7*>(this->presenter());
|
||||
|
@ -60,4 +64,4 @@ void Win32Notification::Dismiss() {
|
|||
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
|
||||
// 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 <vector>
|
||||
|
||||
#include "atom/browser/notifications/notification_delegate.h"
|
||||
#include "atom/browser/notifications/win/notification_presenter_win.h"
|
||||
#include "base/environment.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/common/application_info.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::IXmlText;
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -58,13 +58,13 @@ bool WindowsToastNotification::Initialize() {
|
|||
&toast_manager_)))
|
||||
return false;
|
||||
|
||||
if (IsRunningInDesktopBridge()) {
|
||||
if (brightray::IsRunningInDesktopBridge()) {
|
||||
// Ironically, the Desktop Bridge / UWP environment
|
||||
// requires us to not give Windows an appUserModelId.
|
||||
return SUCCEEDED(toast_manager_->CreateToastNotifier(&toast_notifier_));
|
||||
} else {
|
||||
ScopedHString app_id;
|
||||
if (!GetAppUserModelID(&app_id))
|
||||
if (!brightray::GetAppUserModelID(&app_id))
|
||||
return false;
|
||||
|
||||
return SUCCEEDED(
|
||||
|
@ -444,4 +444,4 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
|
|||
return S_OK;
|
||||
}
|
||||
|
||||
} // namespace brightray
|
||||
} // namespace atom
|
|
@ -6,8 +6,8 @@
|
|||
// this code
|
||||
// and released it as MIT to the world.
|
||||
|
||||
#ifndef BRIGHTRAY_BROWSER_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
||||
#define BRIGHTRAY_BROWSER_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
||||
#ifndef ATOM_BROWSER_NOTIFICATIONS_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
||||
#define ATOM_BROWSER_NOTIFICATIONS_WIN_WINDOWS_TOAST_NOTIFICATION_H_
|
||||
|
||||
#include <windows.h>
|
||||
#include <windows.ui.notifications.h>
|
||||
|
@ -15,7 +15,7 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "brightray/browser/notification.h"
|
||||
#include "atom/browser/notifications/notification.h"
|
||||
|
||||
using Microsoft::WRL::ClassicCom;
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
@ -25,7 +25,7 @@ using Microsoft::WRL::RuntimeClassFlags;
|
|||
|
||||
class ScopedHString;
|
||||
|
||||
namespace brightray {
|
||||
namespace atom {
|
||||
|
||||
using DesktopToastActivatedEventHandler =
|
||||
ABI::Windows::Foundation::ITypedEventHandler<
|
||||
|
@ -126,6 +126,6 @@ class ToastEventHandler : public RuntimeClass<RuntimeClassFlags<ClassicCom>,
|
|||
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_mac.h",
|
||||
"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.mm",
|
||||
"browser/mac/cocoa_notification.h",
|
||||
"browser/mac/cocoa_notification.mm",
|
||||
"browser/mac/event_dispatching_window.h",
|
||||
"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.h",
|
||||
"browser/media/media_device_id_salt.cc",
|
||||
|
@ -74,36 +62,14 @@ static_library("brightray") {
|
|||
"browser/media/media_stream_devices_controller.h",
|
||||
"browser/net/require_ct_delegate.cc",
|
||||
"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.h",
|
||||
"browser/views/views_delegate.cc",
|
||||
"browser/views/views_delegate.h",
|
||||
"browser/web_ui_controller_factory.cc",
|
||||
"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.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.h",
|
||||
"common/application_info.cc",
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
#include "brightray/browser/browser_main_parts.h"
|
||||
#include "brightray/browser/devtools_manager_delegate.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/common/url_constants.h"
|
||||
|
||||
|
@ -59,20 +57,6 @@ BrowserClient::BrowserClient() : browser_main_parts_(nullptr) {
|
|||
|
||||
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(
|
||||
const content::MainFunctionParams&) {
|
||||
return new BrowserMainParts;
|
||||
|
@ -89,13 +73,6 @@ content::MediaObserver* BrowserClient::GetMediaObserver() {
|
|||
return MediaCaptureDevicesDispatcher::GetInstance();
|
||||
}
|
||||
|
||||
content::PlatformNotificationService*
|
||||
BrowserClient::GetPlatformNotificationService() {
|
||||
if (!notification_service_)
|
||||
notification_service_.reset(new PlatformNotificationService(this));
|
||||
return notification_service_.get();
|
||||
}
|
||||
|
||||
void BrowserClient::GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* additional_schemes) {
|
||||
additional_schemes->push_back(content::kChromeDevToolsScheme);
|
||||
|
|
|
@ -14,8 +14,6 @@
|
|||
namespace brightray {
|
||||
|
||||
class BrowserMainParts;
|
||||
class NotificationPresenter;
|
||||
class PlatformNotificationService;
|
||||
|
||||
class BrowserClient : public content::ContentBrowserClient {
|
||||
public:
|
||||
|
@ -27,20 +25,11 @@ class BrowserClient : public content::ContentBrowserClient {
|
|||
|
||||
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
|
||||
// handlers) should call this implementation after doing their own work.
|
||||
content::BrowserMainParts* CreateBrowserMainParts(
|
||||
const content::MainFunctionParams&) override;
|
||||
content::MediaObserver* GetMediaObserver() override;
|
||||
content::PlatformNotificationService* GetPlatformNotificationService()
|
||||
override;
|
||||
void GetAdditionalAllowedSchemesForFileSystem(
|
||||
std::vector<std::string>* additional_schemes) override;
|
||||
void GetAdditionalWebUISchemes(
|
||||
|
@ -59,9 +48,6 @@ class BrowserClient : public content::ContentBrowserClient {
|
|||
private:
|
||||
BrowserMainParts* browser_main_parts_;
|
||||
|
||||
std::unique_ptr<PlatformNotificationService> notification_service_;
|
||||
std::unique_ptr<NotificationPresenter> notification_presenter_;
|
||||
|
||||
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_stream_job.cc",
|
||||
"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.h",
|
||||
"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_delegate.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_ns_window.h'],
|
||||
['atom', 'browser', 'ui', 'cocoa', 'atom_ns_window_delegate.h'],
|
||||
|
@ -28,15 +29,6 @@ const BLACKLIST = new Set([
|
|||
['atom', 'node', 'osfhandle.cc'],
|
||||
['brightray', 'browser', 'mac', 'bry_inspectable_web_contents_view.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']
|
||||
].map(tokens => path.join(SOURCE_ROOT, ...tokens)))
|
||||
|
||||
|
|
Loading…
Reference in a new issue