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

Unified Diff: chrome/test/data/native_messaging/native_hosts/echo.py

Issue 115683005: Pass correct --parent-window value to native messaging hosts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/api/messaging/native_process_launcher.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/native_messaging/native_hosts/echo.py
diff --git a/chrome/test/data/native_messaging/native_hosts/echo.py b/chrome/test/data/native_messaging/native_hosts/echo.py
index e9550f6cf678f7831b2617c03b3e39f23a6f7dfe..b7176b141ac617931cc6c7b3d9cac44ff87fcaad 100755
--- a/chrome/test/data/native_messaging/native_hosts/echo.py
+++ b/chrome/test/data/native_messaging/native_hosts/echo.py
@@ -7,6 +7,7 @@
# All this client does is echo the text it receives back at the extension.
import os
+import platform
import sys
import struct
@@ -22,13 +23,24 @@ def WriteMessage(message):
def Main():
message_number = 0
+ caller_url = None;
miket_OOO 2014/01/07 17:15:11 Begone, semicolon!
Sergey Ulanov 2014/01/07 20:56:10 Done.
+ parent_window = None
+
if len(sys.argv) < 2:
sys.stderr.write("URL of the calling application is not specified.\n")
- return;
+ return 1
for arg in sys.argv[1:]:
- if not arg.startswith('--'):
+ if arg.startswith('--'):
+ if arg.startswith('--parent-window='):
miket_OOO 2014/01/07 17:15:11 Not a big deal, but it makes me sad when I see man
Sergey Ulanov 2014/01/07 20:56:10 Added TODO. FWIW argparse is available only starti
+ parent_window = long(arg[len('--parent-window='):])
+ elif caller_url == None:
caller_url = arg
- break
+
+ if platform.system() == 'Windows':
+ import win32gui
+ if not win32gui.IsWindow(parent_window):
+ sys.stderr.write('Invalid --parent-window.\n')
+ return 1
while 1:
# Read the message type (first 4 bytes).
@@ -63,10 +75,10 @@ def Main():
message_number += 1
- if not WriteMessage(
- '{{"id": {0}, "echo": {1}, "caller_url": "{2}"}}'.format(
- message_number, text, caller_url).encode('utf-8')):
+ message = '{{"id": {0}, "echo": {1}, "caller_url": "{2}"}}'.format(
+ message_number, text, caller_url).encode('utf-8')
+ if not WriteMessage(message):
break
if __name__ == '__main__':
- Main()
+ sys.exit(Main())
« no previous file with comments | « chrome/browser/extensions/api/messaging/native_process_launcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698