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" |
| 13 #include "chrome/browser/ui/views/frame/browser_view.h" | |
| 12 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 13 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
| 16 #include "extensions/grit/extensions_browser_resources.h" | |
| 17 #include "grit/theme_resources.h" | |
| 14 #include "ui/accessibility/ax_view_state.h" | 18 #include "ui/accessibility/ax_view_state.h" |
| 19 #include "ui/aura/window.h" | |
| 20 #include "ui/base/resource/resource_bundle.h" | |
| 15 #include "ui/views/focus/focus_manager.h" | 21 #include "ui/views/focus/focus_manager.h" |
| 16 | 22 |
| 17 using content::DesktopMediaID; | 23 using content::DesktopMediaID; |
| 18 | 24 |
| 19 namespace { | 25 namespace { |
| 20 | 26 |
| 21 const int kDesktopMediaSourceViewGroupId = 1; | 27 const int kDesktopMediaSourceViewGroupId = 1; |
| 22 | 28 |
| 29 #if defined(OS_CHROMEOS) | |
|
sky
2016/08/26 16:40:35
I think you want USE_ASH here and below.
qiangchen
2016/08/26 17:30:01
Done.
| |
| 30 // As aura framework uses empty icon to represent default icon, it relies on | |
|
sky
2016/08/26 16:40:35
aura here is misleading because aura is used on li
qiangchen
2016/08/26 17:30:01
Moved part of the comment below. Here we just need
| |
| 31 // the caller to handle the case. | |
| 32 // Here we are going to display default app icon for app windows without an | |
| 33 // icon, and display product logo for chrome browser windows. | |
| 34 gfx::ImageSkia LoadDefaultIcon(aura::Window* window) { | |
| 35 BrowserView* browser_view = | |
| 36 BrowserView::GetBrowserViewForNativeWindow(window); | |
| 37 Browser* browser = browser_view ? browser_view->browser() : nullptr; | |
| 38 | |
| 39 // Apps could be launched in a view other than BrowserView, so we count those | |
| 40 // windows without Browser association as apps. | |
| 41 // Technically dev tool is actually a special app, but we would like to | |
| 42 // display product logo for it, because intuitively it is internal to browser. | |
| 43 bool is_app = browser ? browser->is_app() && !browser->is_devtools() : true; | |
|
sky
2016/08/26 16:40:35
I don't think you need the ternary here, it just m
qiangchen
2016/08/26 17:30:01
Done.
But it should be !browser || (....)
| |
| 44 int idr = is_app ? IDR_APP_DEFAULT_ICON : IDR_PRODUCT_LOGO_32; | |
| 45 | |
| 46 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
| 47 return *rb.GetImageSkiaNamed(idr); | |
| 48 } | |
| 49 #endif | |
| 23 } // namespace | 50 } // namespace |
| 24 | 51 |
| 25 DesktopMediaListView::DesktopMediaListView( | 52 DesktopMediaListView::DesktopMediaListView( |
| 26 DesktopMediaPickerDialogView* parent, | 53 DesktopMediaPickerDialogView* parent, |
| 27 std::unique_ptr<DesktopMediaList> media_list, | 54 std::unique_ptr<DesktopMediaList> media_list, |
| 28 DesktopMediaSourceViewStyle generic_style, | 55 DesktopMediaSourceViewStyle generic_style, |
| 29 DesktopMediaSourceViewStyle single_style, | 56 DesktopMediaSourceViewStyle single_style, |
| 30 const base::string16& accessible_name) | 57 const base::string16& accessible_name) |
| 31 : parent_(parent), | 58 : parent_(parent), |
| 32 media_list_(std::move(media_list)), | 59 media_list_(std::move(media_list)), |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 171 |
| 145 // We are going to have a second item, apply the generic style. | 172 // We are going to have a second item, apply the generic style. |
| 146 if (child_count() == 1) | 173 if (child_count() == 1) |
| 147 SetStyle(&generic_style_); | 174 SetStyle(&generic_style_); |
| 148 | 175 |
| 149 DesktopMediaSourceView* source_view = | 176 DesktopMediaSourceView* source_view = |
| 150 new DesktopMediaSourceView(this, source.id, *active_style_); | 177 new DesktopMediaSourceView(this, source.id, *active_style_); |
| 151 | 178 |
| 152 source_view->SetName(source.name); | 179 source_view->SetName(source.name); |
| 153 source_view->SetGroup(kDesktopMediaSourceViewGroupId); | 180 source_view->SetGroup(kDesktopMediaSourceViewGroupId); |
| 181 if (source.id.type == DesktopMediaID::TYPE_WINDOW) { | |
| 182 gfx::ImageSkia icon_image = GetWindowIcon(source.id); | |
| 183 #if defined(OS_CHROMEOS) | |
| 184 if (icon_image.isNull()) { | |
| 185 aura::Window* window = DesktopMediaID::GetAuraWindowById(source.id); | |
| 186 if (window) | |
| 187 icon_image = LoadDefaultIcon(window); | |
| 188 } | |
| 189 #endif | |
| 190 source_view->SetIcon(icon_image); | |
| 191 } | |
| 154 AddChildViewAt(source_view, index); | 192 AddChildViewAt(source_view, index); |
| 155 | 193 |
| 156 if ((child_count() - 1) % active_style_->columns == 0) | 194 if ((child_count() - 1) % active_style_->columns == 0) |
| 157 parent_->OnMediaListRowsChanged(); | 195 parent_->OnMediaListRowsChanged(); |
| 158 | 196 |
| 159 // Auto select the first screen. | 197 // Auto select the first screen. |
| 160 if (index == 0 && source.id.type == DesktopMediaID::TYPE_SCREEN) | 198 if (index == 0 && source.id.type == DesktopMediaID::TYPE_SCREEN) |
| 161 source_view->RequestFocus(); | 199 source_view->RequestFocus(); |
| 162 | 200 |
| 163 PreferredSizeChanged(); | 201 PreferredSizeChanged(); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 240 DesktopMediaSourceView* source_view = | 278 DesktopMediaSourceView* source_view = |
| 241 static_cast<DesktopMediaSourceView*>(child_at(i)); | 279 static_cast<DesktopMediaSourceView*>(child_at(i)); |
| 242 source_view->SetStyle(*active_style_); | 280 source_view->SetStyle(*active_style_); |
| 243 } | 281 } |
| 244 } | 282 } |
| 245 | 283 |
| 246 void DesktopMediaListView::GetAccessibleState(ui::AXViewState* state) { | 284 void DesktopMediaListView::GetAccessibleState(ui::AXViewState* state) { |
| 247 state->role = ui::AX_ROLE_GROUP; | 285 state->role = ui::AX_ROLE_GROUP; |
| 248 state->name = accessible_name_; | 286 state->name = accessible_name_; |
| 249 } | 287 } |
| OLD | NEW |