How to show messagebox in Chromium?

189 views
Skip to first unread message

Junaid Iqbal

unread,
Jan 8, 2018, 9:39:32 AM1/8/18
to Chromium-dev
Hello:

I am new to chromium development. I am using visual studio to modify the source code. I was wondering how would you print a message or an alert box in chromium when. I tried messagebox(); but it didn't work. Any help would be appreciated,

Thanks,




Greg Thompson

unread,
Jan 9, 2018, 8:58:04 AM1/9/18
to junai...@gmail.com, Chromium-dev
From what process type are you hoping to pop a message box? Note that we have a ui::MessageBox wrapper around ::MessageBox, which you can easily find using code search; for example: https://cs.chromium.org/search/?q=messagebox&sq=package:chromium&type=cs.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/04f8964e-8506-4769-ba36-5452bbfe1f0a%40chromium.org.

Junaid Iqbal

unread,
Jan 9, 2018, 10:13:29 AM1/9/18
to Chromium-dev, junai...@gmail.com
Thanks for your answer. I am actually working around dom project (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/). I am trying to intercept the rendering of the dom. To understand the flow of code in ContainerNode.cpp (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/ContainerNode.cpp), I want to print some values of nodes or any alert box containing some string. I tried MessageBox but I am not sure if that would work in .cpp file? I hope it clarifies my situation.

Thanks,

Jeremy Roman

unread,
Jan 9, 2018, 10:25:27 AM1/9/18
to junai...@gmail.com, Chromium-dev
On Tue, Jan 9, 2018 at 10:13 AM, Junaid Iqbal <junai...@gmail.com> wrote:
Thanks for your answer. I am actually working around dom project (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/). I am trying to intercept the rendering of the dom. To understand the flow of code in ContainerNode.cpp (https://cs.chromium.org/chromium/src/third_party/WebKit/Source/core/dom/ContainerNode.cpp), I want to print some values of nodes or any alert box containing some string. I tried MessageBox but I am not sure if that would work in .cpp file? I hope it clarifies my situation.

I'd suggest using LOG(ERROR) or a debugger instead. The renderer process is by default sandboxed and doesn't ordinarily interact with the UI directly, so you may have trouble trying to do UI stuff.
 
Thanks,

 

On Tuesday, January 9, 2018 at 9:58:04 AM UTC-4, Greg Thompson wrote:
From what process type are you hoping to pop a message box? Note that we have a ui::MessageBox wrapper around ::MessageBox, which you can easily find using code search; for example: https://cs.chromium.org/search/?q=messagebox&sq=package:chromium&type=cs.

On Mon, Jan 8, 2018 at 3:40 PM Junaid Iqbal <junai...@gmail.com> wrote:
Hello:

I am new to chromium development. I am using visual studio to modify the source code. I was wondering how would you print a message or an alert box in chromium when. I tried messagebox(); but it didn't work. Any help would be appreciated,

Thanks,




--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/04f8964e-8506-4769-ba36-5452bbfe1f0a%40chromium.org.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.

Junaid Iqbal

unread,
Jan 9, 2018, 10:30:07 AM1/9/18
to Chromium-dev, junai...@gmail.com
I tried LOG(ERROR), and I start the browser with --enable-logging --v=1 there were lots of info in the logging window, I could not find my specified string in the log.

Steve Kobes

unread,
Jan 9, 2018, 1:26:24 PM1/9/18
to junai...@gmail.com, Chromium-dev
Logging on Windows has some quirks.  Try --enable-logging=stderr, and also make sure you have win_console_app = true in your GN args file.

Brett Wilson

unread,
Jan 9, 2018, 1:40:15 PM1/9/18
to junai...@gmail.com, Chromium-dev
I use MessageBox sometimes in the renderer, but you need to disable the sandbox (--no-sandbox) or it will be blocked.

Brett

Sébastien Marchand

unread,
Jan 9, 2018, 2:16:33 PM1/9/18
to Brett Wilson, junai...@gmail.com, Chromium-dev
You can also only enable logging for some specific modules with "--v=0 --vmodule=path_to_file=1", see this comment for more details: https://chromium.googlesource.com/chromium/src/+/master/base/logging.h#89

Junaid Iqbal

unread,
Jan 10, 2018, 1:37:32 PM1/10/18
to Chromium-dev, junai...@gmail.com
Hey Steve, 

Thanks for your reply, I tried your suggestion but now I am getting the following error on logging windows:

[6560:11748:0110/143522.029:ERROR:gpu_process_transport_factory.cc(1050)] Lost UI shared context.

Junaid Iqbal

unread,
Jan 10, 2018, 1:43:42 PM1/10/18
to Chromium-dev, junai...@gmail.com
This works! Thanks Brett

Any suggesstion on printing objects in MessageBox? Like Node, or full DOM tree? I cannot even print a simple string like "testing". I gives me an error that type does not match. I looked into the definition of MessageBox and I found the below parameter types. I don't understand them. 

MessageBox(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType)

Christian Biesinger

unread,
Jan 10, 2018, 2:31:31 PM1/10/18
to Junaid Iqbal, Chromium-dev
Try L"testing" for strings.

In general, things are more optimized for logging and/or output to
stderr. For example, there's showTreeForThis(Node*) which prints to
stderr. But you can try:

MessageBox(NULL, node->ToTreeStringForThis().data(), L"", 0);

Christian
> https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/9e4f4d39-efa3-40d9-aaa8-5817961c368d%40chromium.org.

Junaid Iqbal

unread,
Jan 11, 2018, 9:27:33 AM1/11/18
to Chromium-dev, junai...@gmail.com
Works like a charm!

Thanks Christian
Reply all
Reply to author
Forward
0 new messages