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 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ |
6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ | 6 #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <queue> | 9 #include <queue> |
10 #include <string> | 10 #include <string> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 public: | 50 public: |
51 explicit FileBrowserPrivateAPI(Profile* profile); | 51 explicit FileBrowserPrivateAPI(Profile* profile); |
52 virtual ~FileBrowserPrivateAPI(); | 52 virtual ~FileBrowserPrivateAPI(); |
53 | 53 |
54 // ProfileKeyedService overrides. | 54 // ProfileKeyedService overrides. |
55 virtual void Shutdown() OVERRIDE; | 55 virtual void Shutdown() OVERRIDE; |
56 | 56 |
57 // Convenience function to return the FileBrowserPrivateAPI for a Profile. | 57 // Convenience function to return the FileBrowserPrivateAPI for a Profile. |
58 static FileBrowserPrivateAPI* Get(Profile* profile); | 58 static FileBrowserPrivateAPI* Get(Profile* profile); |
59 | 59 |
60 scoped_refptr<FileBrowserEventRouter> event_router() { | 60 FileBrowserEventRouter* event_router() { |
61 return event_router_; | 61 return event_router_.get(); |
62 } | 62 } |
63 | 63 |
64 private: | 64 private: |
65 scoped_refptr<FileBrowserEventRouter> event_router_; | 65 scoped_ptr<FileBrowserEventRouter> event_router_; |
66 }; | 66 }; |
67 | 67 |
68 // Implements the chrome.fileBrowserPrivate.logoutUser method. | 68 // Implements the chrome.fileBrowserPrivate.logoutUser method. |
69 class LogoutUserFunction : public SyncExtensionFunction { | 69 class LogoutUserFunction : public SyncExtensionFunction { |
70 public: | 70 public: |
71 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.logoutUser", | 71 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.logoutUser", |
72 FILEBROWSERPRIVATE_LOGOUTUSER) | 72 FILEBROWSERPRIVATE_LOGOUTUSER) |
73 | 73 |
74 protected: | 74 protected: |
75 virtual ~LogoutUserFunction() {} | 75 virtual ~LogoutUserFunction() {} |
(...skipping 24 matching lines...) Expand all Loading... |
100 scoped_refptr<fileapi::FileSystemContext> file_system_context, | 100 scoped_refptr<fileapi::FileSystemContext> file_system_context, |
101 const GURL& source_url, | 101 const GURL& source_url, |
102 int child_id); | 102 int child_id); |
103 }; | 103 }; |
104 | 104 |
105 // Implements the chrome.fileBrowserPrivate.addFileWatch method. | 105 // Implements the chrome.fileBrowserPrivate.addFileWatch method. |
106 class FileWatchBrowserFunctionBase : public AsyncExtensionFunction { | 106 class FileWatchBrowserFunctionBase : public AsyncExtensionFunction { |
107 protected: | 107 protected: |
108 virtual ~FileWatchBrowserFunctionBase() {} | 108 virtual ~FileWatchBrowserFunctionBase() {} |
109 | 109 |
110 virtual bool PerformFileWatchOperation( | 110 // Performs a file watch operation (ex. adds or removes a file watch). |
111 scoped_refptr<FileBrowserEventRouter> event_router, | 111 virtual void PerformFileWatchOperation( |
112 const base::FilePath& local_path, const base::FilePath& virtual_path, | 112 const base::FilePath& local_path, |
| 113 const base::FilePath& virtual_path, |
113 const std::string& extension_id) = 0; | 114 const std::string& extension_id) = 0; |
114 | 115 |
115 // AsyncExtensionFunction overrides. | 116 // AsyncExtensionFunction overrides. |
116 virtual bool RunImpl() OVERRIDE; | 117 virtual bool RunImpl() OVERRIDE; |
117 | 118 |
118 private: | 119 // Calls SendResponse() with |success| converted to base::Value. |
119 void RespondOnUIThread(bool success); | 120 void Respond(bool success); |
120 void RunFileWatchOperationOnFileThread( | |
121 scoped_refptr<FileBrowserEventRouter> event_router, | |
122 const fileapi::FileSystemURL& file_url, | |
123 const std::string& extension_id); | |
124 }; | 121 }; |
125 | 122 |
126 // Implements the chrome.fileBrowserPrivate.addFileWatch method. | 123 // Implements the chrome.fileBrowserPrivate.addFileWatch method. |
127 class AddFileWatchBrowserFunction : public FileWatchBrowserFunctionBase { | 124 class AddFileWatchBrowserFunction : public FileWatchBrowserFunctionBase { |
128 public: | 125 public: |
129 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.addFileWatch", | 126 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.addFileWatch", |
130 FILEBROWSERPRIVATE_ADDFILEWATCH) | 127 FILEBROWSERPRIVATE_ADDFILEWATCH) |
131 | 128 |
132 protected: | 129 protected: |
133 virtual ~AddFileWatchBrowserFunction() {} | 130 virtual ~AddFileWatchBrowserFunction() {} |
134 | 131 |
135 virtual bool PerformFileWatchOperation( | 132 // FileWatchBrowserFunctionBase override. |
136 scoped_refptr<FileBrowserEventRouter> event_router, | 133 virtual void PerformFileWatchOperation( |
137 const base::FilePath& local_path, const base::FilePath& virtual_path, | 134 const base::FilePath& local_path, |
| 135 const base::FilePath& virtual_path, |
138 const std::string& extension_id) OVERRIDE; | 136 const std::string& extension_id) OVERRIDE; |
139 }; | 137 }; |
140 | 138 |
141 | 139 |
142 // Implements the chrome.fileBrowserPrivate.removeFileWatch method. | 140 // Implements the chrome.fileBrowserPrivate.removeFileWatch method. |
143 class RemoveFileWatchBrowserFunction : public FileWatchBrowserFunctionBase { | 141 class RemoveFileWatchBrowserFunction : public FileWatchBrowserFunctionBase { |
144 public: | 142 public: |
145 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.removeFileWatch", | 143 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.removeFileWatch", |
146 FILEBROWSERPRIVATE_REMOVEFILEWATCH) | 144 FILEBROWSERPRIVATE_REMOVEFILEWATCH) |
147 | 145 |
148 protected: | 146 protected: |
149 virtual ~RemoveFileWatchBrowserFunction() {} | 147 virtual ~RemoveFileWatchBrowserFunction() {} |
150 | 148 |
151 virtual bool PerformFileWatchOperation( | 149 // FileWatchBrowserFunctionBase override. |
152 scoped_refptr<FileBrowserEventRouter> event_router, | 150 virtual void PerformFileWatchOperation( |
153 const base::FilePath& local_path, const base::FilePath& virtual_path, | 151 const base::FilePath& local_path, |
| 152 const base::FilePath& virtual_path, |
154 const std::string& extension_id) OVERRIDE; | 153 const std::string& extension_id) OVERRIDE; |
155 }; | 154 }; |
156 | 155 |
157 // Implements the chrome.fileBrowserPrivate.getFileTasks method. | 156 // Implements the chrome.fileBrowserPrivate.getFileTasks method. |
158 class GetFileTasksFileBrowserFunction : public AsyncExtensionFunction { | 157 class GetFileTasksFileBrowserFunction : public AsyncExtensionFunction { |
159 public: | 158 public: |
160 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getFileTasks", | 159 DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getFileTasks", |
161 FILEBROWSERPRIVATE_GETFILETASKS) | 160 FILEBROWSERPRIVATE_GETFILETASKS) |
162 | 161 |
163 protected: | 162 protected: |
(...skipping 717 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 OpenNewWindowFunction(); | 880 OpenNewWindowFunction(); |
882 | 881 |
883 protected: | 882 protected: |
884 virtual ~OpenNewWindowFunction(); | 883 virtual ~OpenNewWindowFunction(); |
885 | 884 |
886 // AsyncExtensionFunction overrides. | 885 // AsyncExtensionFunction overrides. |
887 virtual bool RunImpl() OVERRIDE; | 886 virtual bool RunImpl() OVERRIDE; |
888 }; | 887 }; |
889 | 888 |
890 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ | 889 #endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_BROWSER_PRIVATE_API_H_ |
OLD | NEW |