Remove the old Web Notification code-path (Chromium)
This patch removes the old Web Notifications code-path now that we've switched to the new Workers-enabled path. BUG=392187 Review URL: https://codereview.chromium.org/740543003 Cr-Commit-Position: refs/heads/master@{#305005}
This commit is contained in:
content
browser
frame_host
renderer_host
common
content_common.gypicontent_renderer.gypicontent_shell.gypicontent_tests.gypirenderer
BUILD.gnactive_notification_tracker.ccactive_notification_tracker.hactive_notification_tracker_unittest.ccnotification_icon_loader.ccnotification_icon_loader.hnotification_provider.ccnotification_provider.hrender_frame_impl.ccrender_frame_impl.h
shell
ipc
@ -37,7 +37,6 @@
|
||||
#include "content/browser/renderer_host/render_widget_host_view_base.h"
|
||||
#include "content/browser/transition_request_manager.h"
|
||||
#include "content/common/accessibility_messages.h"
|
||||
#include "content/common/desktop_notification_messages.h"
|
||||
#include "content/common/frame_messages.h"
|
||||
#include "content/common/input_messages.h"
|
||||
#include "content/common/inter_process_time_ticks_converter.h"
|
||||
@ -83,54 +82,6 @@ typedef base::hash_map<RenderFrameHostID, RenderFrameHostImpl*>
|
||||
base::LazyInstance<RoutingIDFrameMap> g_routing_id_frame_map =
|
||||
LAZY_INSTANCE_INITIALIZER;
|
||||
|
||||
class DesktopNotificationDelegateImpl : public DesktopNotificationDelegate {
|
||||
public:
|
||||
DesktopNotificationDelegateImpl(RenderFrameHost* render_frame_host,
|
||||
int notification_id)
|
||||
: render_process_id_(render_frame_host->GetProcess()->GetID()),
|
||||
render_frame_id_(render_frame_host->GetRoutingID()),
|
||||
notification_id_(notification_id) {}
|
||||
|
||||
~DesktopNotificationDelegateImpl() override {}
|
||||
|
||||
void NotificationDisplayed() override {
|
||||
RenderFrameHost* rfh =
|
||||
RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
||||
if (!rfh)
|
||||
return;
|
||||
|
||||
rfh->Send(new DesktopNotificationMsg_PostDisplay(
|
||||
rfh->GetRoutingID(), notification_id_));
|
||||
}
|
||||
|
||||
void NotificationClosed(bool by_user) override {
|
||||
RenderFrameHost* rfh =
|
||||
RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
||||
if (!rfh)
|
||||
return;
|
||||
|
||||
rfh->Send(new DesktopNotificationMsg_PostClose(
|
||||
rfh->GetRoutingID(), notification_id_, by_user));
|
||||
static_cast<RenderFrameHostImpl*>(rfh)->NotificationClosed(
|
||||
notification_id_);
|
||||
}
|
||||
|
||||
void NotificationClick() override {
|
||||
RenderFrameHost* rfh =
|
||||
RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
||||
if (!rfh)
|
||||
return;
|
||||
|
||||
rfh->Send(new DesktopNotificationMsg_PostClick(
|
||||
rfh->GetRoutingID(), notification_id_));
|
||||
}
|
||||
|
||||
private:
|
||||
int render_process_id_;
|
||||
int render_frame_id_;
|
||||
int notification_id_;
|
||||
};
|
||||
|
||||
// Translate a WebKit text direction into a base::i18n one.
|
||||
base::i18n::TextDirection WebTextDirectionToChromeTextDirection(
|
||||
blink::WebTextDirection dir) {
|
||||
@ -384,10 +335,6 @@ bool RenderFrameHostImpl::OnMessageReceived(const IPC::Message &msg) {
|
||||
OnBeginNavigation)
|
||||
IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_RequestPermission,
|
||||
OnRequestPlatformNotificationPermission)
|
||||
IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show,
|
||||
OnShowDesktopNotification)
|
||||
IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel,
|
||||
OnCancelDesktopNotification)
|
||||
IPC_MESSAGE_HANDLER(FrameHostMsg_TextSurroundingSelectionResponse,
|
||||
OnTextSurroundingSelectionResponse)
|
||||
IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Events, OnAccessibilityEvents)
|
||||
@ -1017,31 +964,6 @@ void RenderFrameHostImpl::OnRequestPlatformNotificationPermission(
|
||||
done_callback);
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::OnShowDesktopNotification(
|
||||
int notification_id,
|
||||
const ShowDesktopNotificationHostMsgParams& params) {
|
||||
scoped_ptr<DesktopNotificationDelegateImpl> delegate(
|
||||
new DesktopNotificationDelegateImpl(this, notification_id));
|
||||
|
||||
base::Closure cancel_callback;
|
||||
GetContentClient()->browser()->ShowDesktopNotification(
|
||||
params,
|
||||
GetSiteInstance()->GetBrowserContext(),
|
||||
GetProcess()->GetID(),
|
||||
delegate.Pass(),
|
||||
&cancel_callback);
|
||||
|
||||
cancel_notification_callbacks_[notification_id] = cancel_callback;
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::OnCancelDesktopNotification(int notification_id) {
|
||||
if (!cancel_notification_callbacks_.count(notification_id))
|
||||
return;
|
||||
|
||||
cancel_notification_callbacks_[notification_id].Run();
|
||||
cancel_notification_callbacks_.erase(notification_id);
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::OnTextSurroundingSelectionResponse(
|
||||
const base::string16& content,
|
||||
size_t start_offset,
|
||||
@ -1453,10 +1375,6 @@ void RenderFrameHostImpl::JavaScriptDialogClosed(
|
||||
render_view_host_->delegate_->RendererUnresponsive(render_view_host_);
|
||||
}
|
||||
|
||||
void RenderFrameHostImpl::NotificationClosed(int notification_id) {
|
||||
cancel_notification_callbacks_.erase(notification_id);
|
||||
}
|
||||
|
||||
// PlzNavigate
|
||||
void RenderFrameHostImpl::CommitNavigation(
|
||||
ResourceResponse* response,
|
||||
|
@ -322,9 +322,6 @@ class CONTENT_EXPORT RenderFrameHostImpl
|
||||
const base::string16& user_input,
|
||||
bool dialog_was_suppressed);
|
||||
|
||||
// Called when an HTML5 notification is closed.
|
||||
void NotificationClosed(int notification_id);
|
||||
|
||||
// Clears any outstanding transition request. This is called when we hear the
|
||||
// response or commit.
|
||||
void ClearPendingTransitionRequestData();
|
||||
@ -539,9 +536,6 @@ class CONTENT_EXPORT RenderFrameHostImpl
|
||||
// ExecuteJavaScript and their corresponding callbacks.
|
||||
std::map<int, JavaScriptResultCallback> javascript_callbacks_;
|
||||
|
||||
// Map from notification_id to a callback to cancel them.
|
||||
std::map<int, base::Closure> cancel_notification_callbacks_;
|
||||
|
||||
int routing_id_;
|
||||
|
||||
// The current state of this RenderFrameHost.
|
||||
|
@ -35,7 +35,6 @@
|
||||
#include "content/common/child_process_messages.h"
|
||||
#include "content/common/content_constants_internal.h"
|
||||
#include "content/common/cookie_data.h"
|
||||
#include "content/common/desktop_notification_messages.h"
|
||||
#include "content/common/frame_messages.h"
|
||||
#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
|
||||
#include "content/common/host_discardable_shared_memory_manager.h"
|
||||
@ -71,7 +70,6 @@
|
||||
#include "net/url_request/url_request_context.h"
|
||||
#include "net/url_request/url_request_context_getter.h"
|
||||
#include "ppapi/shared_impl/file_type_conversion.h"
|
||||
#include "third_party/WebKit/public/web/WebNotificationPresenter.h"
|
||||
#include "ui/gfx/color_profile.h"
|
||||
|
||||
#if defined(OS_MACOSX)
|
||||
@ -108,7 +106,6 @@ const int kPluginsRefreshThresholdInSeconds = 3;
|
||||
|
||||
const uint32 kFilteredMessageClasses[] = {
|
||||
ChildProcessMsgStart,
|
||||
DesktopNotificationMsgStart,
|
||||
FrameMsgStart,
|
||||
ViewMsgStart,
|
||||
};
|
||||
@ -400,8 +397,6 @@ bool RenderMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||
RenderWidgetResizeHelper::Get()->PostRendererProcessMsg(
|
||||
render_process_id_, message))
|
||||
#endif
|
||||
IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_CheckPermission,
|
||||
OnCheckNotificationPermission)
|
||||
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
|
||||
OnAllocateSharedMemory)
|
||||
IPC_MESSAGE_HANDLER_DELAY_REPLY(
|
||||
@ -898,17 +893,6 @@ void RenderMessageFilter::OnSaveImageFromDataURL(int render_view_id,
|
||||
DownloadUrl(render_view_id, data_url, Referrer(), base::string16(), true);
|
||||
}
|
||||
|
||||
void RenderMessageFilter::OnCheckNotificationPermission(
|
||||
const GURL& source_origin, int* result) {
|
||||
#if defined(ENABLE_NOTIFICATIONS)
|
||||
*result = GetContentClient()->browser()->
|
||||
CheckDesktopNotificationPermission(source_origin, resource_context_,
|
||||
render_process_id_);
|
||||
#else
|
||||
*result = blink::WebNotificationPresenter::PermissionAllowed;
|
||||
#endif
|
||||
}
|
||||
|
||||
void RenderMessageFilter::OnAllocateSharedMemory(
|
||||
uint32 buffer_size,
|
||||
base::SharedMemoryHandle* handle) {
|
||||
|
@ -212,8 +212,6 @@ class CONTENT_EXPORT RenderMessageFilter : public BrowserMessageFilter {
|
||||
const Referrer& referrer,
|
||||
const base::string16& suggested_name);
|
||||
void OnSaveImageFromDataURL(int render_view_id, const std::string& url_str);
|
||||
void OnCheckNotificationPermission(const GURL& source_origin,
|
||||
int* permission_level);
|
||||
|
||||
void OnGetAudioHardwareConfig(media::AudioParameters* input_params,
|
||||
media::AudioParameters* output_params);
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "content/common/cc_messages.h"
|
||||
#include "content/common/clipboard_messages.h"
|
||||
#include "content/common/database_messages.h"
|
||||
#include "content/common/desktop_notification_messages.h"
|
||||
#include "content/common/device_sensors/device_light_messages.h"
|
||||
#include "content/common/device_sensors/device_motion_messages.h"
|
||||
#include "content/common/device_sensors/device_orientation_messages.h"
|
||||
|
@ -1,49 +0,0 @@
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// IPC messages for desktop notification.
|
||||
// Multiply-included message file, hence no include guard.
|
||||
|
||||
#include "content/public/common/show_desktop_notification_params.h"
|
||||
#include "ipc/ipc_message_macros.h"
|
||||
|
||||
#define IPC_MESSAGE_START DesktopNotificationMsgStart
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(content::ShowDesktopNotificationHostMsgParams)
|
||||
IPC_STRUCT_TRAITS_MEMBER(origin)
|
||||
IPC_STRUCT_TRAITS_MEMBER(icon)
|
||||
IPC_STRUCT_TRAITS_MEMBER(title)
|
||||
IPC_STRUCT_TRAITS_MEMBER(body)
|
||||
IPC_STRUCT_TRAITS_MEMBER(direction)
|
||||
IPC_STRUCT_TRAITS_MEMBER(replace_id)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
// Messages sent from the browser to the renderer.
|
||||
|
||||
// Used to inform the renderer that the browser has displayed its
|
||||
// requested notification.
|
||||
IPC_MESSAGE_ROUTED1(DesktopNotificationMsg_PostDisplay,
|
||||
int /* notification_id */)
|
||||
|
||||
// Informs the renderer that the one if its notifications has closed.
|
||||
IPC_MESSAGE_ROUTED2(DesktopNotificationMsg_PostClose,
|
||||
int /* notification_id */,
|
||||
bool /* by_user */)
|
||||
|
||||
// Informs the renderer that one of its notifications was clicked on.
|
||||
IPC_MESSAGE_ROUTED1(DesktopNotificationMsg_PostClick,
|
||||
int /* notification_id */)
|
||||
|
||||
// Messages sent from the renderer to the browser.
|
||||
|
||||
IPC_MESSAGE_ROUTED2(DesktopNotificationHostMsg_Show,
|
||||
int /* notification_id */,
|
||||
content::ShowDesktopNotificationHostMsgParams /* params */)
|
||||
|
||||
IPC_MESSAGE_ROUTED1(DesktopNotificationHostMsg_Cancel,
|
||||
int /* notification_id */)
|
||||
|
||||
IPC_SYNC_MESSAGE_ROUTED1_1(DesktopNotificationHostMsg_CheckPermission,
|
||||
GURL /* origin */,
|
||||
int /* permission_result */)
|
@ -15,6 +15,15 @@
|
||||
IPC_ENUM_TRAITS_MAX_VALUE(blink::WebNotificationPermission,
|
||||
blink::WebNotificationPermissionLast)
|
||||
|
||||
IPC_STRUCT_TRAITS_BEGIN(content::ShowDesktopNotificationHostMsgParams)
|
||||
IPC_STRUCT_TRAITS_MEMBER(origin)
|
||||
IPC_STRUCT_TRAITS_MEMBER(icon)
|
||||
IPC_STRUCT_TRAITS_MEMBER(title)
|
||||
IPC_STRUCT_TRAITS_MEMBER(body)
|
||||
IPC_STRUCT_TRAITS_MEMBER(direction)
|
||||
IPC_STRUCT_TRAITS_MEMBER(replace_id)
|
||||
IPC_STRUCT_TRAITS_END()
|
||||
|
||||
// Messages sent from the browser to the renderer.
|
||||
|
||||
// Informs the renderer that the permission request for |request_id| is done,
|
||||
|
@ -202,7 +202,6 @@
|
||||
'common/cursors/webcursor_ozone.cc',
|
||||
'common/database_messages.h',
|
||||
'common/date_time_suggestion.h',
|
||||
'common/desktop_notification_messages.h',
|
||||
'common/device_sensors/device_light_data.h',
|
||||
'common/device_sensors/device_light_hardware_buffer.h',
|
||||
'common/device_sensors/device_light_messages.h',
|
||||
|
@ -80,8 +80,6 @@
|
||||
'renderer/accessibility/blink_ax_tree_source.h',
|
||||
'renderer/accessibility/renderer_accessibility.cc',
|
||||
'renderer/accessibility/renderer_accessibility.h',
|
||||
'renderer/active_notification_tracker.cc',
|
||||
'renderer/active_notification_tracker.h',
|
||||
'renderer/android/address_detector.cc',
|
||||
'renderer/android/address_detector.h',
|
||||
'renderer/android/content_detector.cc',
|
||||
@ -300,12 +298,8 @@
|
||||
'renderer/mouse_lock_dispatcher.h',
|
||||
'renderer/net_info_helper.cc',
|
||||
'renderer/net_info_helper.h',
|
||||
'renderer/notification_icon_loader.cc',
|
||||
'renderer/notification_icon_loader.h',
|
||||
'renderer/notification_permission_dispatcher.cc',
|
||||
'renderer/notification_permission_dispatcher.h',
|
||||
'renderer/notification_provider.cc',
|
||||
'renderer/notification_provider.h',
|
||||
'renderer/push_messaging_dispatcher.cc',
|
||||
'renderer/push_messaging_dispatcher.h',
|
||||
'renderer/render_font_warmup_win.cc',
|
||||
@ -706,12 +700,6 @@
|
||||
'<@(private_renderer_sources)',
|
||||
],
|
||||
'conditions': [
|
||||
['notifications==0', {
|
||||
'sources!': [
|
||||
'renderer/notification_provider.cc',
|
||||
'renderer/active_notification_tracker.cc',
|
||||
],
|
||||
}],
|
||||
['OS=="mac"', {
|
||||
'sources!': [
|
||||
'common/process_watcher_posix.cc',
|
||||
|
@ -249,8 +249,6 @@
|
||||
'shell/renderer/test_runner/mock_webrtc_dtmf_sender_handler.h',
|
||||
'shell/renderer/test_runner/mock_webrtc_peer_connection_handler.cc',
|
||||
'shell/renderer/test_runner/mock_webrtc_peer_connection_handler.h',
|
||||
'shell/renderer/test_runner/notification_presenter.cc',
|
||||
'shell/renderer/test_runner/notification_presenter.h',
|
||||
'shell/renderer/test_runner/spell_check_client.cc',
|
||||
'shell/renderer/test_runner/spell_check_client.h',
|
||||
'shell/renderer/test_runner/test_common.cc',
|
||||
|
@ -720,7 +720,6 @@
|
||||
'common/sandbox_mac_unittest_helper.mm',
|
||||
'common/shareable_file_reference_unittest.cc',
|
||||
'common/webplugininfo_unittest.cc',
|
||||
'renderer/active_notification_tracker_unittest.cc',
|
||||
'renderer/android/email_detector_unittest.cc',
|
||||
'renderer/android/phone_number_detector_unittest.cc',
|
||||
'renderer/bmp_image_decoder_unittest.cc',
|
||||
@ -900,11 +899,6 @@
|
||||
['exclude', '^browser/speech/'],
|
||||
]
|
||||
}],
|
||||
['notifications==0', {
|
||||
'sources!': [
|
||||
'renderer/active_notification_tracker_unittest.cc',
|
||||
],
|
||||
}],
|
||||
['OS=="linux"', {
|
||||
'dependencies': [
|
||||
'../build/linux/system.gyp:dbus',
|
||||
|
@ -62,13 +62,6 @@ source_set("renderer") {
|
||||
"//webkit/common/gpu",
|
||||
]
|
||||
|
||||
if (!enable_notifications) {
|
||||
sources -= [
|
||||
"notification_provider.cc",
|
||||
"active_notification_tracker.cc",
|
||||
]
|
||||
}
|
||||
|
||||
if (is_mac) {
|
||||
sources -= [
|
||||
"webscrollbarbehavior_impl_gtkoraura.cc",
|
||||
|
@ -1,67 +0,0 @@
|
||||
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/active_notification_tracker.h"
|
||||
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "third_party/WebKit/public/web/WebNotification.h"
|
||||
|
||||
using blink::WebNotification;
|
||||
|
||||
namespace content {
|
||||
|
||||
ActiveNotificationTracker::ActiveNotificationTracker() {}
|
||||
|
||||
ActiveNotificationTracker::~ActiveNotificationTracker() {}
|
||||
|
||||
bool ActiveNotificationTracker::GetId(
|
||||
const WebNotification& notification, int& id) {
|
||||
ReverseTable::iterator iter = reverse_notification_table_.find(notification);
|
||||
if (iter == reverse_notification_table_.end())
|
||||
return false;
|
||||
id = iter->second;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ActiveNotificationTracker::GetNotification(
|
||||
int id, WebNotification* notification) {
|
||||
WebNotification* lookup = notification_table_.Lookup(id);
|
||||
if (!lookup)
|
||||
return false;
|
||||
|
||||
*notification = *lookup;
|
||||
return true;
|
||||
}
|
||||
|
||||
int ActiveNotificationTracker::RegisterNotification(
|
||||
const blink::WebNotification& proxy) {
|
||||
if (reverse_notification_table_.find(proxy)
|
||||
!= reverse_notification_table_.end()) {
|
||||
return reverse_notification_table_[proxy];
|
||||
} else {
|
||||
WebNotification* notification = new WebNotification(proxy);
|
||||
int id = notification_table_.Add(notification);
|
||||
reverse_notification_table_[proxy] = id;
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
void ActiveNotificationTracker::UnregisterNotification(int id) {
|
||||
// We want to free the notification after removing it from the table.
|
||||
scoped_ptr<WebNotification> notification(notification_table_.Lookup(id));
|
||||
notification_table_.Remove(id);
|
||||
DCHECK(notification.get());
|
||||
if (notification)
|
||||
reverse_notification_table_.erase(*notification);
|
||||
}
|
||||
|
||||
void ActiveNotificationTracker::Clear() {
|
||||
while (!reverse_notification_table_.empty()) {
|
||||
ReverseTable::iterator iter = reverse_notification_table_.begin();
|
||||
UnregisterNotification((*iter).second);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,47 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_
|
||||
#define CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "base/containers/hash_tables.h"
|
||||
#include "base/id_map.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "third_party/WebKit/public/web/WebNotification.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
// This class manages the set of active Notification objects in either
|
||||
// a render or worker process. This class should be accessed only on
|
||||
// the main thread.
|
||||
class CONTENT_EXPORT ActiveNotificationTracker {
|
||||
public:
|
||||
ActiveNotificationTracker();
|
||||
~ActiveNotificationTracker();
|
||||
|
||||
// Methods for tracking active notification objects.
|
||||
int RegisterNotification(const blink::WebNotification& notification);
|
||||
void UnregisterNotification(int id);
|
||||
bool GetId(const blink::WebNotification& notification, int& id);
|
||||
bool GetNotification(int id, blink::WebNotification* notification);
|
||||
|
||||
// Clears out all active notifications. Useful on page navigation.
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
typedef std::map<blink::WebNotification, int> ReverseTable;
|
||||
|
||||
// Tracking maps for active notifications.
|
||||
IDMap<blink::WebNotification> notification_table_;
|
||||
ReverseTable reverse_notification_table_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ActiveNotificationTracker);
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_RENDERER_ACTIVE_NOTIFICATION_TRACKER_H_
|
@ -1,29 +0,0 @@
|
||||
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/active_notification_tracker.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
TEST(ActiveNotificationTrackerTest, TestLookupAndClear) {
|
||||
ActiveNotificationTracker tracker;
|
||||
|
||||
blink::WebNotification notification1;
|
||||
int id1 = tracker.RegisterNotification(notification1);
|
||||
|
||||
blink::WebNotification notification2;
|
||||
int id2 = tracker.RegisterNotification(notification2);
|
||||
|
||||
blink::WebNotification result;
|
||||
tracker.GetNotification(id1, &result);
|
||||
EXPECT_TRUE(result == notification1);
|
||||
|
||||
tracker.GetNotification(id2, &result);
|
||||
EXPECT_TRUE(result == notification2);
|
||||
|
||||
tracker.Clear();
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,83 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/notification_icon_loader.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "content/child/image_decoder.h"
|
||||
#include "third_party/WebKit/public/platform/Platform.h"
|
||||
#include "third_party/WebKit/public/platform/WebURL.h"
|
||||
#include "third_party/WebKit/public/platform/WebURLLoader.h"
|
||||
#include "third_party/skia/include/core/SkBitmap.h"
|
||||
|
||||
using blink::WebURL;
|
||||
using blink::WebURLError;
|
||||
using blink::WebURLLoader;
|
||||
using blink::WebURLRequest;
|
||||
|
||||
namespace content {
|
||||
|
||||
NotificationIconLoader::NotificationIconLoader(
|
||||
int notification_id,
|
||||
const DownloadCompletedCallback& callback)
|
||||
: notification_id_(notification_id),
|
||||
callback_(callback),
|
||||
completed_(false) {}
|
||||
|
||||
NotificationIconLoader::~NotificationIconLoader() {}
|
||||
|
||||
void NotificationIconLoader::Start(const WebURL& icon_url) {
|
||||
DCHECK(!loader_);
|
||||
|
||||
WebURLRequest request(icon_url);
|
||||
request.setRequestContext(WebURLRequest::RequestContextImage);
|
||||
|
||||
loader_.reset(blink::Platform::current()->createURLLoader());
|
||||
loader_->loadAsynchronously(request, this);
|
||||
}
|
||||
|
||||
void NotificationIconLoader::Cancel() {
|
||||
DCHECK(loader_);
|
||||
|
||||
completed_ = true;
|
||||
loader_->cancel();
|
||||
}
|
||||
|
||||
void NotificationIconLoader::didReceiveData(
|
||||
WebURLLoader* loader,
|
||||
const char* data,
|
||||
int data_length,
|
||||
int encoded_data_length) {
|
||||
DCHECK(!completed_);
|
||||
DCHECK_GT(data_length, 0);
|
||||
|
||||
buffer_.insert(buffer_.end(), data, data + data_length);
|
||||
}
|
||||
|
||||
void NotificationIconLoader::didFinishLoading(
|
||||
WebURLLoader* loader,
|
||||
double finish_time,
|
||||
int64_t total_encoded_data_length) {
|
||||
DCHECK(!completed_);
|
||||
|
||||
SkBitmap icon;
|
||||
if (!buffer_.empty()) {
|
||||
ImageDecoder decoder;
|
||||
icon = decoder.Decode(&buffer_[0], buffer_.size());
|
||||
}
|
||||
|
||||
completed_ = true;
|
||||
callback_.Run(notification_id_, icon);
|
||||
}
|
||||
|
||||
void NotificationIconLoader::didFail(
|
||||
WebURLLoader* loader, const WebURLError& error) {
|
||||
if (completed_)
|
||||
return;
|
||||
|
||||
completed_ = true;
|
||||
callback_.Run(notification_id_, SkBitmap());
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,73 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_RENDERER_NOTIFICATION_ICON_LOADER_H_
|
||||
#define CONTENT_RENDERER_NOTIFICATION_ICON_LOADER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/callback.h"
|
||||
#include "base/memory/scoped_ptr.h"
|
||||
#include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
|
||||
|
||||
class SkBitmap;
|
||||
|
||||
namespace blink {
|
||||
class WebURL;
|
||||
struct WebURLError;
|
||||
class WebURLLoader;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
|
||||
// Downloads the icon associated with a notification and decodes the received
|
||||
// image. This must be completed before notifications are shown to the user.
|
||||
// Icon downloaders must not be re-used for multiple notifications or icons.
|
||||
class NotificationIconLoader : public blink::WebURLLoaderClient {
|
||||
typedef base::Callback<void(int, const SkBitmap&)> DownloadCompletedCallback;
|
||||
|
||||
public:
|
||||
NotificationIconLoader(int notification_id,
|
||||
const DownloadCompletedCallback& callback);
|
||||
|
||||
virtual ~NotificationIconLoader();
|
||||
|
||||
// Downloads the notification's image and invokes the callback with the
|
||||
// decoded SkBitmap when the download has succeeded, or with an empty SkBitmap
|
||||
// in case the download has failed.
|
||||
void Start(const blink::WebURL& icon_url);
|
||||
|
||||
// Cancels the current image download. The callback will not be invoked.
|
||||
void Cancel();
|
||||
|
||||
// blink::WebURLLoaderClient implementation.
|
||||
virtual void didReceiveData(blink::WebURLLoader* loader,
|
||||
const char* data,
|
||||
int data_length,
|
||||
int encoded_data_length);
|
||||
virtual void didFinishLoading(blink::WebURLLoader* loader,
|
||||
double finish_time,
|
||||
int64_t total_encoded_data_length);
|
||||
virtual void didFail(blink::WebURLLoader* loader,
|
||||
const blink::WebURLError& error);
|
||||
|
||||
int notification_id() const {
|
||||
return notification_id_;
|
||||
}
|
||||
|
||||
private:
|
||||
int notification_id_;
|
||||
DownloadCompletedCallback callback_;
|
||||
|
||||
scoped_ptr<blink::WebURLLoader> loader_;
|
||||
bool completed_;
|
||||
|
||||
std::vector<uint8_t> buffer_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NotificationIconLoader);
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_RENDERER_NOTIFICATION_ICON_LOADER_H_
|
@ -1,165 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/renderer/notification_provider.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/strings/string_util.h"
|
||||
#include "content/common/desktop_notification_messages.h"
|
||||
#include "content/common/frame_messages.h"
|
||||
#include "content/renderer/notification_icon_loader.h"
|
||||
#include "content/renderer/render_frame_impl.h"
|
||||
#include "third_party/WebKit/public/web/WebDocument.h"
|
||||
#include "third_party/WebKit/public/web/WebLocalFrame.h"
|
||||
|
||||
using blink::WebDocument;
|
||||
using blink::WebNotification;
|
||||
using blink::WebNotificationPresenter;
|
||||
using blink::WebSecurityOrigin;
|
||||
using blink::WebString;
|
||||
|
||||
namespace content {
|
||||
|
||||
NotificationProvider::NotificationProvider(RenderFrame* render_frame)
|
||||
: RenderFrameObserver(render_frame) {}
|
||||
|
||||
NotificationProvider::~NotificationProvider() {}
|
||||
|
||||
bool NotificationProvider::show(const WebNotification& notification) {
|
||||
int notification_id = manager_.RegisterNotification(notification);
|
||||
if (notification.iconURL().isEmpty()) {
|
||||
DisplayNotification(notification_id, SkBitmap());
|
||||
return true;
|
||||
}
|
||||
|
||||
scoped_ptr<NotificationIconLoader> loader(
|
||||
new NotificationIconLoader(
|
||||
notification_id,
|
||||
base::Bind(&NotificationProvider::DisplayNotification,
|
||||
base::Unretained(this))));
|
||||
|
||||
loader->Start(notification.iconURL());
|
||||
|
||||
pending_notifications_.push_back(loader.release());
|
||||
return true;
|
||||
}
|
||||
|
||||
void NotificationProvider::DisplayNotification(int notification_id,
|
||||
const SkBitmap& icon) {
|
||||
WebDocument document = render_frame()->GetWebFrame()->document();
|
||||
WebNotification notification;
|
||||
|
||||
if (!manager_.GetNotification(notification_id, ¬ification)) {
|
||||
NOTREACHED();
|
||||
return;
|
||||
}
|
||||
|
||||
RemovePendingNotification(notification_id);
|
||||
|
||||
ShowDesktopNotificationHostMsgParams params;
|
||||
params.origin = GURL(document.securityOrigin().toString());
|
||||
params.icon = icon;
|
||||
params.title = notification.title();
|
||||
params.body = notification.body();
|
||||
params.direction = notification.direction();
|
||||
params.replace_id = notification.replaceId();
|
||||
|
||||
Send(new DesktopNotificationHostMsg_Show(routing_id(),
|
||||
notification_id,
|
||||
params));
|
||||
}
|
||||
|
||||
bool NotificationProvider::RemovePendingNotification(int notification_id) {
|
||||
PendingNotifications::iterator iter = pending_notifications_.begin();
|
||||
for (; iter != pending_notifications_.end(); ++iter) {
|
||||
if ((*iter)->notification_id() != notification_id)
|
||||
continue;
|
||||
|
||||
pending_notifications_.erase(iter);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void NotificationProvider::cancel(const WebNotification& notification) {
|
||||
int id;
|
||||
bool id_found = manager_.GetId(notification, id);
|
||||
// Won't be found if the notification has already been closed by the user,
|
||||
// or if the notification's icon is still being requested.
|
||||
if (id_found && !RemovePendingNotification(id))
|
||||
Send(new DesktopNotificationHostMsg_Cancel(routing_id(), id));
|
||||
}
|
||||
|
||||
void NotificationProvider::objectDestroyed(
|
||||
const WebNotification& notification) {
|
||||
int id;
|
||||
bool id_found = manager_.GetId(notification, id);
|
||||
// Won't be found if the notification has already been closed by the user.
|
||||
if (id_found) {
|
||||
RemovePendingNotification(id);
|
||||
manager_.UnregisterNotification(id);
|
||||
}
|
||||
}
|
||||
|
||||
WebNotificationPresenter::Permission NotificationProvider::checkPermission(
|
||||
const WebSecurityOrigin& origin) {
|
||||
int permission = WebNotificationPresenter::PermissionNotAllowed;
|
||||
Send(new DesktopNotificationHostMsg_CheckPermission(
|
||||
routing_id(),
|
||||
GURL(origin.toString()),
|
||||
&permission));
|
||||
return static_cast<WebNotificationPresenter::Permission>(permission);
|
||||
}
|
||||
|
||||
bool NotificationProvider::OnMessageReceived(const IPC::Message& message) {
|
||||
bool handled = true;
|
||||
IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message)
|
||||
IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay);
|
||||
IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClose, OnClose);
|
||||
IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClick, OnClick);
|
||||
IPC_MESSAGE_UNHANDLED(handled = false)
|
||||
IPC_END_MESSAGE_MAP()
|
||||
|
||||
if (message.type() == FrameMsg_Navigate::ID)
|
||||
OnNavigate(); // Don't want to swallow the message.
|
||||
|
||||
return handled;
|
||||
}
|
||||
|
||||
void NotificationProvider::OnDisplay(int id) {
|
||||
WebNotification notification;
|
||||
bool found = manager_.GetNotification(id, ¬ification);
|
||||
// |found| may be false if the WebNotification went out of scope in
|
||||
// the page before it was actually displayed to the user.
|
||||
if (found)
|
||||
notification.dispatchDisplayEvent();
|
||||
}
|
||||
|
||||
void NotificationProvider::OnClose(int id, bool by_user) {
|
||||
WebNotification notification;
|
||||
bool found = manager_.GetNotification(id, ¬ification);
|
||||
// |found| may be false if the WebNotification went out of scope in
|
||||
// the page before the associated toast was closed by the user.
|
||||
if (found) {
|
||||
notification.dispatchCloseEvent(by_user);
|
||||
manager_.UnregisterNotification(id);
|
||||
}
|
||||
}
|
||||
|
||||
void NotificationProvider::OnClick(int id) {
|
||||
WebNotification notification;
|
||||
bool found = manager_.GetNotification(id, ¬ification);
|
||||
// |found| may be false if the WebNotification went out of scope in
|
||||
// the page before the associated toast was clicked on.
|
||||
if (found)
|
||||
notification.dispatchClickEvent();
|
||||
}
|
||||
|
||||
void NotificationProvider::OnNavigate() {
|
||||
manager_.Clear();
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,66 +0,0 @@
|
||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_
|
||||
#define CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_
|
||||
|
||||
#include "base/memory/scoped_vector.h"
|
||||
#include "content/public/renderer/render_frame_observer.h"
|
||||
#include "content/renderer/active_notification_tracker.h"
|
||||
#include "third_party/WebKit/public/web/WebNotification.h"
|
||||
#include "third_party/WebKit/public/web/WebNotificationPresenter.h"
|
||||
|
||||
class SkBitmap;
|
||||
|
||||
namespace content {
|
||||
|
||||
class NotificationIconLoader;
|
||||
|
||||
// NotificationProvider class is owned by the RenderFrame. Only to be used on
|
||||
// the main thread.
|
||||
class NotificationProvider : public RenderFrameObserver,
|
||||
public blink::WebNotificationPresenter {
|
||||
public:
|
||||
explicit NotificationProvider(RenderFrame* render_frame);
|
||||
~NotificationProvider() override;
|
||||
|
||||
private:
|
||||
// RenderFrameObserver implementation.
|
||||
bool OnMessageReceived(const IPC::Message& message) override;
|
||||
|
||||
// blink::WebNotificationPresenter implementation.
|
||||
virtual bool show(const blink::WebNotification& proxy);
|
||||
virtual void cancel(const blink::WebNotification& proxy);
|
||||
virtual void objectDestroyed(const blink::WebNotification& proxy);
|
||||
virtual blink::WebNotificationPresenter::Permission checkPermission(
|
||||
const blink::WebSecurityOrigin& origin);
|
||||
|
||||
// Sends an IPC to the browser process to display the notification identified
|
||||
// by |notification|, accompanied by the downloaded icon.
|
||||
void DisplayNotification(int notification_id, const SkBitmap& icon);
|
||||
|
||||
// Removes the IconDownload object associated with |notification_id|, stopping
|
||||
// any in-progress download. Returns whether the notification was removed.
|
||||
bool RemovePendingNotification(int notification_id);
|
||||
|
||||
// IPC handlers.
|
||||
void OnDisplay(int id);
|
||||
void OnClose(int id, bool by_user);
|
||||
void OnClick(int id);
|
||||
void OnNavigate();
|
||||
|
||||
// A vector tracking notifications whose icon is still being downloaded.
|
||||
typedef ScopedVector<NotificationIconLoader> PendingNotifications;
|
||||
PendingNotifications pending_notifications_;
|
||||
|
||||
// A tracker object which manages the active notifications and the IDs
|
||||
// that are used to refer to them over IPC.
|
||||
ActiveNotificationTracker manager_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NotificationProvider);
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_RENDERER_NOTIFICATION_PROVIDER_H_
|
@ -79,7 +79,6 @@
|
||||
#include "content/renderer/media/webmediaplayer_ms.h"
|
||||
#include "content/renderer/mojo/service_registry_js_wrapper.h"
|
||||
#include "content/renderer/notification_permission_dispatcher.h"
|
||||
#include "content/renderer/notification_provider.h"
|
||||
#include "content/renderer/npapi/plugin_channel_host.h"
|
||||
#include "content/renderer/push_messaging_dispatcher.h"
|
||||
#include "content/renderer/render_frame_proxy.h"
|
||||
@ -572,7 +571,6 @@ RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id)
|
||||
selection_range_(gfx::Range::InvalidRange()),
|
||||
handling_select_range_(false),
|
||||
notification_permission_dispatcher_(NULL),
|
||||
notification_provider_(NULL),
|
||||
web_user_media_client_(NULL),
|
||||
midi_dispatcher_(NULL),
|
||||
#if defined(OS_ANDROID)
|
||||
@ -609,10 +607,6 @@ RenderFrameImpl::RenderFrameImpl(RenderViewImpl* render_view, int routing_id)
|
||||
plugin_power_saver_helper_ = new PluginPowerSaverHelper(this);
|
||||
#endif
|
||||
|
||||
#if defined(ENABLE_NOTIFICATIONS)
|
||||
notification_provider_ = new NotificationProvider(this);
|
||||
#endif
|
||||
|
||||
manifest_manager_ = new ManifestManager(this);
|
||||
}
|
||||
|
||||
@ -2642,10 +2636,6 @@ void RenderFrameImpl::requestNotificationPermission(
|
||||
notification_permission_dispatcher_->RequestPermission(origin, callback);
|
||||
}
|
||||
|
||||
blink::WebNotificationPresenter* RenderFrameImpl::notificationPresenter() {
|
||||
return notification_provider_;
|
||||
}
|
||||
|
||||
void RenderFrameImpl::didChangeSelection(bool is_empty_selection) {
|
||||
if (!GetRenderWidget()->handling_input_event() && !handling_select_range_)
|
||||
return;
|
||||
|
@ -46,7 +46,6 @@ class WebGeolocationClient;
|
||||
class WebMouseEvent;
|
||||
class WebContentDecryptionModule;
|
||||
class WebMediaPlayer;
|
||||
class WebNotificationPresenter;
|
||||
class WebPushClient;
|
||||
class WebSecurityOrigin;
|
||||
struct WebCompositionUnderline;
|
||||
@ -71,7 +70,6 @@ class MediaStreamDispatcher;
|
||||
class MediaStreamRendererFactory;
|
||||
class MidiDispatcher;
|
||||
class NotificationPermissionDispatcher;
|
||||
class NotificationProvider;
|
||||
class PageState;
|
||||
class PepperPluginInstanceImpl;
|
||||
class PluginPowerSaverHelper;
|
||||
@ -388,7 +386,6 @@ class CONTENT_EXPORT RenderFrameImpl
|
||||
virtual void requestNotificationPermission(
|
||||
const blink::WebSecurityOrigin& origin,
|
||||
blink::WebNotificationPermissionCallback* callback);
|
||||
virtual blink::WebNotificationPresenter* notificationPresenter();
|
||||
virtual void didChangeSelection(bool is_empty_selection);
|
||||
virtual blink::WebColorChooser* createColorChooser(
|
||||
blink::WebColorChooserClient* client,
|
||||
@ -753,10 +750,6 @@ class CONTENT_EXPORT RenderFrameImpl
|
||||
// Dispatches permission requests for Web Notifications.
|
||||
NotificationPermissionDispatcher* notification_permission_dispatcher_;
|
||||
|
||||
// Holds a reference to the service which provides desktop notifications.
|
||||
// TODO(peter) Remove this once Web Notifications are routed through Platform.
|
||||
NotificationProvider* notification_provider_;
|
||||
|
||||
// Destroyed via the RenderFrameObserver::OnDestruct() mechanism.
|
||||
UserMediaClientImpl* web_user_media_client_;
|
||||
|
||||
|
@ -194,8 +194,6 @@ static_library("content_shell_lib") {
|
||||
"renderer/test_runner/mock_webrtc_dtmf_sender_handler.h",
|
||||
"renderer/test_runner/mock_webrtc_peer_connection_handler.cc",
|
||||
"renderer/test_runner/mock_webrtc_peer_connection_handler.h",
|
||||
"renderer/test_runner/notification_presenter.cc",
|
||||
"renderer/test_runner/notification_presenter.h",
|
||||
"renderer/test_runner/spell_check_client.cc",
|
||||
"renderer/test_runner/spell_check_client.h",
|
||||
"renderer/test_runner/test_common.cc",
|
||||
|
@ -55,8 +55,6 @@ bool LayoutTestMessageFilter::OnMessageReceived(const IPC::Message& message) {
|
||||
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_ClearAllDatabases,
|
||||
OnClearAllDatabases)
|
||||
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_SetDatabaseQuota, OnSetDatabaseQuota)
|
||||
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_CheckWebNotificationPermission,
|
||||
OnCheckWebNotificationPermission)
|
||||
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_GrantWebNotificationPermission,
|
||||
OnGrantWebNotificationPermission)
|
||||
IPC_MESSAGE_HANDLER(LayoutTestHostMsg_ClearWebNotificationPermissions,
|
||||
@ -105,16 +103,6 @@ void LayoutTestMessageFilter::OnSetDatabaseQuota(int quota) {
|
||||
storage::QuotaCallback());
|
||||
}
|
||||
|
||||
void LayoutTestMessageFilter::OnCheckWebNotificationPermission(
|
||||
const GURL& origin, int* result) {
|
||||
LayoutTestNotificationManager* manager =
|
||||
LayoutTestContentBrowserClient::Get()->GetLayoutTestNotificationManager();
|
||||
if (manager)
|
||||
*result = manager->CheckPermission(origin);
|
||||
else
|
||||
*result = blink::WebNotificationPermissionAllowed;
|
||||
}
|
||||
|
||||
void LayoutTestMessageFilter::OnGrantWebNotificationPermission(
|
||||
const GURL& origin, bool permission_granted) {
|
||||
LayoutTestNotificationManager* manager =
|
||||
|
@ -50,7 +50,6 @@ class LayoutTestMessageFilter : public BrowserMessageFilter {
|
||||
std::string* filesystem_id);
|
||||
void OnClearAllDatabases();
|
||||
void OnSetDatabaseQuota(int quota);
|
||||
void OnCheckWebNotificationPermission(const GURL& origin, int* result);
|
||||
void OnGrantWebNotificationPermission(const GURL& origin,
|
||||
bool permission_granted);
|
||||
void OnClearWebNotificationPermissions();
|
||||
|
@ -22,9 +22,6 @@ IPC_SYNC_MESSAGE_ROUTED1_1(LayoutTestHostMsg_RegisterIsolatedFileSystem,
|
||||
IPC_MESSAGE_ROUTED0(LayoutTestHostMsg_ClearAllDatabases)
|
||||
IPC_MESSAGE_ROUTED1(LayoutTestHostMsg_SetDatabaseQuota,
|
||||
int /* quota */)
|
||||
IPC_SYNC_MESSAGE_ROUTED1_1(LayoutTestHostMsg_CheckWebNotificationPermission,
|
||||
GURL /* origin */,
|
||||
int /* result */)
|
||||
IPC_MESSAGE_ROUTED2(LayoutTestHostMsg_GrantWebNotificationPermission,
|
||||
GURL /* origin */,
|
||||
bool /* permission_granted */)
|
||||
|
@ -412,16 +412,6 @@ void WebKitTestRunner::SetDatabaseQuota(int quota) {
|
||||
Send(new LayoutTestHostMsg_SetDatabaseQuota(routing_id(), quota));
|
||||
}
|
||||
|
||||
blink::WebNotificationPresenter::Permission
|
||||
WebKitTestRunner::CheckWebNotificationPermission(const GURL& origin) {
|
||||
int permission = blink::WebNotificationPresenter::PermissionNotAllowed;
|
||||
Send(new LayoutTestHostMsg_CheckWebNotificationPermission(
|
||||
routing_id(),
|
||||
origin,
|
||||
&permission));
|
||||
return static_cast<blink::WebNotificationPresenter::Permission>(permission);
|
||||
}
|
||||
|
||||
void WebKitTestRunner::GrantWebNotificationPermission(const GURL& origin,
|
||||
bool permission_granted) {
|
||||
Send(new LayoutTestHostMsg_GrantWebNotificationPermission(
|
||||
|
@ -88,8 +88,6 @@ class WebKitTestRunner : public RenderViewObserver,
|
||||
void EvaluateInWebInspector(long call_id, const std::string& script) override;
|
||||
void ClearAllDatabases() override;
|
||||
void SetDatabaseQuota(int quota) override;
|
||||
blink::WebNotificationPresenter::Permission CheckWebNotificationPermission(
|
||||
const GURL& origin) override;
|
||||
void GrantWebNotificationPermission(const GURL& origin,
|
||||
bool permission_granted) override;
|
||||
void ClearWebNotificationPermissions() override;
|
||||
|
@ -1,133 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "content/shell/renderer/test_runner/notification_presenter.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "content/common/desktop_notification_messages.h"
|
||||
#include "content/shell/renderer/test_runner/web_test_delegate.h"
|
||||
#include "third_party/WebKit/public/platform/Platform.h"
|
||||
#include "third_party/WebKit/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/public/platform/WebURL.h"
|
||||
#include "third_party/WebKit/public/web/WebKit.h"
|
||||
#include "third_party/WebKit/public/web/WebNotificationPermissionCallback.h"
|
||||
#include "third_party/WebKit/public/web/WebSecurityOrigin.h"
|
||||
#include "url/gurl.h"
|
||||
|
||||
using blink::Platform;
|
||||
using blink::WebNotification;
|
||||
using blink::WebNotificationPermissionCallback;
|
||||
using blink::WebNotificationPresenter;
|
||||
using blink::WebSecurityOrigin;
|
||||
using blink::WebTextDirectionRightToLeft;
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
void DeferredDisplayDispatch(void* context) {
|
||||
WebNotification* notification = static_cast<WebNotification*>(context);
|
||||
notification->dispatchDisplayEvent();
|
||||
|
||||
delete notification;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NotificationPresenter::NotificationPresenter() : delegate_(0) {}
|
||||
|
||||
NotificationPresenter::~NotificationPresenter() {}
|
||||
|
||||
bool NotificationPresenter::SimulateClick(const std::string& title) {
|
||||
ActiveNotificationMap::iterator iter = active_notifications_.find(title);
|
||||
if (iter == active_notifications_.end())
|
||||
return false;
|
||||
|
||||
const WebNotification& notification = iter->second;
|
||||
|
||||
WebNotification event_target(notification);
|
||||
event_target.dispatchClickEvent();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NotificationPresenter::Reset() {
|
||||
while (!active_notifications_.empty()) {
|
||||
const WebNotification& notification = active_notifications_.begin()->second;
|
||||
cancel(notification);
|
||||
}
|
||||
|
||||
replacements_.clear();
|
||||
}
|
||||
|
||||
bool NotificationPresenter::show(const WebNotification& notification) {
|
||||
if (!notification.replaceId().isEmpty()) {
|
||||
std::string replaceId(notification.replaceId().utf8());
|
||||
if (replacements_.find(replaceId) != replacements_.end()) {
|
||||
delegate_->PrintMessage(std::string("REPLACING NOTIFICATION ") +
|
||||
replacements_.find(replaceId)->second + "\n");
|
||||
}
|
||||
replacements_[replaceId] = notification.title().utf8();
|
||||
}
|
||||
|
||||
delegate_->PrintMessage("DESKTOP NOTIFICATION SHOWN: ");
|
||||
if (!notification.title().isEmpty())
|
||||
delegate_->PrintMessage(notification.title().utf8().data());
|
||||
|
||||
if (notification.direction() == WebTextDirectionRightToLeft)
|
||||
delegate_->PrintMessage(", RTL");
|
||||
|
||||
// TODO(beverloo): WebNotification should expose the "lang" attribute's value.
|
||||
|
||||
if (!notification.body().isEmpty()) {
|
||||
delegate_->PrintMessage(std::string(", body: ") +
|
||||
notification.body().utf8().data());
|
||||
}
|
||||
|
||||
if (!notification.replaceId().isEmpty()) {
|
||||
delegate_->PrintMessage(std::string(", tag: ") +
|
||||
notification.replaceId().utf8().data());
|
||||
}
|
||||
|
||||
if (!notification.iconURL().isEmpty()) {
|
||||
delegate_->PrintMessage(std::string(", icon: ") +
|
||||
notification.iconURL().spec().data());
|
||||
}
|
||||
|
||||
delegate_->PrintMessage("\n");
|
||||
|
||||
std::string title = notification.title().utf8();
|
||||
active_notifications_[title] = notification;
|
||||
|
||||
Platform::current()->callOnMainThread(DeferredDisplayDispatch,
|
||||
new WebNotification(notification));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void NotificationPresenter::cancel(const WebNotification& notification) {
|
||||
std::string title = notification.title().utf8();
|
||||
|
||||
delegate_->PrintMessage(std::string("DESKTOP NOTIFICATION CLOSED: ") + title +
|
||||
"\n");
|
||||
|
||||
WebNotification event_target(notification);
|
||||
event_target.dispatchCloseEvent(false);
|
||||
|
||||
active_notifications_.erase(title);
|
||||
}
|
||||
|
||||
void NotificationPresenter::objectDestroyed(
|
||||
const WebNotification& notification) {
|
||||
std::string title = notification.title().utf8();
|
||||
active_notifications_.erase(title);
|
||||
}
|
||||
|
||||
WebNotificationPresenter::Permission NotificationPresenter::checkPermission(
|
||||
const WebSecurityOrigin& security_origin) {
|
||||
return delegate_->CheckWebNotificationPermission(
|
||||
GURL(security_origin.toString()));
|
||||
}
|
||||
|
||||
} // namespace content
|
@ -1,55 +0,0 @@
|
||||
// Copyright 2014 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_
|
||||
#define CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "base/basictypes.h"
|
||||
#include "third_party/WebKit/public/web/WebNotification.h"
|
||||
#include "third_party/WebKit/public/web/WebNotificationPresenter.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
class WebTestDelegate;
|
||||
|
||||
// A class that implements WebNotificationPresenter for the TestRunner library.
|
||||
class NotificationPresenter : public blink::WebNotificationPresenter {
|
||||
public:
|
||||
NotificationPresenter();
|
||||
virtual ~NotificationPresenter();
|
||||
|
||||
// Called by the TestRunner to simulate a user clicking on a notification.
|
||||
bool SimulateClick(const std::string& title);
|
||||
|
||||
// Called by the TestRunner to reset the presenter to an default state.
|
||||
void Reset();
|
||||
|
||||
void set_delegate(WebTestDelegate* delegate) { delegate_ = delegate; }
|
||||
|
||||
// blink::WebNotificationPresenter interface
|
||||
virtual bool show(const blink::WebNotification& notification);
|
||||
virtual void cancel(const blink::WebNotification& notification);
|
||||
virtual void objectDestroyed(const blink::WebNotification& notification);
|
||||
virtual Permission checkPermission(
|
||||
const blink::WebSecurityOrigin& security_origin);
|
||||
|
||||
private:
|
||||
WebTestDelegate* delegate_;
|
||||
|
||||
// Map of currently active notifications.
|
||||
typedef std::map<std::string, blink::WebNotification> ActiveNotificationMap;
|
||||
ActiveNotificationMap active_notifications_;
|
||||
|
||||
// Map of replacement identifiers to the titles of those notifications.
|
||||
std::map<std::string, std::string> replacements_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NotificationPresenter);
|
||||
};
|
||||
|
||||
} // namespace content
|
||||
|
||||
#endif // CONTENT_SHELL_RENDERER_TEST_RUNNER_NOTIFICATION_PRESENTER_H_
|
@ -13,7 +13,6 @@
|
||||
#include "content/shell/renderer/test_runner/mock_credential_manager_client.h"
|
||||
#include "content/shell/renderer/test_runner/mock_web_push_client.h"
|
||||
#include "content/shell/renderer/test_runner/mock_web_speech_recognizer.h"
|
||||
#include "content/shell/renderer/test_runner/notification_presenter.h"
|
||||
#include "content/shell/renderer/test_runner/test_interfaces.h"
|
||||
#include "content/shell/renderer/test_runner/web_permissions.h"
|
||||
#include "content/shell/renderer/test_runner/web_test_delegate.h"
|
||||
@ -1547,7 +1546,6 @@ TestRunner::TestRunner(TestInterfaces* interfaces)
|
||||
web_view_(nullptr),
|
||||
page_overlay_(nullptr),
|
||||
web_permissions_(new WebPermissions()),
|
||||
notification_presenter_(new NotificationPresenter()),
|
||||
weak_factory_(this) {}
|
||||
|
||||
TestRunner::~TestRunner() {}
|
||||
@ -1559,7 +1557,6 @@ void TestRunner::Install(WebFrame* frame) {
|
||||
void TestRunner::SetDelegate(WebTestDelegate* delegate) {
|
||||
delegate_ = delegate;
|
||||
web_permissions_->SetDelegate(delegate);
|
||||
notification_presenter_->set_delegate(delegate);
|
||||
}
|
||||
|
||||
void TestRunner::SetWebView(WebView* webView, WebTestProxyBase* proxy) {
|
||||
@ -1659,7 +1656,6 @@ void TestRunner::Reset() {
|
||||
|
||||
web_permissions_->Reset();
|
||||
|
||||
notification_presenter_->Reset();
|
||||
use_mock_theme_ = true;
|
||||
pointer_locked_ = false;
|
||||
pointer_lock_planned_result_ = PointerLockWillSucceed;
|
||||
@ -1879,10 +1875,6 @@ bool TestRunner::shouldDumpResourcePriorities() const {
|
||||
return should_dump_resource_priorities_;
|
||||
}
|
||||
|
||||
WebNotificationPresenter* TestRunner::notification_presenter() const {
|
||||
return notification_presenter_.get();
|
||||
}
|
||||
|
||||
bool TestRunner::RequestPointerLock() {
|
||||
switch (pointer_lock_planned_result_) {
|
||||
case PointerLockWillSucceed:
|
||||
@ -2776,10 +2768,6 @@ void TestRunner::ClearWebNotificationPermissions() {
|
||||
|
||||
void TestRunner::SimulateWebNotificationClick(const std::string& title) {
|
||||
delegate_->SimulateWebNotificationClick(title);
|
||||
|
||||
// TODO(peter): Remove this call once Web Notifications switch away from the
|
||||
// WebFrame-based code path.
|
||||
notification_presenter_->SimulateClick(title);
|
||||
}
|
||||
|
||||
void TestRunner::AddMockSpeechRecognitionResult(const std::string& transcript,
|
||||
|
@ -20,7 +20,6 @@ class SkBitmap;
|
||||
|
||||
namespace blink {
|
||||
class WebFrame;
|
||||
class WebNotificationPresenter;
|
||||
class WebPermissionClient;
|
||||
class WebString;
|
||||
class WebView;
|
||||
@ -35,7 +34,6 @@ class Arguments;
|
||||
namespace content {
|
||||
|
||||
class InvokeCallbackTask;
|
||||
class NotificationPresenter;
|
||||
class TestInterfaces;
|
||||
class TestPageOverlay;
|
||||
class WebPermissions;
|
||||
@ -117,7 +115,6 @@ class TestRunner : public WebTestRunner,
|
||||
bool policyDelegateShouldNotifyDone() const;
|
||||
bool shouldInterceptPostMessage() const;
|
||||
bool shouldDumpResourcePriorities() const;
|
||||
blink::WebNotificationPresenter* notification_presenter() const;
|
||||
bool RequestPointerLock();
|
||||
void RequestPointerUnlock();
|
||||
bool isPointerLocked();
|
||||
@ -528,7 +525,7 @@ class TestRunner : public WebTestRunner,
|
||||
// Clears all previously granted Web Notification permissions.
|
||||
void ClearWebNotificationPermissions();
|
||||
|
||||
// Simulates a click on a desktop notification.
|
||||
// Simulates a click on a Web Notification.
|
||||
void SimulateWebNotificationClick(const std::string& title);
|
||||
|
||||
// Speech recognition related functions.
|
||||
@ -770,8 +767,6 @@ class TestRunner : public WebTestRunner,
|
||||
// WebPermissionClient mock object.
|
||||
scoped_ptr<WebPermissions> web_permissions_;
|
||||
|
||||
scoped_ptr<NotificationPresenter> notification_presenter_;
|
||||
|
||||
bool pointer_locked_;
|
||||
enum {
|
||||
PointerLockWillSucceed,
|
||||
|
@ -129,10 +129,6 @@ class WebFrameTestProxy : public Base {
|
||||
base_proxy_->DidFinishLoad(frame);
|
||||
}
|
||||
|
||||
virtual blink::WebNotificationPresenter* notificationPresenter() {
|
||||
return base_proxy_->GetNotificationPresenter();
|
||||
}
|
||||
|
||||
virtual void didChangeSelection(bool is_selection_empty) {
|
||||
base_proxy_->DidChangeSelection(is_selection_empty);
|
||||
Base::didChangeSelection(is_selection_empty);
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "third_party/WebKit/public/platform/WebString.h"
|
||||
#include "third_party/WebKit/public/platform/WebURL.h"
|
||||
#include "third_party/WebKit/public/platform/WebVector.h"
|
||||
#include "third_party/WebKit/public/web/WebNotificationPresenter.h"
|
||||
|
||||
#define WEBTESTRUNNER_NEW_HISTORY_CAPTURE
|
||||
|
||||
@ -135,9 +134,7 @@ class WebTestDelegate {
|
||||
virtual void ClearAllDatabases() = 0;
|
||||
virtual void SetDatabaseQuota(int quota) = 0;
|
||||
|
||||
// Controls Web Notification permissions.
|
||||
virtual blink::WebNotificationPresenter::Permission
|
||||
CheckWebNotificationPermission(const GURL& origin) = 0;
|
||||
// Controls Web Notifications.
|
||||
virtual void GrantWebNotificationPermission(const GURL& origin,
|
||||
bool permission_granted) = 0;
|
||||
virtual void ClearWebNotificationPermissions() = 0;
|
||||
|
@ -885,10 +885,6 @@ void WebTestProxyBase::PrintPage(blink::WebLocalFrame* frame) {
|
||||
frame->printEnd();
|
||||
}
|
||||
|
||||
blink::WebNotificationPresenter* WebTestProxyBase::GetNotificationPresenter() {
|
||||
return test_interfaces_->GetTestRunner()->notification_presenter();
|
||||
}
|
||||
|
||||
blink::WebMIDIClient* WebTestProxyBase::GetWebMIDIClient() {
|
||||
return GetMIDIClientMock();
|
||||
}
|
||||
|
@ -51,7 +51,6 @@ class WebMIDIAccessorClient;
|
||||
class WebMIDIClient;
|
||||
class WebMIDIClientMock;
|
||||
class WebNode;
|
||||
class WebNotificationPresenter;
|
||||
class WebPlugin;
|
||||
class WebPushClient;
|
||||
class WebRange;
|
||||
@ -173,7 +172,6 @@ class WebTestProxyBase {
|
||||
const blink::WebContextMenuData& data);
|
||||
blink::WebUserMediaClient* GetUserMediaClient();
|
||||
void PrintPage(blink::WebLocalFrame* frame);
|
||||
blink::WebNotificationPresenter* GetNotificationPresenter();
|
||||
blink::WebMIDIClient* GetWebMIDIClient();
|
||||
blink::WebSpeechRecognizer* GetSpeechRecognizer();
|
||||
bool RequestPointerLock();
|
||||
|
@ -45,7 +45,6 @@ enum IPCMessageStart {
|
||||
DeviceLightMsgStart,
|
||||
DeviceMotionMsgStart,
|
||||
DeviceOrientationMsgStart,
|
||||
DesktopNotificationMsgStart,
|
||||
GeolocationMsgStart,
|
||||
AudioMsgStart,
|
||||
MidiMsgStart,
|
||||
|
Reference in New Issue
Block a user