How about the notification in CEF3?

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

How about the notification in CEF3?

Postby atai » Sun Jan 26, 2014 4:20 am

Hi all,
I am a newbie with CEF3. I want to ask the situation with desktop notification in CEF3? Is there any solution for it?
Thanks for any help.
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Re: How about the notification in CEF3?

Postby magreenblatt » Sun Jan 26, 2014 3:43 pm

CEF3 does not support the notification API. You will need to create your own modal dialogs in your application using native code.
magreenblatt
Site Admin
 
Posts: 12406
Joined: Fri May 29, 2009 6:57 pm

Re: How about the notification in CEF3?

Postby atai » Fri Jan 31, 2014 10:46 am

I tried to find the taskbar notification in Windows using API, but only could find the code using MFC. I don't know whether we can use it? Or someone already did it using pure WinAPI?
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Re: How about the notification in CEF3?

Postby magreenblatt » Fri Jan 31, 2014 11:44 am

atai wrote:I tried to find the taskbar notification in Windows using API, but only could find the code using MFC. I don't know whether we can use it? Or someone already did it using pure WinAPI?

Did you see this?
magreenblatt
Site Admin
 
Posts: 12406
Joined: Fri May 29, 2009 6:57 pm

Re: How about the notification in CEF3?

Postby atai » Fri Jan 31, 2014 12:09 pm

Yes, I found the Taskbar Notification written in VC++ with MFC.
1. http://www.codeproject.com/Articles/256 ... ion-dialog
2. http://www.codeproject.com/Articles/146 ... essage-box

As I said, I couldn't find the code using pure WinAPI for this. In the second article, they said "Here is the code I would like to share with anyone out there who would also like to use it, but was not able to do so because of no direct API help for the following task.".
How do you think about this?
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Re: How about the notification in CEF3?

Postby atai » Fri Jan 31, 2014 12:10 pm

And I found this one: http://www.componentsource.com/products ... mmary.html
But this one is commercial version, I think.
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Re: How about the notification in CEF3?

Postby magreenblatt » Fri Jan 31, 2014 2:09 pm

The link I posted above describes the API (Shell_NotifyIcon, etc). You can create your own implementation based on the documentation.
magreenblatt
Site Admin
 
Posts: 12406
Joined: Fri May 29, 2009 6:57 pm

Re: How about the notification in CEF3?

Postby atai » Fri Jan 31, 2014 9:33 pm

Thanks a lot, Marshall.
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Re: How about the notification in CEF3?

Postby atai » Wed Feb 05, 2014 8:27 am

Hi Marshall,
When I tried to add desktop notification into cefclient, I had some problem.

I tried to add notification class (just customize the binding_test as a copy), and tried to use (customize) the binding.html to test notification. I did as follow:

----------------------------------------
1. In binding.html:
1.1. add one more form:
Message: <input type="text" id="message2" value="My Message2">
1.2. add one more textarea result2:
<br/><textarea rows="10" cols="40" id="result2"></textarea>
1.3. add one more app.setMessageCallback:

app.setMessageCallback('desktop_notification', function (name, args) {
document.getElementById('result2').value = "Response: " + args[1];
});

1.4. in function sendMessage() add:
var msg2 = document.getElementById("message2").value;
app.sendMessage('desktop_notification', [msg, msg2]);


3. I add desktop_notification class, the same as binding_test class:

#include "cefclient/desktop_notification.h"
#include "include/cef_browser.h"
#include <algorithm>
#include <string>

namespace desktop_notification {

namespace {

const char* kMessageName = "desktop_notification";

// Handle messages in the browser process.
class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
public:
ProcessMessageDelegate() {
}

// From ClientHandler::ProcessMessageDelegate.
virtual bool OnProcessMessageReceived(
CefRefPtr<ClientHandler> handler,
CefRefPtr<CefBrowser> browser,
CefProcessId source_process,
CefRefPtr<CefProcessMessage> message) OVERRIDE {
std::string message_name = message->GetName();
if (message_name == kMessageName) {
// Handle the message.
std::string result;
std::string result2;

CefRefPtr<CefListValue> args = message->GetArgumentList();
if (args->GetSize() > 0 && args->GetType(0) == VTYPE_STRING) {
// Our result is a reverse of the original message.
result = args->GetString(0);
result2 = args->GetString(1);

MessageBoxA(NULL,"yes, I can get it", "test",MB_OK);
std::reverse(result2.begin(), result2.end());
} else {
result = "Invalid request";
}

// Send the result back to the render process.
CefRefPtr<CefProcessMessage> response =
CefProcessMessage::Create(kMessageName);
response->GetArgumentList()->SetString(0, result);
response->GetArgumentList()->SetString(1, result2);
browser->SendProcessMessage(PID_RENDERER, response);

return true;
}

return false;
}

IMPLEMENT_REFCOUNTING(ProcessMessageDelegate);
};

} // namespace

void CreateProcessMessageDelegates(ClientHandler::ProcessMessageDelegateSet& delegates)
{
delegates.insert(new ProcessMessageDelegate);
}

} // namespace desktop_notification


----------------------------------------

I tried to rebuild all and run the app, but there is no action in desktop_notification.cpp.
After that, i removed all things I added (comment out), return the beginning, but now the binding_test doesn't work as before.
Marshall, can you help to figure out?
Thanks.
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Re: How about the notification in CEF3?

Postby atai » Wed Feb 05, 2014 9:41 pm

I figured out the reason, Marshall,
Need to add desktop_notification::CreateProcessMessageDelegates(delegates); in the ClientHandler.
Now it works Ok.
Thanks.
atai
Techie
 
Posts: 22
Joined: Fri Jan 24, 2014 9:47 pm

Next

Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 9 guests