Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / download / save_package_file_picker.h
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.
4
5 #ifndef CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_
6 #define CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_
7
8 #include <vector>
9
10 #include "base/memory/ref_counted.h"
11 #include "content/public/browser/download_manager_delegate.h"
12 #include "content/public/browser/save_page_type.h"
13 #include "ui/shell_dialogs/select_file_dialog.h"
14
15 class DownloadPrefs;
16
17 // Handles showing a dialog to the user to ask for the filename to save a page.
18 class SavePackageFilePicker : public ui::SelectFileDialog::Listener {
19  public:
20   SavePackageFilePicker(
21       content::WebContents* web_contents,
22       const base::FilePath& suggested_path,
23       const base::FilePath::StringType& default_extension,
24       bool can_save_as_complete,
25       DownloadPrefs* download_prefs,
26       const content::SavePackagePathPickedCallback& callback);
27   ~SavePackageFilePicker() override;
28
29   // Used to disable prompting the user for a directory/filename of the saved
30   // web page.  This is available for testing.
31   static void SetShouldPromptUser(bool should_prompt);
32
33  private:
34   // SelectFileDialog::Listener implementation.
35   void FileSelected(const base::FilePath& path,
36                     int index,
37                     void* unused_params) override;
38   void FileSelectionCanceled(void* unused_params) override;
39
40   bool ShouldSaveAsMHTML() const;
41
42   // Used to look up the renderer process for this request to get the context.
43   int render_process_id_;
44
45   // Whether the web page can be saved as a complete HTML file.
46   bool can_save_as_complete_;
47
48   DownloadPrefs* download_prefs_;
49
50   content::SavePackagePathPickedCallback callback_;
51
52   std::vector<content::SavePageType> save_types_;
53
54   // For managing select file dialogs.
55   scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
56
57   DISALLOW_COPY_AND_ASSIGN(SavePackageFilePicker);
58 };
59
60 #endif  // CHROME_BROWSER_DOWNLOAD_SAVE_PACKAGE_FILE_PICKER_H_