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 #include "chrome/browser/ui/views/extensions/media_galleries_dialog_views.h" | 5 #include "chrome/browser/ui/views/extensions/media_galleries_dialog_views.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/ui/views/constrained_window_views.h" | 8 #include "chrome/browser/ui/views/constrained_window_views.h" |
9 #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h" | 9 #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
10 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
11 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
12 #include "grit/locale_settings.h" | 13 #include "grit/locale_settings.h" |
13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/native_theme/native_theme.h" | 15 #include "ui/native_theme/native_theme.h" |
15 #include "ui/views/border.h" | 16 #include "ui/views/border.h" |
16 #include "ui/views/controls/button/checkbox.h" | 17 #include "ui/views/controls/button/checkbox.h" |
17 #include "ui/views/controls/button/image_button.h" | 18 #include "ui/views/controls/button/image_button.h" |
18 #include "ui/views/controls/button/label_button.h" | 19 #include "ui/views/controls/button/label_button.h" |
19 #include "ui/views/controls/label.h" | 20 #include "ui/views/controls/label.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 InitChildViews(); | 69 InitChildViews(); |
69 if (ControllerHasWebContents()) | 70 if (ControllerHasWebContents()) |
70 ShowWebModalDialogViews(this, controller->WebContents()); | 71 ShowWebModalDialogViews(this, controller->WebContents()); |
71 } | 72 } |
72 | 73 |
73 MediaGalleriesDialogViews::~MediaGalleriesDialogViews() { | 74 MediaGalleriesDialogViews::~MediaGalleriesDialogViews() { |
74 if (!ControllerHasWebContents()) | 75 if (!ControllerHasWebContents()) |
75 delete contents_; | 76 delete contents_; |
76 } | 77 } |
77 | 78 |
| 79 void MediaGalleriesDialogViews::AcceptDialogForTesting() { |
| 80 accepted_ = true; |
| 81 |
| 82 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 83 web_modal::WebContentsModalDialogManager::FromWebContents( |
| 84 controller_->WebContents()); |
| 85 DCHECK(web_contents_modal_dialog_manager); |
| 86 web_modal::WebContentsModalDialogManager::TestApi( |
| 87 web_contents_modal_dialog_manager).CloseAllDialogs(); |
| 88 } |
| 89 |
78 void MediaGalleriesDialogViews::InitChildViews() { | 90 void MediaGalleriesDialogViews::InitChildViews() { |
79 // Outer dialog layout. | 91 // Outer dialog layout. |
80 contents_->RemoveAllChildViews(true); | 92 contents_->RemoveAllChildViews(true); |
81 checkbox_map_.clear(); | 93 checkbox_map_.clear(); |
82 | 94 |
83 int dialog_content_width = views::Widget::GetLocalizedContentsWidth( | 95 int dialog_content_width = views::Widget::GetLocalizedContentsWidth( |
84 IDS_MEDIA_GALLERIES_DIALOG_CONTENT_WIDTH_CHARS); | 96 IDS_MEDIA_GALLERIES_DIALOG_CONTENT_WIDTH_CHARS); |
85 views::GridLayout* layout = views::GridLayout::CreatePanel(contents_); | 97 views::GridLayout* layout = views::GridLayout::CreatePanel(contents_); |
86 contents_->SetLayoutManager(layout); | 98 contents_->SetLayoutManager(layout); |
87 | 99 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 return controller_->WebContents() != NULL; | 328 return controller_->WebContents() != NULL; |
317 } | 329 } |
318 | 330 |
319 // MediaGalleriesDialogViewsController ----------------------------------------- | 331 // MediaGalleriesDialogViewsController ----------------------------------------- |
320 | 332 |
321 // static | 333 // static |
322 MediaGalleriesDialog* MediaGalleriesDialog::Create( | 334 MediaGalleriesDialog* MediaGalleriesDialog::Create( |
323 MediaGalleriesDialogController* controller) { | 335 MediaGalleriesDialogController* controller) { |
324 return new MediaGalleriesDialogViews(controller); | 336 return new MediaGalleriesDialogViews(controller); |
325 } | 337 } |
OLD | NEW |