Extract SIGPIPE ignoring code to a common place.
[chromium-blink-merge.git] / chrome / common / extensions / file_browser_handler.h
blobceef073ce60a0e44903339ece40eeb1e8275d95a
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.
5 #ifndef CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
6 #define CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "chrome/common/extensions/url_pattern_set.h"
13 #include "extensions/common/url_pattern.h"
14 #include "googleurl/src/gurl.h"
16 class URLPattern;
18 // FileBrowserHandler encapsulates the state of a file browser action.
19 class FileBrowserHandler {
20 public:
21 FileBrowserHandler();
22 ~FileBrowserHandler();
24 // extension id
25 std::string extension_id() const { return extension_id_; }
26 void set_extension_id(const std::string& extension_id) {
27 extension_id_ = extension_id;
30 // action id
31 const std::string& id() const { return id_; }
32 void set_id(const std::string& id) { id_ = id; }
34 // default title
35 const std::string& title() const { return title_; }
36 void set_title(const std::string& title) { title_ = title; }
38 // File schema URL patterns.
39 const URLPatternSet& file_url_patterns() const {
40 return url_set_;
42 void AddPattern(const URLPattern& pattern);
43 bool MatchesURL(const GURL& url) const;
44 void ClearPatterns();
46 // Action icon path.
47 const std::string icon_path() const { return default_icon_path_; }
48 void set_icon_path(const std::string& path) {
49 default_icon_path_ = path;
52 // File access permissions.
53 // Adjusts file_access_permission_flags_ to allow specified permission.
54 bool AddFileAccessPermission(const std::string& permission_str);
55 // Checks that specified file access permissions are valid (all set
56 // permissions are valid and there is no other permission specified with
57 // "create")
58 // If no access permissions were set, initialize them to default value.
59 bool ValidateFileAccessPermissions();
60 // Checks if handler has read access.
61 bool CanRead() const;
62 // Checks if handler has write access.
63 bool CanWrite() const;
64 // Checks if handler has "create" access specified.
65 bool HasCreateAccessPermission() const;
67 private:
68 // The id for the extension this action belongs to (as defined in the
69 // extension manifest).
70 std::string extension_id_;
71 std::string title_;
72 std::string default_icon_path_;
73 // The id for the FileBrowserHandler, for example: "PdfFileAction".
74 std::string id_;
75 unsigned int file_access_permission_flags_;
77 // A list of file filters.
78 URLPatternSet url_set_;
81 #endif // CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_