| 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/content_setting_bubble_contents.h" | 5 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 } | 149 } |
| 150 | 150 |
| 151 ContentSettingBubbleContents::~ContentSettingBubbleContents() { | 151 ContentSettingBubbleContents::~ContentSettingBubbleContents() { |
| 152 STLDeleteValues(&media_menus_); | 152 STLDeleteValues(&media_menus_); |
| 153 } | 153 } |
| 154 | 154 |
| 155 gfx::Size ContentSettingBubbleContents::GetPreferredSize() const { | 155 gfx::Size ContentSettingBubbleContents::GetPreferredSize() const { |
| 156 gfx::Size preferred_size(views::View::GetPreferredSize()); | 156 gfx::Size preferred_size(views::View::GetPreferredSize()); |
| 157 int preferred_width = | 157 int preferred_width = |
| 158 (!content_setting_bubble_model_->bubble_content().domain_lists.empty() && | 158 (!content_setting_bubble_model_->bubble_content().domain_lists.empty() && |
| 159 (kMinMultiLineContentsWidth > preferred_size.width())) ? | 159 (kMinMultiLineContentsWidth > preferred_size.width())) |
| 160 kMinMultiLineContentsWidth : preferred_size.width(); | 160 ? kMinMultiLineContentsWidth |
| 161 : preferred_size.width(); |
| 161 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); | 162 preferred_size.set_width(std::min(preferred_width, kMaxContentsWidth)); |
| 162 return preferred_size; | 163 return preferred_size; |
| 163 } | 164 } |
| 164 | 165 |
| 165 void ContentSettingBubbleContents::UpdateMenuLabel( | 166 void ContentSettingBubbleContents::UpdateMenuLabel( |
| 166 content::MediaStreamType type, | 167 content::MediaStreamType type, |
| 167 const std::string& label) { | 168 const std::string& label) { |
| 168 for (MediaMenuPartsMap::const_iterator it = media_menus_.begin(); | 169 for (MediaMenuPartsMap::const_iterator it = media_menus_.begin(); |
| 169 it != media_menus_.end(); ++it) { | 170 it != media_menus_.end(); ++it) { |
| 170 if (it->second->type == type) { | 171 if (it->second->type == type) { |
| 171 it->first->SetText(base::UTF8ToUTF16(label)); | 172 it->first->SetText(base::UTF8ToUTF16(label)); |
| 173 it->first->Layout(); |
| 172 return; | 174 return; |
| 173 } | 175 } |
| 174 } | 176 } |
| 175 NOTREACHED(); | 177 NOTREACHED(); |
| 176 } | 178 } |
| 177 | 179 |
| 178 void ContentSettingBubbleContents::Init() { | 180 void ContentSettingBubbleContents::Init() { |
| 179 using views::GridLayout; | 181 using views::GridLayout; |
| 180 | 182 |
| 181 GridLayout* layout = new views::GridLayout(this); | 183 GridLayout* layout = new views::GridLayout(this); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // Make sure the width is at least kMinMediaMenuButtonWidth. The | 492 // Make sure the width is at least kMinMediaMenuButtonWidth. The |
| 491 // maximum width will be clamped by kMaxContentsWidth of the view. | 493 // maximum width will be clamped by kMaxContentsWidth of the view. |
| 492 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); | 494 menu_width = std::max(kMinMediaMenuButtonWidth, menu_width + margins); |
| 493 | 495 |
| 494 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); | 496 for (MediaMenuPartsMap::const_iterator i = media_menus_.begin(); |
| 495 i != media_menus_.end(); ++i) { | 497 i != media_menus_.end(); ++i) { |
| 496 i->first->SetMinSize(gfx::Size(menu_width, 0)); | 498 i->first->SetMinSize(gfx::Size(menu_width, 0)); |
| 497 i->first->SetMaxSize(gfx::Size(menu_width, 0)); | 499 i->first->SetMaxSize(gfx::Size(menu_width, 0)); |
| 498 } | 500 } |
| 499 } | 501 } |
| OLD | NEW |