| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_SELECT_FILE_DIALOG_EXTENSION_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_SELECT_FILE_DIALOG_EXTENSION_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_SELECT_FILE_DIALOG_EXTENSION_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_SELECT_FILE_DIALOG_EXTENSION_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // every WebContents. | 36 // every WebContents. |
| 37 typedef const void* RoutingID; | 37 typedef const void* RoutingID; |
| 38 static RoutingID GetRoutingIDFromWebContents( | 38 static RoutingID GetRoutingIDFromWebContents( |
| 39 const content::WebContents* web_contents); | 39 const content::WebContents* web_contents); |
| 40 | 40 |
| 41 static SelectFileDialogExtension* Create( | 41 static SelectFileDialogExtension* Create( |
| 42 ui::SelectFileDialog::Listener* listener, | 42 ui::SelectFileDialog::Listener* listener, |
| 43 ui::SelectFilePolicy* policy); | 43 ui::SelectFilePolicy* policy); |
| 44 | 44 |
| 45 // BaseShellDialog implementation. | 45 // BaseShellDialog implementation. |
| 46 virtual bool IsRunning(gfx::NativeWindow owner_window) const OVERRIDE; | 46 virtual bool IsRunning(gfx::NativeWindow owner_window) const override; |
| 47 virtual void ListenerDestroyed() OVERRIDE; | 47 virtual void ListenerDestroyed() override; |
| 48 | 48 |
| 49 // ExtensionDialog::Observer implementation. | 49 // ExtensionDialog::Observer implementation. |
| 50 virtual void ExtensionDialogClosing(ExtensionDialog* dialog) OVERRIDE; | 50 virtual void ExtensionDialogClosing(ExtensionDialog* dialog) override; |
| 51 virtual void ExtensionTerminated(ExtensionDialog* dialog) OVERRIDE; | 51 virtual void ExtensionTerminated(ExtensionDialog* dialog) override; |
| 52 | 52 |
| 53 // Routes callback to appropriate SelectFileDialog::Listener based on the | 53 // Routes callback to appropriate SelectFileDialog::Listener based on the |
| 54 // owning |web_contents|. | 54 // owning |web_contents|. |
| 55 static void OnFileSelected(RoutingID routing_id, | 55 static void OnFileSelected(RoutingID routing_id, |
| 56 const ui::SelectedFileInfo& file, | 56 const ui::SelectedFileInfo& file, |
| 57 int index); | 57 int index); |
| 58 static void OnMultiFilesSelected( | 58 static void OnMultiFilesSelected( |
| 59 RoutingID routing_id, | 59 RoutingID routing_id, |
| 60 const std::vector<ui::SelectedFileInfo>& files); | 60 const std::vector<ui::SelectedFileInfo>& files); |
| 61 static void OnFileSelectionCanceled(RoutingID routing_id); | 61 static void OnFileSelectionCanceled(RoutingID routing_id); |
| 62 | 62 |
| 63 // For testing, so we can inject JavaScript into the contained view. | 63 // For testing, so we can inject JavaScript into the contained view. |
| 64 content::RenderViewHost* GetRenderViewHost(); | 64 content::RenderViewHost* GetRenderViewHost(); |
| 65 | 65 |
| 66 protected: | 66 protected: |
| 67 // SelectFileDialog implementation. | 67 // SelectFileDialog implementation. |
| 68 virtual void SelectFileImpl( | 68 virtual void SelectFileImpl( |
| 69 Type type, | 69 Type type, |
| 70 const base::string16& title, | 70 const base::string16& title, |
| 71 const base::FilePath& default_path, | 71 const base::FilePath& default_path, |
| 72 const FileTypeInfo* file_types, | 72 const FileTypeInfo* file_types, |
| 73 int file_type_index, | 73 int file_type_index, |
| 74 const base::FilePath::StringType& default_extension, | 74 const base::FilePath::StringType& default_extension, |
| 75 gfx::NativeWindow owning_window, | 75 gfx::NativeWindow owning_window, |
| 76 void* params) OVERRIDE; | 76 void* params) override; |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 friend class SelectFileDialogExtensionBrowserTest; | 79 friend class SelectFileDialogExtensionBrowserTest; |
| 80 friend class SelectFileDialogExtensionTest; | 80 friend class SelectFileDialogExtensionTest; |
| 81 | 81 |
| 82 // Object is ref-counted, use Create(). | 82 // Object is ref-counted, use Create(). |
| 83 explicit SelectFileDialogExtension(SelectFileDialog::Listener* listener, | 83 explicit SelectFileDialogExtension(SelectFileDialog::Listener* listener, |
| 84 ui::SelectFilePolicy* policy); | 84 ui::SelectFilePolicy* policy); |
| 85 virtual ~SelectFileDialogExtension(); | 85 virtual ~SelectFileDialogExtension(); |
| 86 | 86 |
| 87 // Invokes the appropriate file selection callback on our listener. | 87 // Invokes the appropriate file selection callback on our listener. |
| 88 void NotifyListener(); | 88 void NotifyListener(); |
| 89 | 89 |
| 90 // Adds this to the list of pending dialogs, used for testing. | 90 // Adds this to the list of pending dialogs, used for testing. |
| 91 void AddPending(RoutingID routing_id); | 91 void AddPending(RoutingID routing_id); |
| 92 | 92 |
| 93 // Check if the list of pending dialogs contains dialog for |routing_id|. | 93 // Check if the list of pending dialogs contains dialog for |routing_id|. |
| 94 static bool PendingExists(RoutingID routing_id); | 94 static bool PendingExists(RoutingID routing_id); |
| 95 | 95 |
| 96 // Returns true if the dialog has multiple file type choices. | 96 // Returns true if the dialog has multiple file type choices. |
| 97 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE; | 97 virtual bool HasMultipleFileTypeChoicesImpl() override; |
| 98 | 98 |
| 99 bool has_multiple_file_type_choices_; | 99 bool has_multiple_file_type_choices_; |
| 100 | 100 |
| 101 // Host for the extension that implements this dialog. | 101 // Host for the extension that implements this dialog. |
| 102 scoped_refptr<ExtensionDialog> extension_dialog_; | 102 scoped_refptr<ExtensionDialog> extension_dialog_; |
| 103 | 103 |
| 104 // ID of the tab that spawned this dialog, used to route callbacks. | 104 // ID of the tab that spawned this dialog, used to route callbacks. |
| 105 RoutingID routing_id_; | 105 RoutingID routing_id_; |
| 106 | 106 |
| 107 // Pointer to the profile the dialog is running in. | 107 // Pointer to the profile the dialog is running in. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 120 }; | 120 }; |
| 121 SelectionType selection_type_; | 121 SelectionType selection_type_; |
| 122 std::vector<ui::SelectedFileInfo> selection_files_; | 122 std::vector<ui::SelectedFileInfo> selection_files_; |
| 123 int selection_index_; | 123 int selection_index_; |
| 124 void* params_; | 124 void* params_; |
| 125 | 125 |
| 126 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogExtension); | 126 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogExtension); |
| 127 }; | 127 }; |
| 128 | 128 |
| 129 #endif // CHROME_BROWSER_UI_VIEWS_SELECT_FILE_DIALOG_EXTENSION_H_ | 129 #endif // CHROME_BROWSER_UI_VIEWS_SELECT_FILE_DIALOG_EXTENSION_H_ |
| OLD | NEW |