// Copyright 2013 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef EXTENSIONS_BROWSER_FILE_HIGHLIGHTER_H_ #define EXTENSIONS_BROWSER_FILE_HIGHLIGHTER_H_ #include <stddef.h> #include <string> namespace extensions { // The FileHighlighter class is used in order to isolate and highlight a portion // of a given file (in string form). The Highlighter will split the source into // three portions: the portion before the highlighted feature, the highlighted // feature, and the portion following the highlighted feature. // The file will be parsed for highlighting upon construction of the Highlighter // object. class FileHighlighter { … }; // Use the ManifestHighlighter class to find the bounds of a feature in the // manifest. // A feature can be at any level in the hierarchy. The "start" of a feature is // the first character of the feature name, or the beginning quote of the name, // if present. The "end" of a feature is wherever the next item at the same // level starts. // For instance, the bounds for the 'permissions' feature at the top level could // be '"permissions": { "tabs", "history", "downloads" }', but the feature for // 'tabs' within 'permissions' would just be '"tabs"'. // We can't use the JSONParser to do this, because we want to display the actual // manifest, and once we parse it into Values, we lose any formatting the user // may have had. // If a feature cannot be found, the feature will have zero-length. class ManifestHighlighter : public FileHighlighter { … }; // Use the SourceHighlighter to highlight a particular line in a given source // file. class SourceHighlighter : public FileHighlighter { … }; } // namespace extensions #endif // EXTENSIONS_BROWSER_FILE_HIGHLIGHTER_H_