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

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

Issue 1805583002: For Desktop tab sharing, activate selected inactive tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | no next file » | 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"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "chrome/browser/media/desktop_media_list.h" 14 #include "chrome/browser/media/desktop_media_list.h"
15 #include "chrome/browser/ui/ash/ash_util.h" 15 #include "chrome/browser/ui/ash/ash_util.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/grit/generated_resources.h" 17 #include "chrome/grit/generated_resources.h"
18 #include "components/constrained_window/constrained_window_views.h" 18 #include "components/constrained_window/constrained_window_views.h"
19 #include "components/web_modal/web_contents_modal_dialog_manager.h" 19 #include "components/web_modal/web_contents_modal_dialog_manager.h"
20 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
21 #include "content/public/browser/render_frame_host.h"
21 #include "content/public/browser/web_contents_delegate.h" 22 #include "content/public/browser/web_contents_delegate.h"
22 #include "grit/components_strings.h" 23 #include "grit/components_strings.h"
23 #include "ui/aura/window_tree_host.h" 24 #include "ui/aura/window_tree_host.h"
24 #include "ui/base/l10n/l10n_util.h" 25 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/events/event_constants.h" 26 #include "ui/events/event_constants.h"
26 #include "ui/events/keycodes/keyboard_codes.h" 27 #include "ui/events/keycodes/keyboard_codes.h"
27 #include "ui/gfx/canvas.h" 28 #include "ui/gfx/canvas.h"
28 #include "ui/native_theme/native_theme.h" 29 #include "ui/native_theme/native_theme.h"
29 #include "ui/views/background.h" 30 #include "ui/views/background.h"
30 #include "ui/views/bubble/bubble_frame_view.h" 31 #include "ui/views/bubble/bubble_frame_view.h"
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 ui::DialogButton button) const { 508 ui::DialogButton button) const {
508 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? 509 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ?
509 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL); 510 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL);
510 } 511 }
511 512
512 bool DesktopMediaPickerDialogView::Accept() { 513 bool DesktopMediaPickerDialogView::Accept() {
513 DesktopMediaSourceView* selection = sources_list_view_->GetSelection(); 514 DesktopMediaSourceView* selection = sources_list_view_->GetSelection();
514 515
515 // Ok button should only be enabled when a source is selected. 516 // Ok button should only be enabled when a source is selected.
516 DCHECK(selection); 517 DCHECK(selection);
517 518 DesktopMediaID source = selection->source_id();
518 DesktopMediaID source;
519 if (selection)
520 source = selection->source_id();
521
522 source.audio_share = audio_share_checkbox_ && 519 source.audio_share = audio_share_checkbox_ &&
523 audio_share_checkbox_->enabled() && 520 audio_share_checkbox_->enabled() &&
524 audio_share_checkbox_->checked(); 521 audio_share_checkbox_->checked();
525 522
523 // If the media source is an tab, activate it.
524 if (source.type == DesktopMediaID::TYPE_WEB_CONTENTS) {
525 content::RenderFrameHost* render_frame_host =
526 content::RenderFrameHost::FromID(
527 source.web_contents_id.render_process_id,
528 source.web_contents_id.main_render_frame_id);
529 if (render_frame_host) {
msw 2016/03/16 00:38:06 nit: FromRenderFrameHost can take a nullptr, inlin
530 content::WebContents* tab =
531 content::WebContents::FromRenderFrameHost(render_frame_host);
532 if (tab)
533 tab->GetDelegate()->ActivateContents(tab);
534 }
535 }
536
526 if (parent_) 537 if (parent_)
527 parent_->NotifyDialogResult(source); 538 parent_->NotifyDialogResult(source);
528 539
529 // Return true to close the window. 540 // Return true to close the window.
530 return true; 541 return true;
531 } 542 }
532 543
533 void DesktopMediaPickerDialogView::DeleteDelegate() { 544 void DesktopMediaPickerDialogView::DeleteDelegate() {
534 // If the dialog is being closed then notify the parent about it. 545 // If the dialog is being closed then notify the parent about it.
535 if (parent_) 546 if (parent_)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 content::BrowserThread::PostTask( 637 content::BrowserThread::PostTask(
627 content::BrowserThread::UI, FROM_HERE, 638 content::BrowserThread::UI, FROM_HERE,
628 base::Bind(callback_, source)); 639 base::Bind(callback_, source));
629 callback_.Reset(); 640 callback_.Reset();
630 } 641 }
631 642
632 // static 643 // static
633 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 644 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
634 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 645 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
635 } 646 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698