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

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

Issue 100833002: Add AshDesktopMediaList and enable Desktop Capture API on Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/media/desktop_media_list_ash_unittest.cc ('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/media/desktop_media_picker.h" 5 #include "chrome/browser/media/desktop_media_picker.h"
6 6
7 #include "ash/shell.h"
8 #include "base/callback.h" 7 #include "base/callback.h"
9 #include "chrome/browser/media/desktop_media_list.h" 8 #include "chrome/browser/media/desktop_media_list.h"
10 #include "chrome/browser/media/desktop_media_list_observer.h" 9 #include "chrome/browser/media/desktop_media_list_observer.h"
10 #include "chrome/browser/ui/ash/ash_util.h"
11 #include "content/public/browser/browser_thread.h" 11 #include "content/public/browser/browser_thread.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/events/keycodes/keyboard_codes.h" 14 #include "ui/events/keycodes/keyboard_codes.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/native_theme/native_theme.h" 16 #include "ui/native_theme/native_theme.h"
17 #include "ui/views/background.h" 17 #include "ui/views/background.h"
18 #include "ui/views/controls/image_view.h" 18 #include "ui/views/controls/image_view.h"
19 #include "ui/views/controls/label.h" 19 #include "ui/views/controls/label.h"
20 #include "ui/views/controls/scroll_view.h" 20 #include "ui/views/controls/scroll_view.h"
21 #include "ui/views/corewm/shadow_types.h" 21 #include "ui/views/corewm/shadow_types.h"
22 #include "ui/views/layout/box_layout.h" 22 #include "ui/views/layout/box_layout.h"
23 #include "ui/views/layout/layout_constants.h" 23 #include "ui/views/layout/layout_constants.h"
24 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
25 #include "ui/views/window/dialog_client_view.h" 25 #include "ui/views/window/dialog_client_view.h"
26 #include "ui/views/window/dialog_delegate.h" 26 #include "ui/views/window/dialog_delegate.h"
27 27
28 #if defined(USE_AURA) 28 #if defined(USE_AURA)
29 #include "ui/aura/root_window.h" 29 #include "ui/aura/root_window.h"
30 #endif 30 #endif
31 31
32 #if defined(OS_WIN)
33 #include "ui/views/win/hwnd_util.h"
34 #endif
35
36 using content::DesktopMediaID; 32 using content::DesktopMediaID;
37 33
38 namespace { 34 namespace {
39 35
40 const int kThumbnailWidth = 160; 36 const int kThumbnailWidth = 160;
41 const int kThumbnailHeight = 100; 37 const int kThumbnailHeight = 100;
42 const int kThumbnailMargin = 10; 38 const int kThumbnailMargin = 10;
43 const int kLabelHeight = 40; 39 const int kLabelHeight = 40;
44 const int kListItemWidth = kThumbnailMargin * 2 + kThumbnailWidth; 40 const int kListItemWidth = kThumbnailMargin * 2 + kThumbnailWidth;
45 const int kListItemHeight = 41 const int kListItemHeight =
46 kThumbnailMargin * 2 + kThumbnailHeight + kLabelHeight; 42 kThumbnailMargin * 2 + kThumbnailHeight + kLabelHeight;
47 const int kListColumns = 3; 43 const int kListColumns = 3;
48 const int kTotalListWidth = kListColumns * kListItemWidth; 44 const int kTotalListWidth = kListColumns * kListItemWidth;
49 45
50 const int kDesktopMediaSourceViewGroupId = 1; 46 const int kDesktopMediaSourceViewGroupId = 1;
51 47
52 const char kDesktopMediaSourceViewClassName[] = 48 const char kDesktopMediaSourceViewClassName[] =
53 "DesktopMediaPicker_DesktopMediaSourceView"; 49 "DesktopMediaPicker_DesktopMediaSourceView";
54 50
51 content::DesktopMediaID::Id AcceleratedWidgetToDesktopMediaId(
52 gfx::AcceleratedWidget accelerated_widget) {
53 #if defined(OS_WIN)
54 return reinterpret_cast<content::DesktopMediaID::Id>(accelerated_widget);
55 #else
56 return static_cast<content::DesktopMediaID::Id>(accelerated_widget);
57 #endif
58 }
59
55 class DesktopMediaListView; 60 class DesktopMediaListView;
56 class DesktopMediaPickerDialogView; 61 class DesktopMediaPickerDialogView;
57 class DesktopMediaPickerViews; 62 class DesktopMediaPickerViews;
58 63
59 // View used for each item in DesktopMediaListView. Shows a single desktop media 64 // View used for each item in DesktopMediaListView. Shows a single desktop media
60 // source as a thumbnail with the title under it. 65 // source as a thumbnail with the title under it.
61 class DesktopMediaSourceView : public views::View { 66 class DesktopMediaSourceView : public views::View {
62 public: 67 public:
63 DesktopMediaSourceView(DesktopMediaListView* parent, 68 DesktopMediaSourceView(DesktopMediaListView* parent,
64 DesktopMediaID source_id); 69 DesktopMediaID source_id);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 AddChildView(label_); 493 AddChildView(label_);
489 494
490 scroll_view_->SetContents(list_view_); 495 scroll_view_->SetContents(list_view_);
491 AddChildView(scroll_view_); 496 AddChildView(scroll_view_);
492 497
493 DialogDelegate::CreateDialogWidget(this, context, parent_window); 498 DialogDelegate::CreateDialogWidget(this, context, parent_window);
494 499
495 // DesktopMediaList needs to know the ID of the picker window which 500 // DesktopMediaList needs to know the ID of the picker window which
496 // matches the ID it gets from the OS. Depending on the OS and configuration 501 // matches the ID it gets from the OS. Depending on the OS and configuration
497 // we get this ID differently. 502 // we get this ID differently.
498 // 503 content::DesktopMediaID::Id dialog_window_id = 0;
499 // TODO(sergeyu): Update this code when Ash-specific window capturer is
500 // implemented. Currently this code will always get native windows ID
501 // which is not what we need in Ash. http://crbug.com/295102
502 content::DesktopMediaID::Id dialog_window_id;
503 504
504 #if defined(OS_WIN) 505 #if defined(USE_AURA)
505 dialog_window_id = reinterpret_cast<content::DesktopMediaID::Id>( 506
506 views::HWNDForWidget(GetWidget())); 507 #if defined(USE_ASH)
507 #elif defined(USE_AURA) 508 if (chrome::IsNativeWindowInAsh(GetWidget()->GetNativeWindow())) {
508 dialog_window_id = static_cast<content::DesktopMediaID::Id>( 509 dialog_window_id = content::DesktopMediaID::RegisterAuraWindow(
509 GetWidget()->GetNativeWindow()->GetDispatcher()->host()-> 510 GetWidget()->GetNativeWindow()).id;
510 GetAcceleratedWidget()); 511 } else
511 #else 512 #endif
513 {
514 dialog_window_id = AcceleratedWidgetToDesktopMediaId(
515 GetWidget()->GetNativeWindow()->GetDispatcher()->host()->
516 GetAcceleratedWidget());
517 }
518
519 #else // defined(USE_AURA)
512 dialog_window_id = 0; 520 dialog_window_id = 0;
513 NOTIMPLEMENTED(); 521 NOTIMPLEMENTED();
514 #endif 522 #endif // !defined(USE_AURA)
515 523
516 list_view_->StartUpdating(dialog_window_id); 524 list_view_->StartUpdating(dialog_window_id);
517 525
518 GetWidget()->Show(); 526 GetWidget()->Show();
519 } 527 }
520 528
521 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {} 529 DesktopMediaPickerDialogView::~DesktopMediaPickerDialogView() {}
522 530
523 void DesktopMediaPickerDialogView::DetachParent() { 531 void DesktopMediaPickerDialogView::DetachParent() {
524 parent_ = NULL; 532 parent_ = NULL;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 base::Bind(callback_, source)); 630 base::Bind(callback_, source));
623 callback_.Reset(); 631 callback_.Reset();
624 } 632 }
625 633
626 } // namespace 634 } // namespace
627 635
628 // static 636 // static
629 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 637 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
630 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 638 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
631 } 639 }
OLDNEW
« no previous file with comments | « chrome/browser/media/desktop_media_list_ash_unittest.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698