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

Unified Diff: chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py

Issue 2567483002: Add proto for TLS error assistant, refactor proto generator code. (Closed)
Patch Set: Add OWNERS for c/b/r/protobufs and c/b/r/ssl Created 4 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
Index: chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py
diff --git a/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py b/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py
new file mode 100755
index 0000000000000000000000000000000000000000..4ad676c629fc36ee0274a2fa06940c591bb575a1
--- /dev/null
+++ b/chrome/browser/resources/ssl/tls_error_assistant/gen_tls_error_assistant_proto.py
@@ -0,0 +1,44 @@
+#!/usr/bin/python
+# Copyright 2016 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.
+
+"""
+ Convert the ASCII tls_error_assistant.asciipb proto into a binary resource.
+"""
+
+import os
+import sys
+
+# Import the binary proto generator. Walks up to the root of the source tree
+# which is six directories above, and the finds the protobufs directory from
+# there.
+proto_generator_path = os.path.normpath(os.path.join(os.path.abspath(__file__),
+ *[os.path.pardir] * 6 + ['chrome/browser/resources/protobufs']))
+sys.path.insert(0, proto_generator_path)
+from binary_proto_generator import BinaryProtoGenerator
+
+
+class TLSErrorAssistantProtoGenerator(BinaryProtoGenerator):
+ def ImportProtoModule(self):
+ import tls_error_assistant_pb2
+ globals()['tls_error_assistant_pb2'] = tls_error_assistant_pb2
+
+ def EmptyProtoInstance(self):
+ return tls_error_assistant_pb2.TLSErrorAssistantConfig()
+
+ def ValidatePb(self, opts, pb):
+ assert pb.version_id > 0
+ assert len(pb.captive_portal_cert) > 0
+
+ def ProcessPb(self, opts, pb):
+ binary_pb_str = pb.SerializeToString()
+ outfile = os.path.join(opts.outdir, opts.outbasename)
+ open(outfile, 'wb').write(binary_pb_str)
+
+
+def main():
+ return TLSErrorAssistantProtoGenerator().Run()
+
+if __name__ == '__main__':
+ sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698