Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/desktop_capture/desktop_media_list_view.h" | 5 #include "chrome/browser/ui/views/desktop_capture/desktop_media_list_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/media/desktop_media_list.h" | 9 #include "chrome/browser/media/desktop_media_list.h" |
| 10 #include "chrome/browser/media/window_icon_util.h" | |
| 10 #include "chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.h" | 11 #include "chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.h" |
| 11 #include "chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h" | 12 #include "chrome/browser/ui/views/desktop_capture/desktop_media_source_view.h" |
| 12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "grit/theme_resources.h" | |
| 14 #include "ui/accessibility/ax_view_state.h" | 16 #include "ui/accessibility/ax_view_state.h" |
| 17 #include "ui/aura/client/aura_constants.h" | |
| 18 #include "ui/aura/window.h" | |
| 19 #include "ui/base/resource/resource_bundle.h" | |
| 15 #include "ui/views/focus/focus_manager.h" | 20 #include "ui/views/focus/focus_manager.h" |
| 16 | 21 |
| 17 using content::DesktopMediaID; | 22 using content::DesktopMediaID; |
| 18 | 23 |
| 19 namespace { | 24 namespace { |
| 20 | 25 |
| 21 const int kDesktopMediaSourceViewGroupId = 1; | 26 const int kDesktopMediaSourceViewGroupId = 1; |
| 22 | 27 |
| 28 const gfx::ImageSkia GetWindowIconHelper(DesktopMediaID id) { | |
| 29 #if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_WIN) || \ | |
|
msw
2016/08/23 21:37:12
q: would #if !defined(OS_CHROMEOS) suffice? Is thi
qiangchen
2016/08/23 23:24:30
Moved to a single file as implementation of GetWin
| |
| 30 defined(OS_MACOSX) | |
| 31 return GetWindowIcon(id); | |
| 32 #elif defined(OS_CHROMEOS) | |
|
msw
2016/08/23 21:37:12
Does the code here actually belong in the GetWindo
qiangchen
2016/08/23 23:24:30
N/A now.
| |
| 33 aura::Window* window = DesktopMediaID::GetAuraWindowById(id); | |
| 34 const gfx::ImageSkia* icon_image_ptr = nullptr; | |
| 35 if (window) | |
| 36 icon_image_ptr = window->GetProperty(aura::client::kWindowIconKey); | |
| 37 | |
| 38 if (icon_image_ptr) return *icon_image_ptr; | |
|
msw
2016/08/23 21:37:12
No return on the same line as if; use 'git cl form
qiangchen
2016/08/23 23:24:30
Done.
| |
| 39 | |
| 40 // The default icon (for chrome window itself) does not enter window tree | |
|
msw
2016/08/23 21:37:11
nit: "(for a Chrome window itself)". Also, I'm not
qiangchen
2016/08/23 23:24:30
Changed to return empty icon if not aura window.
| |
| 41 // host, and thus not registered in aura::Window. | |
| 42 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 43 icon_image_ptr = rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_32).ToImageSkia(); | |
|
msw
2016/08/23 21:37:12
Is it possible that something other than a chrome
qiangchen
2016/08/23 23:24:30
For ChromeOS, everything is aura window, so no suc
| |
| 44 if (icon_image_ptr) return *icon_image_ptr; | |
|
msw
2016/08/23 21:37:12
Ditto: No return on the same line as if; use 'git
qiangchen
2016/08/23 23:24:30
Done.
| |
| 45 return gfx::ImageSkia(); | |
| 46 #else | |
| 47 return gfx::ImageSkia(); | |
| 48 #endif | |
| 49 } | |
| 50 | |
| 23 } // namespace | 51 } // namespace |
| 24 | 52 |
| 25 DesktopMediaListView::DesktopMediaListView( | 53 DesktopMediaListView::DesktopMediaListView( |
| 26 DesktopMediaPickerDialogView* parent, | 54 DesktopMediaPickerDialogView* parent, |
| 27 std::unique_ptr<DesktopMediaList> media_list, | 55 std::unique_ptr<DesktopMediaList> media_list, |
| 28 DesktopMediaSourceViewStyle generic_style, | 56 DesktopMediaSourceViewStyle generic_style, |
| 29 DesktopMediaSourceViewStyle single_style, | 57 DesktopMediaSourceViewStyle single_style, |
| 30 const base::string16& accessible_name) | 58 const base::string16& accessible_name) |
| 31 : parent_(parent), | 59 : parent_(parent), |
| 32 media_list_(std::move(media_list)), | 60 media_list_(std::move(media_list)), |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 172 |
| 145 // We are going to have a second item, apply the generic style. | 173 // We are going to have a second item, apply the generic style. |
| 146 if (child_count() == 1) | 174 if (child_count() == 1) |
| 147 SetStyle(&generic_style_); | 175 SetStyle(&generic_style_); |
| 148 | 176 |
| 149 DesktopMediaSourceView* source_view = | 177 DesktopMediaSourceView* source_view = |
| 150 new DesktopMediaSourceView(this, source.id, *active_style_); | 178 new DesktopMediaSourceView(this, source.id, *active_style_); |
| 151 | 179 |
| 152 source_view->SetName(source.name); | 180 source_view->SetName(source.name); |
| 153 source_view->SetGroup(kDesktopMediaSourceViewGroupId); | 181 source_view->SetGroup(kDesktopMediaSourceViewGroupId); |
| 182 if (source.id.type == DesktopMediaID::TYPE_WINDOW) | |
| 183 source_view->SetIcon(GetWindowIconHelper(source.id)); | |
| 154 AddChildViewAt(source_view, index); | 184 AddChildViewAt(source_view, index); |
| 155 | 185 |
| 156 if ((child_count() - 1) % active_style_->columns == 0) | 186 if ((child_count() - 1) % active_style_->columns == 0) |
| 157 parent_->OnMediaListRowsChanged(); | 187 parent_->OnMediaListRowsChanged(); |
| 158 | 188 |
| 159 // Auto select the first screen. | 189 // Auto select the first screen. |
| 160 if (index == 0 && source.id.type == DesktopMediaID::TYPE_SCREEN) | 190 if (index == 0 && source.id.type == DesktopMediaID::TYPE_SCREEN) |
| 161 source_view->RequestFocus(); | 191 source_view->RequestFocus(); |
| 162 | 192 |
| 163 PreferredSizeChanged(); | 193 PreferredSizeChanged(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 DesktopMediaSourceView* source_view = | 270 DesktopMediaSourceView* source_view = |
| 241 static_cast<DesktopMediaSourceView*>(child_at(i)); | 271 static_cast<DesktopMediaSourceView*>(child_at(i)); |
| 242 source_view->SetStyle(*active_style_); | 272 source_view->SetStyle(*active_style_); |
| 243 } | 273 } |
| 244 } | 274 } |
| 245 | 275 |
| 246 void DesktopMediaListView::GetAccessibleState(ui::AXViewState* state) { | 276 void DesktopMediaListView::GetAccessibleState(ui::AXViewState* state) { |
| 247 state->role = ui::AX_ROLE_GROUP; | 277 state->role = ui::AX_ROLE_GROUP; |
| 248 state->name = accessible_name_; | 278 state->name = accessible_name_; |
| 249 } | 279 } |
| OLD | NEW |