1/*
2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 *     * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *     * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 *     * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31/**
32 * @constructor
33 * @extends {WebInspector.Object}
34 */
35WebInspector.FileManager = function()
36{
37}
38
39WebInspector.FileManager.EventTypes = {
40    SavedURL: "SavedURL",
41    AppendedToURL: "AppendedToURL"
42}
43
44WebInspector.FileManager.prototype = {
45    /**
46     * @return {boolean}
47     */
48    canSave: function()
49    {
50        return InspectorFrontendHost.canSave();
51    },
52
53    /**
54     * @param {string} url
55     * @param {string} content
56     * @param {boolean} forceSaveAs
57     */
58    save: function(url, content, forceSaveAs)
59    {
60        // Remove this url from the saved URLs while it is being saved.
61        var savedURLs = WebInspector.settings.savedURLs.get();
62        delete savedURLs[url];
63        WebInspector.settings.savedURLs.set(savedURLs);
64        InspectorFrontendHost.save(url, content, forceSaveAs);
65    },
66
67    /**
68     * @param {string} url
69     */
70    savedURL: function(url)
71    {
72        var savedURLs = WebInspector.settings.savedURLs.get();
73        savedURLs[url] = true;
74        WebInspector.settings.savedURLs.set(savedURLs);
75        this.dispatchEventToListeners(WebInspector.FileManager.EventTypes.SavedURL, url);
76    },
77
78    /**
79     * @param {string} url
80     * @return {boolean}
81     */
82    isURLSaved: function(url)
83    {
84        var savedURLs = WebInspector.settings.savedURLs.get();
85        return savedURLs[url];
86    },
87
88    /**
89     * @param {string} url
90     * @param {string} content
91     */
92    append: function(url, content)
93    {
94        InspectorFrontendHost.append(url, content);
95    },
96
97    /**
98     * @param {string} url
99     */
100    close: function(url)
101    {
102        InspectorFrontendHost.close(url);
103    },
104
105    /**
106     * @param {string} url
107     */
108    appendedToURL: function(url)
109    {
110        this.dispatchEventToListeners(WebInspector.FileManager.EventTypes.AppendedToURL, url);
111    },
112
113    __proto__: WebInspector.Object.prototype
114}
115
116WebInspector.fileManager = new WebInspector.FileManager();
117