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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/browser/infobars/infobar_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
10 #include "chrome/browser/ui/media_stream_infobar_delegate.h" | 10 #include "chrome/browser/ui/media_stream_infobar_delegate.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 allow_button_->bounds().right() + kButtonButtonSpacing, | 53 allow_button_->bounds().right() + kButtonButtonSpacing, |
54 OffsetY(deny_button_size), deny_button_size.width(), | 54 OffsetY(deny_button_size), deny_button_size.width(), |
55 deny_button_size.height()); | 55 deny_button_size.height()); |
56 | 56 |
57 gfx::Size devices_size = devices_menu_button_->GetPreferredSize(); | 57 gfx::Size devices_size = devices_menu_button_->GetPreferredSize(); |
58 devices_menu_button_->SetBounds(EndX() - devices_size.width(), | 58 devices_menu_button_->SetBounds(EndX() - devices_size.width(), |
59 OffsetY(devices_size), devices_size.width(), devices_size.height()); | 59 OffsetY(devices_size), devices_size.width(), devices_size.height()); |
60 } | 60 } |
61 | 61 |
62 void MediaStreamInfoBar::ViewHierarchyChanged(bool is_add, | 62 void MediaStreamInfoBar::ViewHierarchyChanged(bool is_add, |
63 View* parent, | 63 views::View* parent, |
64 View* child) { | 64 views::View* child) { |
65 if (is_add && child == this && (label_ == NULL)) { | 65 if (is_add && child == this && (label_ == NULL)) { |
66 int message_id = IDS_MEDIA_CAPTURE_MIC_AND_VIDEO; | 66 int message_id = IDS_MEDIA_CAPTURE_MIC_AND_VIDEO; |
67 DCHECK(delegate_->has_audio() || delegate_->has_video()); | 67 DCHECK(delegate_->has_audio() || delegate_->has_video()); |
68 if (!delegate_->has_audio()) | 68 if (!delegate_->has_audio()) |
69 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; | 69 message_id = IDS_MEDIA_CAPTURE_VIDEO_ONLY; |
70 else if (!delegate_->has_video()) | 70 else if (!delegate_->has_video()) |
71 message_id = IDS_MEDIA_CAPTURE_MIC_ONLY; | 71 message_id = IDS_MEDIA_CAPTURE_MIC_ONLY; |
72 | 72 |
73 label_ = CreateLabel(l10n_util::GetStringFUTF16(message_id, | 73 label_ = CreateLabel(l10n_util::GetStringFUTF16(message_id, |
74 UTF8ToUTF16(delegate_->GetSecurityOrigin()))); | 74 UTF8ToUTF16(delegate_->GetSecurityOrigin()))); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 } | 113 } |
114 | 114 |
115 int MediaStreamInfoBar::ContentMinimumWidth() const { | 115 int MediaStreamInfoBar::ContentMinimumWidth() const { |
116 return | 116 return |
117 kEndOfLabelSpacing + | 117 kEndOfLabelSpacing + |
118 (allow_button_->GetPreferredSize().width() + kButtonButtonSpacing + | 118 (allow_button_->GetPreferredSize().width() + kButtonButtonSpacing + |
119 deny_button_->GetPreferredSize().width()) + | 119 deny_button_->GetPreferredSize().width()) + |
120 (kButtonButtonSpacing + devices_menu_button_->GetPreferredSize().width()); | 120 (kButtonButtonSpacing + devices_menu_button_->GetPreferredSize().width()); |
121 } | 121 } |
122 | 122 |
123 void MediaStreamInfoBar::RunMenu(View* source, const gfx::Point& pt) { | 123 void MediaStreamInfoBar::OnMenuButtonClicked(views::View* source, |
| 124 const gfx::Point& point) { |
124 if (!owned()) | 125 if (!owned()) |
125 return; // We're closing; don't call anything, it might access the owner. | 126 return; // We're closing; don't call anything, it might access the owner. |
126 DCHECK_EQ(devices_menu_button_, source); | 127 DCHECK_EQ(devices_menu_button_, source); |
127 RunMenuAt(&devices_menu_model_, devices_menu_button_, | 128 RunMenuAt(&devices_menu_model_, devices_menu_button_, |
128 views::MenuItemView::TOPRIGHT); | 129 views::MenuItemView::TOPRIGHT); |
129 } | 130 } |
OLD | NEW |