Home | History | Annotate | Download | only in extensions
      1 // Copyright (c) 2011 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_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
      6 #define CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
      7 #pragma once
      8 
      9 #include <string>
     10 #include <vector>
     11 
     12 #include "base/basictypes.h"
     13 #include "chrome/common/extensions/url_pattern.h"
     14 #include "googleurl/src/gurl.h"
     15 
     16 class URLPattern;
     17 
     18 // FileBrowserHandler encapsulates the state of a file browser action.
     19 class FileBrowserHandler {
     20  public:
     21   typedef std::vector<URLPattern> PatternList;
     22 
     23   FileBrowserHandler();
     24   ~FileBrowserHandler();
     25 
     26   // extension id
     27   std::string extension_id() const { return extension_id_; }
     28   void set_extension_id(const std::string& extension_id) {
     29     extension_id_ = extension_id;
     30   }
     31 
     32   // action id
     33   const std::string& id() const { return id_; }
     34   void set_id(const std::string& id) { id_ = id; }
     35 
     36   // default title
     37   const std::string& title() const { return title_; }
     38   void set_title(const std::string& title) { title_ = title; }
     39 
     40   // File schema URL patterns.
     41   const PatternList& file_url_patterns() const { return patterns_; }
     42   void AddPattern(const URLPattern& pattern);
     43   bool MatchesURL(const GURL& url) const;
     44   void ClearPatterns();
     45 
     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;
     50   }
     51 
     52  private:
     53   // The id for the extension this action belongs to (as defined in the
     54   // extension manifest).
     55   std::string extension_id_;
     56   std::string title_;
     57   std::string default_icon_path_;
     58   // The id for the FileBrowserHandler, for example: "PdfFileAction".
     59   std::string id_;
     60   // A list of file filters.
     61   PatternList patterns_;
     62 };
     63 
     64 #endif  // CHROME_COMMON_EXTENSIONS_FILE_BROWSER_HANDLER_H_
     65