summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 03:09:00 +0000
committerjamescook@chromium.org <jamescook@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-02-07 03:09:00 +0000
commit38d1e3042ce826f717420eea4da56b9e6a5ea1c6 (patch)
treed9d43ae8607f7b7daa2bb8dd7eb60289dfa1f7a4
parenteb769aa29d226c499e9089788b9c992a802bbd71 (diff)
downloadchromium_src-38d1e3042ce826f717420eea4da56b9e6a5ea1c6.zip
chromium_src-38d1e3042ce826f717420eea4da56b9e6a5ea1c6.tar.gz
chromium_src-38d1e3042ce826f717420eea4da56b9e6a5ea1c6.tar.bz2
Fix crash when opening media gallery settings
The return value of SelectFileDialog::Create must be stored in a scoped_refptr. Updated header comment to make this more clear. BUG=174552 TEST=manual, see bug TBR=ben@chromium.org for changing a comment in ui/shell_dialogs Review URL: https://chromiumcodereview.appspot.com/12209043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@181167 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/webui/options/media_galleries_handler.cc21
-rw-r--r--chrome/browser/ui/webui/options/media_galleries_handler.h3
-rw-r--r--ui/shell_dialogs/select_file_dialog.h6
3 files changed, 18 insertions, 12 deletions
diff --git a/chrome/browser/ui/webui/options/media_galleries_handler.cc b/chrome/browser/ui/webui/options/media_galleries_handler.cc
index 5f6032c..a4632f0 100644
--- a/chrome/browser/ui/webui/options/media_galleries_handler.cc
+++ b/chrome/browser/ui/webui/options/media_galleries_handler.cc
@@ -30,6 +30,8 @@ MediaGalleriesHandler::MediaGalleriesHandler() {
}
MediaGalleriesHandler::~MediaGalleriesHandler() {
+ if (select_file_dialog_.get())
+ select_file_dialog_->ListenerDestroyed();
}
void MediaGalleriesHandler::GetLocalizedValues(DictionaryValue* values) {
@@ -98,17 +100,18 @@ void MediaGalleriesHandler::OnGalleriesChanged() {
}
void MediaGalleriesHandler::HandleAddNewGallery(const base::ListValue* args) {
- ui::SelectFileDialog* dialog = ui::SelectFileDialog::Create(
+ select_file_dialog_ = ui::SelectFileDialog::Create(
this,
new ChromeSelectFilePolicy(web_ui()->GetWebContents()));
- dialog->SelectFile(ui::SelectFileDialog::SELECT_FOLDER,
- string16(), // TODO(estade): a name for the dialog?
- FilePath(),
- NULL, 0,
- FilePath::StringType(),
- web_ui()->GetWebContents()->GetView()->
- GetTopLevelNativeWindow(),
- NULL);
+ select_file_dialog_->SelectFile(
+ ui::SelectFileDialog::SELECT_FOLDER,
+ string16(), // TODO(estade): a name for the dialog?
+ FilePath(),
+ NULL, 0,
+ FilePath::StringType(),
+ web_ui()->GetWebContents()->GetView()->
+ GetTopLevelNativeWindow(),
+ NULL);
}
void MediaGalleriesHandler::HandleForgetGallery(const base::ListValue* args) {
diff --git a/chrome/browser/ui/webui/options/media_galleries_handler.h b/chrome/browser/ui/webui/options/media_galleries_handler.h
index be56fdd..16ca5eb 100644
--- a/chrome/browser/ui/webui/options/media_galleries_handler.h
+++ b/chrome/browser/ui/webui/options/media_galleries_handler.h
@@ -5,6 +5,7 @@
#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_GALLERIES_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_OPTIONS_MEDIA_GALLERIES_HANDLER_H_
+#include "base/memory/ref_counted.h"
#include "base/prefs/public/pref_change_registrar.h"
#include "chrome/browser/ui/webui/options/options_ui.h"
#include "content/public/browser/notification_observer.h"
@@ -41,6 +42,8 @@ class MediaGalleriesHandler : public OptionsPageUIHandler,
PrefChangeRegistrar pref_change_registrar_;
+ scoped_refptr<ui::SelectFileDialog> select_file_dialog_;
+
DISALLOW_COPY_AND_ASSIGN(MediaGalleriesHandler);
};
diff --git a/ui/shell_dialogs/select_file_dialog.h b/ui/shell_dialogs/select_file_dialog.h
index 762e885..8500150 100644
--- a/ui/shell_dialogs/select_file_dialog.h
+++ b/ui/shell_dialogs/select_file_dialog.h
@@ -89,9 +89,9 @@ class SHELL_DIALOGS_EXPORT SelectFileDialog
// a dependency on chrome's extension system.)
static void SetFactory(ui::SelectFileDialogFactory* factory);
- // Creates a dialog box helper. This object is ref-counted, but the returned
- // object will have no reference (refcount is 0). |policy| is an optional
- // class that can prevent showing a dialog.
+ // Creates a dialog box helper. The returned object is ref-counted, starts
+ // with a ref-count of 0, and should be stored in a scoped_refptr<>.
+ // |policy| is an optional class that can prevent showing a dialog.
static SelectFileDialog* Create(Listener* listener,
ui::SelectFilePolicy* policy);