| 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 "components/web_modal/web_contents_modal_dialog_host.h" | 9 #include "components/web_modal/web_contents_modal_dialog_host.h" |
| 10 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 10 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 subtext, 1, 1, | 121 subtext, 1, 1, |
| 122 views::GridLayout::FILL, views::GridLayout::LEADING, | 122 views::GridLayout::FILL, views::GridLayout::LEADING, |
| 123 dialog_content_width, subtext->GetHeightForWidth(dialog_content_width)); | 123 dialog_content_width, subtext->GetHeightForWidth(dialog_content_width)); |
| 124 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 124 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 125 | 125 |
| 126 // Scrollable area for checkboxes. | 126 // Scrollable area for checkboxes. |
| 127 ScrollableView* scroll_container = new ScrollableView(); | 127 ScrollableView* scroll_container = new ScrollableView(); |
| 128 scroll_container->SetLayoutManager(new views::BoxLayout( | 128 scroll_container->SetLayoutManager(new views::BoxLayout( |
| 129 views::BoxLayout::kVertical, 0, 0, | 129 views::BoxLayout::kVertical, 0, 0, |
| 130 views::kRelatedControlSmallVerticalSpacing)); | 130 views::kRelatedControlSmallVerticalSpacing)); |
| 131 scroll_container->set_border(views::Border::CreateEmptyBorder( | 131 scroll_container->SetBorder( |
| 132 views::kRelatedControlVerticalSpacing, | 132 views::Border::CreateEmptyBorder(views::kRelatedControlVerticalSpacing, |
| 133 0, | 133 0, |
| 134 views::kRelatedControlVerticalSpacing, | 134 views::kRelatedControlVerticalSpacing, |
| 135 0)); | 135 0)); |
| 136 | 136 |
| 137 // Add attached galleries checkboxes. | 137 // Add attached galleries checkboxes. |
| 138 checkbox_map_.clear(); | 138 checkbox_map_.clear(); |
| 139 new_checkbox_map_.clear(); | 139 new_checkbox_map_.clear(); |
| 140 GalleryPermissionsVector permissions = controller_->AttachedPermissions(); | 140 GalleryPermissionsVector permissions = controller_->AttachedPermissions(); |
| 141 for (GalleryPermissionsVector::const_iterator iter = permissions.begin(); | 141 for (GalleryPermissionsVector::const_iterator iter = permissions.begin(); |
| 142 iter != permissions.end(); ++iter) { | 142 iter != permissions.end(); ++iter) { |
| 143 int spacing = 0; | 143 int spacing = 0; |
| 144 if (iter + 1 == permissions.end()) | 144 if (iter + 1 == permissions.end()) |
| 145 spacing = views::kRelatedControlSmallVerticalSpacing; | 145 spacing = views::kRelatedControlSmallVerticalSpacing; |
| 146 AddOrUpdateGallery(iter->pref_info, iter->allowed, scroll_container, | 146 AddOrUpdateGallery(iter->pref_info, iter->allowed, scroll_container, |
| 147 spacing); | 147 spacing); |
| 148 } | 148 } |
| 149 | 149 |
| 150 GalleryPermissionsVector unattached_permissions = | 150 GalleryPermissionsVector unattached_permissions = |
| 151 controller_->UnattachedPermissions(); | 151 controller_->UnattachedPermissions(); |
| 152 | 152 |
| 153 if (!unattached_permissions.empty()) { | 153 if (!unattached_permissions.empty()) { |
| 154 // Separator line. | 154 // Separator line. |
| 155 views::Separator* separator = new views::Separator( | 155 views::Separator* separator = new views::Separator( |
| 156 views::Separator::HORIZONTAL); | 156 views::Separator::HORIZONTAL); |
| 157 scroll_container->AddChildView(separator); | 157 scroll_container->AddChildView(separator); |
| 158 | 158 |
| 159 // Unattached locations section. | 159 // Unattached locations section. |
| 160 views::Label* unattached_text = new views::Label( | 160 views::Label* unattached_text = new views::Label( |
| 161 controller_->GetUnattachedLocationsHeader()); | 161 controller_->GetUnattachedLocationsHeader()); |
| 162 unattached_text->SetMultiLine(true); | 162 unattached_text->SetMultiLine(true); |
| 163 unattached_text->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 163 unattached_text->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 164 unattached_text->set_border(views::Border::CreateEmptyBorder( | 164 unattached_text->SetBorder( |
| 165 views::kRelatedControlVerticalSpacing, | 165 views::Border::CreateEmptyBorder(views::kRelatedControlVerticalSpacing, |
| 166 views::kPanelHorizMargin, | 166 views::kPanelHorizMargin, |
| 167 views::kRelatedControlVerticalSpacing, | 167 views::kRelatedControlVerticalSpacing, |
| 168 0)); | 168 0)); |
| 169 scroll_container->AddChildView(unattached_text); | 169 scroll_container->AddChildView(unattached_text); |
| 170 | 170 |
| 171 // Add unattached galleries checkboxes. | 171 // Add unattached galleries checkboxes. |
| 172 for (GalleryPermissionsVector::const_iterator iter = | 172 for (GalleryPermissionsVector::const_iterator iter = |
| 173 unattached_permissions.begin(); | 173 unattached_permissions.begin(); |
| 174 iter != unattached_permissions.end(); ++iter) { | 174 iter != unattached_permissions.end(); ++iter) { |
| 175 AddOrUpdateGallery(iter->pref_info, iter->allowed, scroll_container, 0); | 175 AddOrUpdateGallery(iter->pref_info, iter->allowed, scroll_container, 0); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 checkbox->set_listener(this); | 225 checkbox->set_listener(this); |
| 226 if (gallery.pref_id != kInvalidMediaGalleryPrefId) | 226 if (gallery.pref_id != kInvalidMediaGalleryPrefId) |
| 227 checkbox->set_context_menu_controller(this); | 227 checkbox->set_context_menu_controller(this); |
| 228 checkbox->SetTooltipText(tooltip_text); | 228 checkbox->SetTooltipText(tooltip_text); |
| 229 views::Label* secondary_text = new views::Label(details); | 229 views::Label* secondary_text = new views::Label(details); |
| 230 if (gallery.pref_id != kInvalidMediaGalleryPrefId) | 230 if (gallery.pref_id != kInvalidMediaGalleryPrefId) |
| 231 secondary_text->set_context_menu_controller(this); | 231 secondary_text->set_context_menu_controller(this); |
| 232 secondary_text->SetTooltipText(tooltip_text); | 232 secondary_text->SetTooltipText(tooltip_text); |
| 233 secondary_text->SetEnabledColor(kDeemphasizedTextColor); | 233 secondary_text->SetEnabledColor(kDeemphasizedTextColor); |
| 234 secondary_text->SetTooltipText(tooltip_text); | 234 secondary_text->SetTooltipText(tooltip_text); |
| 235 secondary_text->set_border(views::Border::CreateEmptyBorder( | 235 secondary_text->SetBorder(views::Border::CreateEmptyBorder( |
| 236 0, | 236 0, |
| 237 views::kRelatedControlSmallHorizontalSpacing, | 237 views::kRelatedControlSmallHorizontalSpacing, |
| 238 0, | 238 0, |
| 239 views::kRelatedControlSmallHorizontalSpacing)); | 239 views::kRelatedControlSmallHorizontalSpacing)); |
| 240 | 240 |
| 241 views::View* checkbox_view = new views::View(); | 241 views::View* checkbox_view = new views::View(); |
| 242 if (gallery.pref_id != kInvalidMediaGalleryPrefId) | 242 if (gallery.pref_id != kInvalidMediaGalleryPrefId) |
| 243 checkbox_view->set_context_menu_controller(this); | 243 checkbox_view->set_context_menu_controller(this); |
| 244 checkbox_view->set_border(views::Border::CreateEmptyBorder( | 244 checkbox_view->SetBorder(views::Border::CreateEmptyBorder( |
| 245 0, | 245 0, views::kPanelHorizMargin, trailing_vertical_space, 0)); |
| 246 views::kPanelHorizMargin, | |
| 247 trailing_vertical_space, | |
| 248 0)); | |
| 249 checkbox_view->SetLayoutManager( | 246 checkbox_view->SetLayoutManager( |
| 250 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); | 247 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0)); |
| 251 checkbox_view->AddChildView(checkbox); | 248 checkbox_view->AddChildView(checkbox); |
| 252 checkbox_view->AddChildView(secondary_text); | 249 checkbox_view->AddChildView(secondary_text); |
| 253 | 250 |
| 254 container->AddChildView(checkbox_view); | 251 container->AddChildView(checkbox_view); |
| 255 | 252 |
| 256 checkbox->SetChecked(permitted); | 253 checkbox->SetChecked(permitted); |
| 257 if (gallery.pref_id != kInvalidMediaGalleryPrefId) | 254 if (gallery.pref_id != kInvalidMediaGalleryPrefId) |
| 258 checkbox_map_[gallery.pref_id] = checkbox; | 255 checkbox_map_[gallery.pref_id] = checkbox; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 } | 380 } |
| 384 } | 381 } |
| 385 | 382 |
| 386 // MediaGalleriesDialogViewsController ----------------------------------------- | 383 // MediaGalleriesDialogViewsController ----------------------------------------- |
| 387 | 384 |
| 388 // static | 385 // static |
| 389 MediaGalleriesDialog* MediaGalleriesDialog::Create( | 386 MediaGalleriesDialog* MediaGalleriesDialog::Create( |
| 390 MediaGalleriesDialogController* controller) { | 387 MediaGalleriesDialogController* controller) { |
| 391 return new MediaGalleriesDialogViews(controller); | 388 return new MediaGalleriesDialogViews(controller); |
| 392 } | 389 } |
| OLD | NEW |