| 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 "components/web_modal/web_contents_modal_dialog_manager.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 177 |
| 178 void MediaGalleriesDialogViews::UpdateGalleries() { | 178 void MediaGalleriesDialogViews::UpdateGalleries() { |
| 179 InitChildViews(); | 179 InitChildViews(); |
| 180 contents_->Layout(); | 180 contents_->Layout(); |
| 181 } | 181 } |
| 182 | 182 |
| 183 bool MediaGalleriesDialogViews::AddOrUpdateGallery( | 183 bool MediaGalleriesDialogViews::AddOrUpdateGallery( |
| 184 const MediaGalleriesDialogController::Entry& gallery, | 184 const MediaGalleriesDialogController::Entry& gallery, |
| 185 views::View* container, | 185 views::View* container, |
| 186 int trailing_vertical_space) { | 186 int trailing_vertical_space) { |
| 187 base::string16 label = gallery.pref_info.GetGalleryDisplayName(); | |
| 188 base::string16 tooltip_text = gallery.pref_info.GetGalleryTooltip(); | |
| 189 base::string16 details = gallery.pref_info.GetGalleryAdditionalDetails(); | |
| 190 bool show_folder_viewer = controller_->ShouldShowFolderViewer(gallery); | 187 bool show_folder_viewer = controller_->ShouldShowFolderViewer(gallery); |
| 191 | 188 |
| 192 CheckboxMap::iterator iter = checkbox_map_.find(gallery.pref_info.pref_id); | 189 CheckboxMap::iterator iter = checkbox_map_.find(gallery.pref_info.pref_id); |
| 193 if (iter != checkbox_map_.end()) { | 190 if (iter != checkbox_map_.end()) { |
| 194 views::Checkbox* checkbox = iter->second->checkbox(); | 191 views::Checkbox* checkbox = iter->second->checkbox(); |
| 195 checkbox->SetChecked(gallery.selected); | 192 checkbox->SetChecked(gallery.selected); |
| 196 checkbox->SetText(label); | 193 checkbox->SetText(gallery.pref_info.GetGalleryDisplayName()); |
| 197 checkbox->SetTooltipText(tooltip_text); | 194 checkbox->SetTooltipText(gallery.pref_info.GetGalleryTooltip()); |
| 195 base::string16 details = gallery.pref_info.GetGalleryAdditionalDetails(); |
| 198 iter->second->secondary_text()->SetText(details); | 196 iter->second->secondary_text()->SetText(details); |
| 199 iter->second->secondary_text()->SetVisible(details.length() > 0); | 197 iter->second->secondary_text()->SetVisible(details.length() > 0); |
| 200 iter->second->folder_viewer_button()->SetVisible(show_folder_viewer); | 198 iter->second->folder_viewer_button()->SetVisible(show_folder_viewer); |
| 201 return false; | 199 return false; |
| 202 } | 200 } |
| 203 | 201 |
| 204 MediaGalleryCheckboxView* gallery_view = | 202 MediaGalleryCheckboxView* gallery_view = |
| 205 new MediaGalleryCheckboxView(label, tooltip_text, details, | 203 new MediaGalleryCheckboxView(gallery.pref_info, show_folder_viewer, |
| 206 show_folder_viewer, trailing_vertical_space, | 204 trailing_vertical_space, this, this); |
| 207 this, this); | |
| 208 gallery_view->checkbox()->SetChecked(gallery.selected); | 205 gallery_view->checkbox()->SetChecked(gallery.selected); |
| 209 container->AddChildView(gallery_view); | 206 container->AddChildView(gallery_view); |
| 210 checkbox_map_[gallery.pref_info.pref_id] = gallery_view; | 207 checkbox_map_[gallery.pref_info.pref_id] = gallery_view; |
| 211 | 208 |
| 212 return true; | 209 return true; |
| 213 } | 210 } |
| 214 | 211 |
| 215 base::string16 MediaGalleriesDialogViews::GetWindowTitle() const { | 212 base::string16 MediaGalleriesDialogViews::GetWindowTitle() const { |
| 216 return controller_->GetHeader(); | 213 return controller_->GetHeader(); |
| 217 } | 214 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 return controller_->WebContents() != NULL; | 325 return controller_->WebContents() != NULL; |
| 329 } | 326 } |
| 330 | 327 |
| 331 // MediaGalleriesDialogViewsController ----------------------------------------- | 328 // MediaGalleriesDialogViewsController ----------------------------------------- |
| 332 | 329 |
| 333 // static | 330 // static |
| 334 MediaGalleriesDialog* MediaGalleriesDialog::Create( | 331 MediaGalleriesDialog* MediaGalleriesDialog::Create( |
| 335 MediaGalleriesDialogController* controller) { | 332 MediaGalleriesDialogController* controller) { |
| 336 return new MediaGalleriesDialogViews(controller); | 333 return new MediaGalleriesDialogViews(controller); |
| 337 } | 334 } |
| OLD | NEW |