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_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_
      6 #define CHROME_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_
      7 #pragma once
      8 
      9 #include "base/file_path.h"
     10 #include "chrome/browser/ui/shell_dialogs.h"
     11 #include "googleurl/src/gurl.h"
     12 
     13 class Profile;
     14 
     15 // Helper class for wiring file browser component extension with the rest of UI.
     16 class FileManagerUtil {
     17  public:
     18   // Gets base file browser url.
     19   static GURL GetFileBrowserUrl();
     20   // Converts |full_file_path| into external filesystem: url. Returns false
     21   // if |full_file_path| is not managed by the external filesystem provider.
     22   static bool ConvertFileToFileSystemUrl(Profile* profile,
     23       const FilePath& full_file_path, const GURL& origin_url, GURL* url);
     24   // Gets base file browser url for.
     25   static GURL GetFileBrowserUrlWithParams(
     26       SelectFileDialog::Type type,
     27       const string16& title,
     28       const FilePath& default_path,
     29       const SelectFileDialog::FileTypeInfo* file_types,
     30       int file_type_index,
     31       const FilePath::StringType& default_extension);
     32 
     33   // Opens file browser UI in its own tab on file system location defined with
     34   // |default_path|.
     35   static void ShowFullTabUrl(Profile* profile,
     36                              const FilePath& default_path);
     37 
     38   static void ViewItem(const FilePath& full_path, bool enqueue);
     39 
     40  private:
     41   FileManagerUtil() {}
     42   // Helper to convert numeric dialog type to a string.
     43   static std::string GetDialogTypeAsString(SelectFileDialog::Type dialog_type);
     44   // Help to convert potential dialog arguments into json.
     45   static std::string GetArgumentsJson(
     46       SelectFileDialog::Type type,
     47       const string16& title,
     48       const FilePath& default_path,
     49       const SelectFileDialog::FileTypeInfo* file_types,
     50       int file_type_index,
     51       const FilePath::StringType& default_extension);
     52 
     53   DISALLOW_COPY_AND_ASSIGN(FileManagerUtil);
     54 };
     55 
     56 #endif  // CHROME_BROWSER_EXTENSIONS_FILE_MANAGER_UTIL_H_
     57