| 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 import copy | 5 import copy |
| 6 import logging | 6 import logging |
| 7 import posixpath | 7 import posixpath |
| 8 | 8 |
| 9 from compiled_file_system import Cache, SingleFile, Unicode | 9 from compiled_file_system import Cache, SingleFile, Unicode |
| 10 from data_source import DataSource | 10 from data_source import DataSource |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 return False | 53 return False |
| 54 | 54 |
| 55 | 55 |
| 56 class SidenavDataSource(DataSource): | 56 class SidenavDataSource(DataSource): |
| 57 '''Provides templates with access to JSON files used to create the side | 57 '''Provides templates with access to JSON files used to create the side |
| 58 navigation bar. | 58 navigation bar. |
| 59 ''' | 59 ''' |
| 60 def __init__(self, server_instance, request): | 60 def __init__(self, server_instance, request): |
| 61 self._cache = server_instance.compiled_fs_factory.Create( | 61 self._cache = server_instance.compiled_fs_factory.Create( |
| 62 server_instance.host_file_system_provider.GetTrunk(), | 62 server_instance.host_file_system_provider.GetMaster(), |
| 63 self._CreateSidenavDict, | 63 self._CreateSidenavDict, |
| 64 SidenavDataSource) | 64 SidenavDataSource) |
| 65 self._server_instance = server_instance | 65 self._server_instance = server_instance |
| 66 self._request = request | 66 self._request = request |
| 67 | 67 |
| 68 @Cache | 68 @Cache |
| 69 @SingleFile | 69 @SingleFile |
| 70 @Unicode | 70 @Unicode |
| 71 def _CreateSidenavDict(self, _, content): | 71 def _CreateSidenavDict(self, _, content): |
| 72 items = Parse(content) | 72 items = Parse(content) |
| (...skipping 25 matching lines...) Expand all Loading... |
| 98 | 98 |
| 99 def get(self, key): | 99 def get(self, key): |
| 100 # TODO(mangini/kalman): Use |key| to decide which sidenav to use, | 100 # TODO(mangini/kalman): Use |key| to decide which sidenav to use, |
| 101 # which will require a more complex Cron method. | 101 # which will require a more complex Cron method. |
| 102 sidenav = self._cache.GetFromFile( | 102 sidenav = self._cache.GetFromFile( |
| 103 posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')).Get() | 103 posixpath.join(JSON_TEMPLATES, 'chrome_sidenav.json')).Get() |
| 104 sidenav = copy.deepcopy(sidenav) | 104 sidenav = copy.deepcopy(sidenav) |
| 105 _AddAnnotations(sidenav, | 105 _AddAnnotations(sidenav, |
| 106 self._server_instance.base_path + self._request.path) | 106 self._server_instance.base_path + self._request.path) |
| 107 return sidenav | 107 return sidenav |
| OLD | NEW |