OLD | NEW |
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 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 if (new_selected) { | 304 if (new_selected) { |
305 GetFocusManager()->SetFocusedView(new_selected); | 305 GetFocusManager()->SetFocusedView(new_selected); |
306 } | 306 } |
307 | 307 |
308 return true; | 308 return true; |
309 } | 309 } |
310 | 310 |
311 return false; | 311 return false; |
312 } | 312 } |
313 | 313 |
314 void DesktopMediaListView::OnSourceAdded(int index) { | 314 void DesktopMediaListView::OnSourceAdded(DesktopMediaList* list, int index) { |
315 const DesktopMediaList::Source& source = media_list_->GetSource(index); | 315 const DesktopMediaList::Source& source = media_list_->GetSource(index); |
316 DesktopMediaSourceView* source_view = | 316 DesktopMediaSourceView* source_view = |
317 new DesktopMediaSourceView(this, source.id); | 317 new DesktopMediaSourceView(this, source.id); |
318 source_view->SetName(source.name); | 318 source_view->SetName(source.name); |
319 source_view->SetGroup(kDesktopMediaSourceViewGroupId); | 319 source_view->SetGroup(kDesktopMediaSourceViewGroupId); |
320 AddChildViewAt(source_view, index); | 320 AddChildViewAt(source_view, index); |
321 | 321 |
322 PreferredSizeChanged(); | 322 PreferredSizeChanged(); |
323 | 323 |
324 if (child_count() % kListColumns == 1) | 324 if (child_count() % kListColumns == 1) |
325 parent_->OnMediaListRowsChanged(); | 325 parent_->OnMediaListRowsChanged(); |
326 | 326 |
327 std::string autoselect_source = | 327 std::string autoselect_source = |
328 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 328 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
329 switches::kAutoSelectDesktopCaptureSource); | 329 switches::kAutoSelectDesktopCaptureSource); |
330 if (!autoselect_source.empty() && | 330 if (!autoselect_source.empty() && |
331 base::ASCIIToUTF16(autoselect_source) == source.name) { | 331 base::ASCIIToUTF16(autoselect_source) == source.name) { |
332 // Select, then accept and close the dialog when we're done adding sources. | 332 // Select, then accept and close the dialog when we're done adding sources. |
333 source_view->OnFocus(); | 333 source_view->OnFocus(); |
334 content::BrowserThread::PostTask( | 334 content::BrowserThread::PostTask( |
335 content::BrowserThread::UI, FROM_HERE, | 335 content::BrowserThread::UI, FROM_HERE, |
336 base::Bind(&DesktopMediaListView::AcceptSelection, | 336 base::Bind(&DesktopMediaListView::AcceptSelection, |
337 weak_factory_.GetWeakPtr())); | 337 weak_factory_.GetWeakPtr())); |
338 } | 338 } |
339 } | 339 } |
340 | 340 |
341 void DesktopMediaListView::OnSourceRemoved(int index) { | 341 void DesktopMediaListView::OnSourceRemoved(DesktopMediaList* list, int index) { |
342 DesktopMediaSourceView* view = | 342 DesktopMediaSourceView* view = |
343 static_cast<DesktopMediaSourceView*>(child_at(index)); | 343 static_cast<DesktopMediaSourceView*>(child_at(index)); |
344 DCHECK(view); | 344 DCHECK(view); |
345 DCHECK_EQ(view->GetClassName(), kDesktopMediaSourceViewClassName); | 345 DCHECK_EQ(view->GetClassName(), kDesktopMediaSourceViewClassName); |
346 bool was_selected = view->is_selected(); | 346 bool was_selected = view->is_selected(); |
347 RemoveChildView(view); | 347 RemoveChildView(view); |
348 delete view; | 348 delete view; |
349 | 349 |
350 if (was_selected) | 350 if (was_selected) |
351 OnSelectionChanged(); | 351 OnSelectionChanged(); |
352 | 352 |
353 PreferredSizeChanged(); | 353 PreferredSizeChanged(); |
354 | 354 |
355 if (child_count() % kListColumns == 0) | 355 if (child_count() % kListColumns == 0) |
356 parent_->OnMediaListRowsChanged(); | 356 parent_->OnMediaListRowsChanged(); |
357 } | 357 } |
358 | 358 |
359 void DesktopMediaListView::OnSourceMoved(int old_index, int new_index) { | 359 void DesktopMediaListView::OnSourceMoved(DesktopMediaList* list, |
| 360 int old_index, |
| 361 int new_index) { |
360 DesktopMediaSourceView* view = | 362 DesktopMediaSourceView* view = |
361 static_cast<DesktopMediaSourceView*>(child_at(old_index)); | 363 static_cast<DesktopMediaSourceView*>(child_at(old_index)); |
362 ReorderChildView(view, new_index); | 364 ReorderChildView(view, new_index); |
363 PreferredSizeChanged(); | 365 PreferredSizeChanged(); |
364 } | 366 } |
365 | 367 |
366 void DesktopMediaListView::OnSourceNameChanged(int index) { | 368 void DesktopMediaListView::OnSourceNameChanged(DesktopMediaList* list, |
| 369 int index) { |
367 const DesktopMediaList::Source& source = media_list_->GetSource(index); | 370 const DesktopMediaList::Source& source = media_list_->GetSource(index); |
368 DesktopMediaSourceView* source_view = | 371 DesktopMediaSourceView* source_view = |
369 static_cast<DesktopMediaSourceView*>(child_at(index)); | 372 static_cast<DesktopMediaSourceView*>(child_at(index)); |
370 source_view->SetName(source.name); | 373 source_view->SetName(source.name); |
371 } | 374 } |
372 | 375 |
373 void DesktopMediaListView::OnSourceThumbnailChanged(int index) { | 376 void DesktopMediaListView::OnSourceThumbnailChanged(DesktopMediaList* list, |
| 377 int index) { |
374 const DesktopMediaList::Source& source = media_list_->GetSource(index); | 378 const DesktopMediaList::Source& source = media_list_->GetSource(index); |
375 DesktopMediaSourceView* source_view = | 379 DesktopMediaSourceView* source_view = |
376 static_cast<DesktopMediaSourceView*>(child_at(index)); | 380 static_cast<DesktopMediaSourceView*>(child_at(index)); |
377 source_view->SetThumbnail(source.thumbnail); | 381 source_view->SetThumbnail(source.thumbnail); |
378 } | 382 } |
379 | 383 |
380 void DesktopMediaListView::AcceptSelection() { | 384 void DesktopMediaListView::AcceptSelection() { |
381 OnSelectionChanged(); | 385 OnSelectionChanged(); |
382 OnDoubleClick(); | 386 OnDoubleClick(); |
383 } | 387 } |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 content::BrowserThread::PostTask( | 603 content::BrowserThread::PostTask( |
600 content::BrowserThread::UI, FROM_HERE, | 604 content::BrowserThread::UI, FROM_HERE, |
601 base::Bind(callback_, source)); | 605 base::Bind(callback_, source)); |
602 callback_.Reset(); | 606 callback_.Reset(); |
603 } | 607 } |
604 | 608 |
605 // static | 609 // static |
606 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { | 610 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { |
607 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); | 611 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); |
608 } | 612 } |
OLD | NEW |