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

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/browser/ui/browser_finder.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/chrome_switches.h" 18 #include "chrome/common/chrome_switches.h"
17 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
18 #include "components/constrained_window/constrained_window_views.h" 20 #include "components/constrained_window/constrained_window_views.h"
19 #include "components/web_modal/web_contents_modal_dialog_manager.h" 21 #include "components/web_modal/web_contents_modal_dialog_manager.h"
20 #include "content/public/browser/browser_thread.h" 22 #include "content/public/browser/browser_thread.h"
23 #include "content/public/browser/render_frame_host.h"
21 #include "content/public/browser/web_contents_delegate.h" 24 #include "content/public/browser/web_contents_delegate.h"
22 #include "grit/components_strings.h" 25 #include "grit/components_strings.h"
23 #include "ui/aura/window_tree_host.h" 26 #include "ui/aura/window_tree_host.h"
24 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
25 #include "ui/events/event_constants.h" 28 #include "ui/events/event_constants.h"
26 #include "ui/events/keycodes/keyboard_codes.h" 29 #include "ui/events/keycodes/keyboard_codes.h"
27 #include "ui/gfx/canvas.h" 30 #include "ui/gfx/canvas.h"
28 #include "ui/native_theme/native_theme.h" 31 #include "ui/native_theme/native_theme.h"
29 #include "ui/views/background.h" 32 #include "ui/views/background.h"
30 #include "ui/views/bubble/bubble_frame_view.h" 33 #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 { 510 ui::DialogButton button) const {
508 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ? 511 return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK ?
509 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL); 512 IDS_DESKTOP_MEDIA_PICKER_SHARE : IDS_CANCEL);
510 } 513 }
511 514
512 bool DesktopMediaPickerDialogView::Accept() { 515 bool DesktopMediaPickerDialogView::Accept() {
513 DesktopMediaSourceView* selection = sources_list_view_->GetSelection(); 516 DesktopMediaSourceView* selection = sources_list_view_->GetSelection();
514 517
515 // Ok button should only be enabled when a source is selected. 518 // Ok button should only be enabled when a source is selected.
516 DCHECK(selection); 519 DCHECK(selection);
517 520 DesktopMediaID source = selection->source_id();
518 DesktopMediaID source;
519 if (selection)
520 source = selection->source_id();
521
522 source.audio_share = audio_share_checkbox_ && 521 source.audio_share = audio_share_checkbox_ &&
523 audio_share_checkbox_->enabled() && 522 audio_share_checkbox_->enabled() &&
524 audio_share_checkbox_->checked(); 523 audio_share_checkbox_->checked();
525 524
525 // If the media source is an inactive tab, activate it.
526 if (source.type == DesktopMediaID::TYPE_WEB_CONTENTS) {
527 content::WebContents* tab = content::WebContents::FromRenderFrameHost(
528 content::RenderFrameHost::FromID(
529 source.web_contents_id.render_process_id,
530 source.web_contents_id.main_render_frame_id));
531 if (tab) {
532 Browser* browser = chrome::FindBrowserWithWebContents(tab);
533 if (browser) {
msw 2016/03/15 23:58:19 When would browser be null? Do we need to check th
GeorgeZ 2016/03/16 00:32:32 You are right, as long as tab is valid, browser sh
534 TabStripModel* tab_strip_model = browser->tab_strip_model();
535 DCHECK(tab_strip_model);
msw 2016/03/15 23:58:19 nit: dcheck before dereference is unnecessary.
GeorgeZ 2016/03/16 00:32:32 Done.
536
537 const int tab_index = tab_strip_model->GetIndexOfWebContents(tab);
538 if (tab_index != tab_strip_model->active_index())
msw 2016/03/15 23:58:19 Must we check if the tab is inactive? Otherwise, t
GeorgeZ 2016/03/16 00:32:32 A check probably is not necessary.
539 tab->GetDelegate()->ActivateContents(tab);
540 }
541 }
542 }
543
526 if (parent_) 544 if (parent_)
527 parent_->NotifyDialogResult(source); 545 parent_->NotifyDialogResult(source);
528 546
529 // Return true to close the window. 547 // Return true to close the window.
530 return true; 548 return true;
531 } 549 }
532 550
533 void DesktopMediaPickerDialogView::DeleteDelegate() { 551 void DesktopMediaPickerDialogView::DeleteDelegate() {
534 // If the dialog is being closed then notify the parent about it. 552 // If the dialog is being closed then notify the parent about it.
535 if (parent_) 553 if (parent_)
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 content::BrowserThread::PostTask( 644 content::BrowserThread::PostTask(
627 content::BrowserThread::UI, FROM_HERE, 645 content::BrowserThread::UI, FROM_HERE,
628 base::Bind(callback_, source)); 646 base::Bind(callback_, source));
629 callback_.Reset(); 647 callback_.Reset();
630 } 648 }
631 649
632 // static 650 // static
633 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() { 651 scoped_ptr<DesktopMediaPicker> DesktopMediaPicker::Create() {
634 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews()); 652 return scoped_ptr<DesktopMediaPicker>(new DesktopMediaPickerViews());
635 } 653 }
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