| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_DEBUGGER_DEVTOOLS_FILE_HELPER_H_ | |
| 6 #define CHROME_BROWSER_DEBUGGER_DEVTOOLS_FILE_HELPER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 | |
| 14 class FilePath; | |
| 15 class Profile; | |
| 16 | |
| 17 class DevToolsFileHelper { | |
| 18 public: | |
| 19 class Delegate { | |
| 20 public: | |
| 21 virtual ~Delegate() {} | |
| 22 virtual void FileSavedAs(const std::string& url) = 0; | |
| 23 virtual void AppendedTo(const std::string& url) = 0; | |
| 24 }; | |
| 25 | |
| 26 DevToolsFileHelper(Profile* profile, Delegate* delegate); | |
| 27 ~DevToolsFileHelper(); | |
| 28 | |
| 29 // Saves |content| to the file and associates its path with given |url|. | |
| 30 // If client is calling this method with given |url| for the first time | |
| 31 // or |save_as| is true, confirmation dialog is shown to the user. | |
| 32 void Save(const std::string& url, | |
| 33 const std::string& content, | |
| 34 bool save_as); | |
| 35 | |
| 36 // Append |content| to the file that has been associated with given |url|. | |
| 37 // The |url| can be associated with a file via calling Save method. | |
| 38 // If the Save method has not been called for this |url|, then | |
| 39 // Append method does nothing. | |
| 40 void Append(const std::string& url, const std::string& content); | |
| 41 | |
| 42 void FileSelected(const std::string& url, | |
| 43 const FilePath& path, | |
| 44 const std::string& content); | |
| 45 | |
| 46 private: | |
| 47 static void WriteFile(const FilePath& path, const std::string& content); | |
| 48 static void AppendToFile(const FilePath& path, const std::string& content); | |
| 49 | |
| 50 class SaveAsDialog; | |
| 51 | |
| 52 Profile* profile_; | |
| 53 Delegate* delegate_; | |
| 54 scoped_refptr<SaveAsDialog> save_as_dialog_; | |
| 55 typedef std::map<std::string, FilePath> PathsMap; | |
| 56 PathsMap saved_files_; | |
| 57 DISALLOW_COPY_AND_ASSIGN(DevToolsFileHelper); | |
| 58 }; | |
| 59 | |
| 60 #endif // CHROME_BROWSER_DEBUGGER_DEVTOOLS_FILE_HELPER_H_ | |
| OLD | NEW |