Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: webkit/tools/test_shell/notification_presenter.cc

Issue 2608001: Change the test notification presenter to fire the display event asynchronous... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/tools/test_shell/notification_presenter.h" 5 #include "webkit/tools/test_shell/notification_presenter.h"
6 6
7 #include "base/message_loop.h"
8 #include "base/task.h"
7 #include "googleurl/src/gurl.h" 9 #include "googleurl/src/gurl.h"
8 #include "third_party/WebKit/WebKit/chromium/public/WebNotification.h" 10 #include "third_party/WebKit/WebKit/chromium/public/WebNotification.h"
9 #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPermissionCal lback.h" 11 #include "third_party/WebKit/WebKit/chromium/public/WebNotificationPermissionCal lback.h"
10 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" 12 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h"
11 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" 13 #include "third_party/WebKit/WebKit/chromium/public/WebString.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" 14 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
13 15
14 using WebKit::WebNotification; 16 using WebKit::WebNotification;
15 using WebKit::WebNotificationPresenter; 17 using WebKit::WebNotificationPresenter;
16 using WebKit::WebNotificationPermissionCallback; 18 using WebKit::WebNotificationPermissionCallback;
17 using WebKit::WebSecurityOrigin; 19 using WebKit::WebSecurityOrigin;
18 using WebKit::WebString; 20 using WebKit::WebString;
19 using WebKit::WebURL; 21 using WebKit::WebURL;
20 22
23 namespace {
24 void DeferredDisplayDispatch(WebNotification notification) {
25 notification.dispatchDisplayEvent();
26 }
27 }
28
21 void TestNotificationPresenter::grantPermission(const std::string& origin) { 29 void TestNotificationPresenter::grantPermission(const std::string& origin) {
22 // Make sure it's in the form of an origin. 30 // Make sure it's in the form of an origin.
23 GURL url(origin); 31 GURL url(origin);
24 allowed_origins_.insert(url.GetOrigin().spec()); 32 allowed_origins_.insert(url.GetOrigin().spec());
25 } 33 }
26 34
27 // The output from all these methods matches what DumpRenderTree produces. 35 // The output from all these methods matches what DumpRenderTree produces.
28 bool TestNotificationPresenter::show(const WebNotification& notification) { 36 bool TestNotificationPresenter::show(const WebNotification& notification) {
29 if (!notification.replaceId().isEmpty()) { 37 if (!notification.replaceId().isEmpty()) {
30 std::string replace_id(notification.replaceId().utf8()); 38 std::string replace_id(notification.replaceId().utf8());
(...skipping 13 matching lines...) Expand all
44 printf("DESKTOP NOTIFICATION:%s icon %s, title %s, text %s\n", 52 printf("DESKTOP NOTIFICATION:%s icon %s, title %s, text %s\n",
45 notification.dir() == "rtl" ? "(RTL)" : "", 53 notification.dir() == "rtl" ? "(RTL)" : "",
46 notification.iconURL().isEmpty() ? "" : 54 notification.iconURL().isEmpty() ? "" :
47 notification.iconURL().spec().data(), 55 notification.iconURL().spec().data(),
48 notification.title().isEmpty() ? "" : 56 notification.title().isEmpty() ? "" :
49 notification.title().utf8().data(), 57 notification.title().utf8().data(),
50 notification.body().isEmpty() ? "" : 58 notification.body().isEmpty() ? "" :
51 notification.body().utf8().data()); 59 notification.body().utf8().data());
52 } 60 }
53 61
62
54 WebNotification event_target(notification); 63 WebNotification event_target(notification);
55 event_target.dispatchDisplayEvent(); 64 MessageLoop::current()->PostTask(FROM_HERE,
65 NewRunnableFunction(&DeferredDisplayDispatch, event_target));
56 return true; 66 return true;
57 } 67 }
58 68
59 void TestNotificationPresenter::cancel(const WebNotification& notification) { 69 void TestNotificationPresenter::cancel(const WebNotification& notification) {
60 WebString identifier; 70 WebString identifier;
61 if (notification.isHTML()) 71 if (notification.isHTML())
62 identifier = notification.url().spec().utf16(); 72 identifier = notification.url().spec().utf16();
63 else 73 else
64 identifier = notification.title(); 74 identifier = notification.title();
65 75
(...skipping 16 matching lines...) Expand all
82 : WebNotificationPresenter::PermissionDenied; 92 : WebNotificationPresenter::PermissionDenied;
83 } 93 }
84 94
85 void TestNotificationPresenter::requestPermission( 95 void TestNotificationPresenter::requestPermission(
86 const WebSecurityOrigin& origin, 96 const WebSecurityOrigin& origin,
87 WebNotificationPermissionCallback* callback) { 97 WebNotificationPermissionCallback* callback) {
88 printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n", 98 printf("DESKTOP NOTIFICATION PERMISSION REQUESTED: %s\n",
89 origin.toString().utf8().data()); 99 origin.toString().utf8().data());
90 callback->permissionRequestComplete(); 100 callback->permissionRequestComplete();
91 } 101 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698