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_
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"
18 // FileBrowserHandler encapsulates the state of a file browser action.
19 class FileBrowserHandler
{
22 ~FileBrowserHandler();
25 std::string
extension_id() const { return extension_id_
; }
26 void set_extension_id(const std::string
& extension_id
) {
27 extension_id_
= extension_id
;
31 const std::string
& id() const { return id_
; }
32 void set_id(const std::string
& id
) { id_
= id
; }
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 {
42 void AddPattern(const URLPattern
& pattern
);
43 bool MatchesURL(const GURL
& url
) const;
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
58 // If no access permissions were set, initialize them to default value.
59 bool ValidateFileAccessPermissions();
60 // Checks if handler has read access.
62 // Checks if handler has write access.
63 bool CanWrite() const;
64 // Checks if handler has "create" access specified.
65 bool HasCreateAccessPermission() const;
68 // The id for the extension this action belongs to (as defined in the
69 // extension manifest).
70 std::string extension_id_
;
72 std::string default_icon_path_
;
73 // The id for the FileBrowserHandler, for example: "PdfFileAction".
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_