Chromium Code Reviews| Index: chrome/browser/ui/views/importer/import_lock_dialog_view.cc |
| diff --git a/chrome/browser/ui/views/importer/import_lock_dialog_view.cc b/chrome/browser/ui/views/importer/import_lock_dialog_view.cc |
| index 71392b5908635fdeeced6d4f8fab2bd1cf316843..0876c0172cf252a0b310a29950e073ed13b5c8ce 100644 |
| --- a/chrome/browser/ui/views/importer/import_lock_dialog_view.cc |
| +++ b/chrome/browser/ui/views/importer/import_lock_dialog_view.cc |
| @@ -30,13 +30,32 @@ void ShowImportLockDialog(gfx::NativeWindow parent, |
| base::RecordAction(UserMetricsAction("ImportLockDialogView_Shown")); |
| } |
| +void HideImportLockDialog() { |
| + ImportLockDialogView::Hide(); |
| +} |
| + |
| } // namespace importer |
| +// For storing widget ptr on creation of dialog widget |
| +// using method CreateDialogWidget. |
| +namespace { |
| +static views::Widget* g_widget = nullptr; |
| +} |
| + |
| +// static |
| +void ImportLockDialogView::Hide() { |
| + if (g_widget) { |
| + g_widget->Close(); |
| + g_widget = nullptr; |
| + } |
| +} |
| + |
| // static |
| void ImportLockDialogView::Show(gfx::NativeWindow parent, |
| const base::Callback<void(bool)>& callback) { |
| - views::DialogDelegate::CreateDialogWidget( |
| - new ImportLockDialogView(callback), NULL, NULL)->Show(); |
| + g_widget = views::DialogDelegate::CreateDialogWidget( |
| + new ImportLockDialogView(callback), NULL, NULL); |
| + g_widget->Show(); |
| } |
| ImportLockDialogView::ImportLockDialogView( |
| @@ -51,6 +70,7 @@ ImportLockDialogView::ImportLockDialogView( |
| } |
| ImportLockDialogView::~ImportLockDialogView() { |
| + g_widget = nullptr; |
|
nikhil.sahni
2017/04/03 13:05:11
Even Destructor is called on Exiting so added chec
|
| } |
| gfx::Size ImportLockDialogView::GetPreferredSize() const { |
| @@ -80,11 +100,13 @@ base::string16 ImportLockDialogView::GetWindowTitle() const { |
| bool ImportLockDialogView::Accept() { |
| base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| base::Bind(callback_, true)); |
| + g_widget = nullptr; |
|
nikhil.sahni
2017/04/03 13:05:11
On Pressing "Continue" this function gets called s
|
| return true; |
| } |
| bool ImportLockDialogView::Cancel() { |
| base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, |
| base::Bind(callback_, false)); |
| + g_widget = nullptr; |
|
nikhil.sahni
2017/04/03 13:05:11
On pressing "Skip Import" and "Cross Button of the
|
| return true; |
| } |