| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_scan_result_dialog_
views.h" | 5 #include "chrome/browser/ui/views/extensions/media_galleries_scan_result_dialog_
views.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/views/constrained_window_views.h" |
| 7 #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h" | 8 #include "chrome/browser/ui/views/extensions/media_gallery_checkbox_view.h" |
| 8 #include "components/web_modal/web_contents_modal_dialog_host.h" | |
| 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 9 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | |
| 11 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 12 #include "grit/generated_resources.h" | 11 #include "grit/generated_resources.h" |
| 13 #include "grit/locale_settings.h" | 12 #include "grit/locale_settings.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 15 #include "ui/views/border.h" | 14 #include "ui/views/border.h" |
| 16 #include "ui/views/controls/button/checkbox.h" | 15 #include "ui/views/controls/button/checkbox.h" |
| 17 #include "ui/views/controls/button/image_button.h" | 16 #include "ui/views/controls/button/image_button.h" |
| 18 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
| 19 #include "ui/views/controls/menu/menu_runner.h" | 18 #include "ui/views/controls/menu/menu_runner.h" |
| 20 #include "ui/views/controls/scroll_view.h" | 19 #include "ui/views/controls/scroll_view.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 SetBounds(x(), y(), width, height); | 54 SetBounds(x(), y(), width, height); |
| 56 | 55 |
| 57 views::View::Layout(); | 56 views::View::Layout(); |
| 58 } | 57 } |
| 59 | 58 |
| 60 } // namespace | 59 } // namespace |
| 61 | 60 |
| 62 MediaGalleriesScanResultDialogViews::MediaGalleriesScanResultDialogViews( | 61 MediaGalleriesScanResultDialogViews::MediaGalleriesScanResultDialogViews( |
| 63 MediaGalleriesScanResultDialogController* controller) | 62 MediaGalleriesScanResultDialogController* controller) |
| 64 : controller_(controller), | 63 : controller_(controller), |
| 65 window_(NULL), | |
| 66 contents_(new views::View()), | 64 contents_(new views::View()), |
| 67 accepted_(false) { | 65 accepted_(false) { |
| 68 InitChildViews(); | 66 InitChildViews(); |
| 69 | 67 ShowWebModalDialogViews(this, controller->web_contents()); |
| 70 // Ownership of |contents_| is handed off by this call. |window_| will take | |
| 71 // care of deleting itself after calling DeleteDelegate(). | |
| 72 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = | |
| 73 web_modal::WebContentsModalDialogManager::FromWebContents( | |
| 74 controller->web_contents()); | |
| 75 DCHECK(web_contents_modal_dialog_manager); | |
| 76 web_modal::WebContentsModalDialogManagerDelegate* modal_delegate = | |
| 77 web_contents_modal_dialog_manager->delegate(); | |
| 78 DCHECK(modal_delegate); | |
| 79 window_ = views::Widget::CreateWindowAsFramelessChild( | |
| 80 this, modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); | |
| 81 web_contents_modal_dialog_manager->ShowModalDialog( | |
| 82 window_->GetNativeView()); | |
| 83 } | 68 } |
| 84 | 69 |
| 85 MediaGalleriesScanResultDialogViews::~MediaGalleriesScanResultDialogViews() {} | 70 MediaGalleriesScanResultDialogViews::~MediaGalleriesScanResultDialogViews() {} |
| 86 | 71 |
| 87 void MediaGalleriesScanResultDialogViews::InitChildViews() { | 72 void MediaGalleriesScanResultDialogViews::InitChildViews() { |
| 88 // Outer dialog layout. | 73 // Outer dialog layout. |
| 89 contents_->RemoveAllChildViews(true); | 74 contents_->RemoveAllChildViews(true); |
| 90 int dialog_content_width = views::Widget::GetLocalizedContentsWidth( | 75 int dialog_content_width = views::Widget::GetLocalizedContentsWidth( |
| 91 IDS_MEDIA_GALLERIES_DIALOG_CONTENT_WIDTH_CHARS); | 76 IDS_MEDIA_GALLERIES_DIALOG_CONTENT_WIDTH_CHARS); |
| 92 views::GridLayout* layout = views::GridLayout::CreatePanel(contents_); | 77 views::GridLayout* layout = views::GridLayout::CreatePanel(contents_); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 } | 192 } |
| 208 | 193 |
| 209 base::string16 MediaGalleriesScanResultDialogViews::GetDialogButtonLabel( | 194 base::string16 MediaGalleriesScanResultDialogViews::GetDialogButtonLabel( |
| 210 ui::DialogButton button) const { | 195 ui::DialogButton button) const { |
| 211 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? | 196 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? |
| 212 IDS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_CONFIRM : | 197 IDS_MEDIA_GALLERIES_SCAN_RESULT_DIALOG_CONFIRM : |
| 213 IDS_MEDIA_GALLERIES_DIALOG_CANCEL); | 198 IDS_MEDIA_GALLERIES_DIALOG_CANCEL); |
| 214 } | 199 } |
| 215 | 200 |
| 216 ui::ModalType MediaGalleriesScanResultDialogViews::GetModalType() const { | 201 ui::ModalType MediaGalleriesScanResultDialogViews::GetModalType() const { |
| 217 #if defined(USE_ASH) | |
| 218 return ui::MODAL_TYPE_CHILD; | 202 return ui::MODAL_TYPE_CHILD; |
| 219 #else | |
| 220 return views::WidgetDelegate::GetModalType(); | |
| 221 #endif | |
| 222 } | 203 } |
| 223 | 204 |
| 224 bool MediaGalleriesScanResultDialogViews::Cancel() { | 205 bool MediaGalleriesScanResultDialogViews::Cancel() { |
| 225 return true; | 206 return true; |
| 226 } | 207 } |
| 227 | 208 |
| 228 bool MediaGalleriesScanResultDialogViews::Accept() { | 209 bool MediaGalleriesScanResultDialogViews::Accept() { |
| 229 accepted_ = true; | 210 accepted_ = true; |
| 230 | |
| 231 return true; | 211 return true; |
| 232 } | 212 } |
| 233 | 213 |
| 234 void MediaGalleriesScanResultDialogViews::ButtonPressed( | 214 void MediaGalleriesScanResultDialogViews::ButtonPressed( |
| 235 views::Button* sender, | 215 views::Button* sender, |
| 236 const ui::Event& event) { | 216 const ui::Event& event) { |
| 237 GetWidget()->client_view()->AsDialogClientView()->UpdateDialogButtons(); | 217 GetWidget()->client_view()->AsDialogClientView()->UpdateDialogButtons(); |
| 238 | 218 |
| 239 for (GalleryViewMap::const_iterator it = gallery_view_map_.begin(); | 219 for (GalleryViewMap::const_iterator it = gallery_view_map_.begin(); |
| 240 it != gallery_view_map_.end(); ++it) { | 220 it != gallery_view_map_.end(); ++it) { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 web_contents_modal_dialog_manager).CloseAllDialogs(); | 274 web_contents_modal_dialog_manager).CloseAllDialogs(); |
| 295 } | 275 } |
| 296 | 276 |
| 297 // MediaGalleriesScanResultDialogViewsController ------------------------------- | 277 // MediaGalleriesScanResultDialogViewsController ------------------------------- |
| 298 | 278 |
| 299 // static | 279 // static |
| 300 MediaGalleriesScanResultDialog* MediaGalleriesScanResultDialog::Create( | 280 MediaGalleriesScanResultDialog* MediaGalleriesScanResultDialog::Create( |
| 301 MediaGalleriesScanResultDialogController* controller) { | 281 MediaGalleriesScanResultDialogController* controller) { |
| 302 return new MediaGalleriesScanResultDialogViews(controller); | 282 return new MediaGalleriesScanResultDialogViews(controller); |
| 303 } | 283 } |
| OLD | NEW |