Avoid adding WebContentsAudioMuted method

This commit is contained in:
Cheng Zhao 2016-07-02 16:53:48 +09:00
parent b217fb07a6
commit bf9d2b7fa9
2 changed files with 7 additions and 14 deletions

View file

@ -28,13 +28,10 @@ class BrowserClient : public content::ContentBrowserClient {
NotificationPresenter* GetNotificationPresenter(); NotificationPresenter* GetNotificationPresenter();
// Subclasses should override this to enable or disable WebNotification. // Subclasses should override this to enable or disable WebNotification.
virtual void WebNotificationAllowed(int render_process_id, virtual void WebNotificationAllowed(
const base::Callback<void(bool)>& callback) { int render_process_id,
callback.Run(true); const base::Callback<void(bool, bool)>& callback) {
} callback.Run(false, true);
virtual bool WebContentsAudioMuted(int render_process_id) {
return false;
} }
// Subclasses that override this (e.g., to provide their own protocol // Subclasses that override this (e.g., to provide their own protocol

View file

@ -22,12 +22,12 @@ void RemoveNotification(base::WeakPtr<Notification> notification) {
} }
void OnWebNotificationAllowed( void OnWebNotificationAllowed(
int render_process_id,
brightray::BrowserClient* browser_client, brightray::BrowserClient* browser_client,
const SkBitmap& icon, const SkBitmap& icon,
const content::PlatformNotificationData& data, const content::PlatformNotificationData& data,
std::unique_ptr<content::DesktopNotificationDelegate> delegate, std::unique_ptr<content::DesktopNotificationDelegate> delegate,
base::Closure* cancel_callback, base::Closure* cancel_callback,
bool audio_muted,
bool allowed) { bool allowed) {
if (!allowed) if (!allowed)
return; return;
@ -38,12 +38,9 @@ void OnWebNotificationAllowed(
new NotificationDelegateAdapter(std::move(delegate))); new NotificationDelegateAdapter(std::move(delegate)));
auto notification = presenter->CreateNotification(adapter.get()); auto notification = presenter->CreateNotification(adapter.get());
if (notification) { if (notification) {
bool silent = data.silent;
if (!silent) {
silent = browser_client->WebContentsAudioMuted(render_process_id);
}
ignore_result(adapter.release()); // it will release itself automatically. ignore_result(adapter.release()); // it will release itself automatically.
notification->Show(data.title, data.body, data.tag, data.icon, icon, silent); notification->Show(data.title, data.body, data.tag, data.icon, icon,
audio_muted ? true : data.silent);
*cancel_callback = base::Bind(&RemoveNotification, notification); *cancel_callback = base::Bind(&RemoveNotification, notification);
} }
} }
@ -83,7 +80,6 @@ void PlatformNotificationService::DisplayNotification(
browser_client_->WebNotificationAllowed( browser_client_->WebNotificationAllowed(
render_process_id_, render_process_id_,
base::Bind(&OnWebNotificationAllowed, base::Bind(&OnWebNotificationAllowed,
render_process_id_,
browser_client_, browser_client_,
notification_resources.notification_icon, notification_resources.notification_icon,
notification_data, notification_data,