OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Class for parsing metadata about extension samples.""" | 5 """Class for parsing metadata about extension samples.""" |
6 | 6 |
7 import locale | 7 import locale |
8 import os | 8 import os |
9 import os.path | 9 import os.path |
10 import re | 10 import re |
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 def _uses_popup(self): | 742 def _uses_popup(self): |
743 """ Returns true if the extension defines a popup on a page or browser | 743 """ Returns true if the extension defines a popup on a page or browser |
744 action. """ | 744 action. """ |
745 has_b_popup = (self._uses_browser_action() and | 745 has_b_popup = (self._uses_browser_action() and |
746 self._manifest['browser_action'].has_key('popup')) | 746 self._manifest['browser_action'].has_key('popup')) |
747 has_p_popup = (self._uses_page_action() and | 747 has_p_popup = (self._uses_page_action() and |
748 self._manifest['page_action'].has_key('popup')) | 748 self._manifest['page_action'].has_key('popup')) |
749 return has_b_popup or has_p_popup | 749 return has_b_popup or has_p_popup |
750 | 750 |
751 def is_hosted_app(self): | 751 def is_hosted_app(self): |
752 """ Returns true if the manifest has an app but not a local_path.""" | 752 """ Returns true if the manifest has an app but not a local_path (that's a |
| 753 packaged app) nor a background (that's a platform app).""" |
753 return (self._manifest.has_key('app') and | 754 return (self._manifest.has_key('app') and |
754 (not self._manifest['app'].has_key('launch') or | 755 (not self._manifest['app'].has_key('launch') or |
755 not self._manifest['app']['launch'].has_key('local_path'))) | 756 not self._manifest['app']['launch'].has_key('local_path')) and |
| 757 not self._manifest['app'].has_key('background')) |
756 | 758 |
757 def is_packaged_app(self): | 759 def is_packaged_app(self): |
758 """ Returns true if the manifest has an app/launch/local_path section.""" | 760 """ Returns true if the manifest has an app/launch/local_path section.""" |
759 return (self._manifest.has_key('app') and | 761 return (self._manifest.has_key('app') and |
760 self._manifest['app'].has_key('launch') and | 762 self._manifest['app'].has_key('launch') and |
761 self._manifest['app']['launch'].has_key('local_path')) | 763 self._manifest['app']['launch'].has_key('local_path')) |
762 | 764 |
763 def write_zip(self): | 765 def write_zip(self): |
764 """ Writes a zip file containing all of the files in this Sample's dir.""" | 766 """ Writes a zip file containing all of the files in this Sample's dir.""" |
765 sample_path = os.path.realpath(os.path.dirname(self._manifest_path)) | 767 sample_path = os.path.realpath(os.path.dirname(self._manifest_path)) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 zip_file.write(abspath, relpath) | 810 zip_file.write(abspath, relpath) |
809 if file == 'manifest.json': | 811 if file == 'manifest.json': |
810 info = zip_file.getinfo(zip_manifest_path) | 812 info = zip_file.getinfo(zip_manifest_path) |
811 info.comment = self['source_hash'] | 813 info.comment = self['source_hash'] |
812 except RuntimeError, msg: | 814 except RuntimeError, msg: |
813 raise Exception("Could not write zip at %s: %s" % (zip_path, msg)) | 815 raise Exception("Could not write zip at %s: %s" % (zip_path, msg)) |
814 finally: | 816 finally: |
815 zip_file.close() | 817 zip_file.close() |
816 | 818 |
817 return self._get_relative_zip_path() | 819 return self._get_relative_zip_path() |
OLD | NEW |