Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: chrome/browser/ui/views/select_file_dialog_extension.h

Issue 9360005: Handle termination/crashes of an extension hosted in the ExtensionDialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "chrome/browser/ui/select_file_dialog.h" 13 #include "chrome/browser/ui/select_file_dialog.h"
14 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h" 14 #include "chrome/browser/ui/views/extensions/extension_dialog_observer.h"
15 #include "ui/gfx/native_widget_types.h" // gfx::NativeWindow 15 #include "ui/gfx/native_widget_types.h" // gfx::NativeWindow
16 16
17 class Browser;
17 class ExtensionDialog; 18 class ExtensionDialog;
18 class RenderViewHost; 19 class RenderViewHost;
19 20
20 // Shows a dialog box for selecting a file or a folder, using the 21 // Shows a dialog box for selecting a file or a folder, using the
21 // file manager extension implementation. 22 // file manager extension implementation.
22 class SelectFileDialogExtension 23 class SelectFileDialogExtension
23 : public SelectFileDialog, 24 : public SelectFileDialog,
24 public ExtensionDialogObserver { 25 public ExtensionDialogObserver {
25 public: 26 public:
26 static SelectFileDialogExtension* Create( 27 static SelectFileDialogExtension* Create(
27 SelectFileDialog::Listener* listener); 28 SelectFileDialog::Listener* listener);
28 29
29 // BaseShellDialog implementation. 30 // BaseShellDialog implementation.
30 virtual bool IsRunning(gfx::NativeWindow owner_window) const OVERRIDE; 31 virtual bool IsRunning(gfx::NativeWindow owner_window) const OVERRIDE;
31 virtual void ListenerDestroyed() OVERRIDE; 32 virtual void ListenerDestroyed() OVERRIDE;
32 33
33 // ExtensionDialog::Observer implementation. 34 // ExtensionDialog::Observer implementation.
34 virtual void ExtensionDialogClosing(ExtensionDialog* dialog) OVERRIDE; 35 virtual void ExtensionDialogClosing(ExtensionDialog* dialog) OVERRIDE;
36 virtual void ExtensionTerminated(ExtensionDialog* dialog) OVERRIDE;
35 37
36 // Routes callback to appropriate SelectFileDialog::Listener based on 38 // Routes callback to appropriate SelectFileDialog::Listener based on
37 // the owning |tab_id|. 39 // the owning |tab_id|.
38 static void OnFileSelected(int32 tab_id, const FilePath& path, int index); 40 static void OnFileSelected(int32 tab_id, const FilePath& path, int index);
39 static void OnMultiFilesSelected(int32 tab_id, 41 static void OnMultiFilesSelected(int32 tab_id,
40 const std::vector<FilePath>& files); 42 const std::vector<FilePath>& files);
41 static void OnFileSelectionCanceled(int32 tab_id); 43 static void OnFileSelectionCanceled(int32 tab_id);
42 44
43 // For testing, so we can inject JavaScript into the contained view. 45 // For testing, so we can inject JavaScript into the contained view.
44 RenderViewHost* GetRenderViewHost(); 46 RenderViewHost* GetRenderViewHost();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE; 78 virtual bool HasMultipleFileTypeChoicesImpl() OVERRIDE;
77 79
78 bool has_multiple_file_type_choices_; 80 bool has_multiple_file_type_choices_;
79 81
80 // Host for the extension that implements this dialog. 82 // Host for the extension that implements this dialog.
81 scoped_refptr<ExtensionDialog> extension_dialog_; 83 scoped_refptr<ExtensionDialog> extension_dialog_;
82 84
83 // ID of the tab that spawned this dialog, used to route callbacks. 85 // ID of the tab that spawned this dialog, used to route callbacks.
84 int32 tab_id_; 86 int32 tab_id_;
85 87
88 // Cache a pointer to our owner browser. Since we're a child window of our
89 // owner browser, if this browser gets deleted, it will also close us.
90 Browser* owner_browser_;
91
86 gfx::NativeWindow owner_window_; 92 gfx::NativeWindow owner_window_;
87 93
88 // We defer the callback into SelectFileDialog::Listener until the window 94 // We defer the callback into SelectFileDialog::Listener until the window
89 // closes, to match the semantics of file selection on Windows and Mac. 95 // closes, to match the semantics of file selection on Windows and Mac.
90 // These are the data passed to the listener. 96 // These are the data passed to the listener.
91 enum SelectionType { 97 enum SelectionType {
92 CANCEL = 0, 98 CANCEL = 0,
93 SINGLE_FILE, 99 SINGLE_FILE,
94 MULTIPLE_FILES 100 MULTIPLE_FILES
95 }; 101 };
96 SelectionType selection_type_; 102 SelectionType selection_type_;
97 std::vector<FilePath> selection_files_; 103 std::vector<FilePath> selection_files_;
98 int selection_index_; 104 int selection_index_;
99 void* params_; 105 void* params_;
100 106
101 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogExtension); 107 DISALLOW_COPY_AND_ASSIGN(SelectFileDialogExtension);
102 }; 108 };
103 109
104 #endif // CHROME_BROWSER_UI_VIEWS_SELECT_FILE_DIALOG_EXTENSION_H_ 110 #endif // CHROME_BROWSER_UI_VIEWS_SELECT_FILE_DIALOG_EXTENSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698