Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: chrome/browser/ui/views/desktop_media_picker_views.cc

Issue 1554243002: Add CombinedDesktopMediaList. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/desktop_media_picker_views.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_media_picker_views.h" 5 #include "chrome/browser/ui/views/desktop_media_picker_views.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 if (new_selected) { 308 if (new_selected) {
309 GetFocusManager()->SetFocusedView(new_selected); 309 GetFocusManager()->SetFocusedView(new_selected);
310 } 310 }
311 311
312 return true; 312 return true;
313 } 313 }
314 314
315 return false; 315 return false;
316 } 316 }
317 317
318 void DesktopMediaListView::OnSourceAdded(int index) { 318 void DesktopMediaListView::OnSourceAdded(DesktopMediaList* list, int index) {
319 const DesktopMediaList::Source& source = media_list_->GetSource(index); 319 const DesktopMediaList::Source& source = media_list_->GetSource(index);
320 DesktopMediaSourceView* source_view = 320 DesktopMediaSourceView* source_view =
321 new DesktopMediaSourceView(this, source.id); 321 new DesktopMediaSourceView(this, source.id);
322 source_view->SetName(source.name); 322 source_view->SetName(source.name);
323 source_view->SetGroup(kDesktopMediaSourceViewGroupId); 323 source_view->SetGroup(kDesktopMediaSourceViewGroupId);
324 AddChildViewAt(source_view, index); 324 AddChildViewAt(source_view, index);
325 325
326 PreferredSizeChanged(); 326 PreferredSizeChanged();
327 327
328 if (child_count() % kListColumns == 1) 328 if (child_count() % kListColumns == 1)
329 parent_->OnMediaListRowsChanged(); 329 parent_->OnMediaListRowsChanged();
330 330
331 std::string autoselect_source = 331 std::string autoselect_source =
332 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 332 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
333 switches::kAutoSelectDesktopCaptureSource); 333 switches::kAutoSelectDesktopCaptureSource);
334 if (!autoselect_source.empty() && 334 if (!autoselect_source.empty() &&
335 base::ASCIIToUTF16(autoselect_source) == source.name) { 335 base::ASCIIToUTF16(autoselect_source) == source.name) {
336 // Select, then accept and close the dialog when we're done adding sources. 336 // Select, then accept and close the dialog when we're done adding sources.
337 source_view->OnFocus(); 337 source_view->OnFocus();
338 content::BrowserThread::PostTask( 338 content::BrowserThread::PostTask(
339 content::BrowserThread::UI, FROM_HERE, 339 content::BrowserThread::UI, FROM_HERE,
340 base::Bind(&DesktopMediaListView::AcceptSelection, 340 base::Bind(&DesktopMediaListView::AcceptSelection,
341 weak_factory_.GetWeakPtr())); 341 weak_factory_.GetWeakPtr()));
342 } 342 }
343 } 343 }
344 344
345 void DesktopMediaListView::OnSourceRemoved(int index) { 345 void DesktopMediaListView::OnSourceRemoved(DesktopMediaList* list, int index) {
346 DesktopMediaSourceView* view = 346 DesktopMediaSourceView* view =
347 static_cast<DesktopMediaSourceView*>(child_at(index)); 347 static_cast<DesktopMediaSourceView*>(child_at(index));
348 DCHECK(view); 348 DCHECK(view);
349 DCHECK_EQ(view->GetClassName(), kDesktopMediaSourceViewClassName); 349 DCHECK_EQ(view->GetClassName(), kDesktopMediaSourceViewClassName);
350 bool was_selected = view->is_selected(); 350 bool was_selected = view->is_selected();
351 RemoveChildView(view); 351 RemoveChildView(view);
352 delete view; 352 delete view;
353 353
354 if (was_selected) 354 if (was_selected)
355 OnSelectionChanged(); 355 OnSelectionChanged();
356 356
357 PreferredSizeChanged(); 357 PreferredSizeChanged();
358 358
359 if (child_count() % kListColumns == 0) 359 if (child_count() % kListColumns == 0)
360 parent_->OnMediaListRowsChanged(); 360 parent_->OnMediaListRowsChanged();
361 } 361 }
362 362
363 void DesktopMediaListView::OnSourceMoved(int old_index, int new_index) { 363 void DesktopMediaListView::OnSourceMoved(DesktopMediaList* list,
364 int old_index,
365 int new_index) {
364 DesktopMediaSourceView* view = 366 DesktopMediaSourceView* view =
365 static_cast<DesktopMediaSourceView*>(child_at(old_index)); 367 static_cast<DesktopMediaSourceView*>(child_at(old_index));
366 ReorderChildView(view, new_index); 368 ReorderChildView(view, new_index);
367 PreferredSizeChanged(); 369 PreferredSizeChanged();
368 } 370 }
369 371
370 void DesktopMediaListView::OnSourceNameChanged(int index) { 372 void DesktopMediaListView::OnSourceNameChanged(DesktopMediaList* list,
373 int index) {
371 const DesktopMediaList::Source& source = media_list_->GetSource(index); 374 const DesktopMediaList::Source& source = media_list_->GetSource(index);
372 DesktopMediaSourceView* source_view = 375 DesktopMediaSourceView* source_view =
373 static_cast<DesktopMediaSourceView*>(child_at(index)); 376 static_cast<DesktopMediaSourceView*>(child_at(index));
374 source_view->SetName(source.name); 377 source_view->SetName(source.name);
375 } 378 }
376 379
377 void DesktopMediaListView::OnSourceThumbnailChanged(int index) { 380 void DesktopMediaListView::OnSourceThumbnailChanged(DesktopMediaList* list,
381 int index) {
378 const DesktopMediaList::Source& source = media_list_->GetSource(index); 382 const DesktopMediaList::Source& source = media_list_->GetSource(index);
379 DesktopMediaSourceView* source_view = 383 DesktopMediaSourceView* source_view =
380 static_cast<DesktopMediaSourceView*>(child_at(index)); 384 static_cast<DesktopMediaSourceView*>(child_at(index));
381 source_view->SetThumbnail(source.thumbnail); 385 source_view->SetThumbnail(source.thumbnail);
382 } 386 }
383 387
384 void DesktopMediaListView::AcceptSelection() { 388 void DesktopMediaListView::AcceptSelection() {
385 OnSelectionChanged(); 389 OnSelectionChanged();
386 OnDoubleClick(); 390 OnDoubleClick();
387 } 391 }
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 content::BrowserThread::PostTask( 607 content::BrowserThread::PostTask(
604 content::BrowserThread::UI, FROM_HERE, 608 content::BrowserThread::UI, FROM_HERE,
605 base::Bind(callback_, source)); 609 base::Bind(callback_, source));
606 callback_.Reset(); 610 callback_.Reset();
607 } 611 }
608 612
609 // static 613 // static
610 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 614 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
611 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 615 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
612 } 616 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/desktop_media_picker_views.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698