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

Side by Side Diff: chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.mm

Issue 2035863002: Push the chrome browser of the selected tab to the front of the screen, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 | chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.cc » ('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 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h" 5 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #import "base/mac/bundle_locations.h" 11 #import "base/mac/bundle_locations.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "chrome/browser/media/combined_desktop_media_list.h" 13 #include "chrome/browser/media/combined_desktop_media_list.h"
14 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_window.h"
14 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" 16 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h"
15 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h" 17 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.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 "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/render_frame_host.h" 21 #include "content/public/browser/render_frame_host.h"
20 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
21 #include "content/public/browser/web_contents_delegate.h" 23 #include "content/public/browser/web_contents_delegate.h"
22 #include "grit/components_strings.h" 24 #include "grit/components_strings.h"
23 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 25 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 } 240 }
239 241
240 - (void)reportResult:(content::DesktopMediaID)sourceID { 242 - (void)reportResult:(content::DesktopMediaID)sourceID {
241 if (doneCallback_.is_null()) { 243 if (doneCallback_.is_null()) {
242 return; 244 return;
243 } 245 }
244 246
245 sourceID.audio_share = [audioShareCheckbox_ isEnabled] && 247 sourceID.audio_share = [audioShareCheckbox_ isEnabled] &&
246 [audioShareCheckbox_ state] == NSOnState; 248 [audioShareCheckbox_ state] == NSOnState;
247 249
248 // If the media source is an tab, activate it.
249 if (sourceID.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) { 250 if (sourceID.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) {
251 // Activate the selected tab and bring the browser window for the selected
252 // tab to the front.
250 content::WebContents* tab = content::WebContents::FromRenderFrameHost( 253 content::WebContents* tab = content::WebContents::FromRenderFrameHost(
251 content::RenderFrameHost::FromID( 254 content::RenderFrameHost::FromID(
252 sourceID.web_contents_id.render_process_id, 255 sourceID.web_contents_id.render_process_id,
253 sourceID.web_contents_id.main_render_frame_id)); 256 sourceID.web_contents_id.main_render_frame_id));
254 if (tab) 257 if (tab) {
255 tab->GetDelegate()->ActivateContents(tab); 258 tab->GetDelegate()->ActivateContents(tab);
259 Browser* browser = chrome::FindBrowserWithWebContents(tab);
260 if (browser && browser->window())
261 browser->window()->Activate();
262 }
256 } 263 }
257 264
258 // Notify the |callback_| asynchronously because it may release the 265 // Notify the |callback_| asynchronously because it may release the
259 // controller. 266 // controller.
260 content::BrowserThread::PostTask( 267 content::BrowserThread::PostTask(
261 content::BrowserThread::UI, FROM_HERE, 268 content::BrowserThread::UI, FROM_HERE,
262 base::Bind(doneCallback_, sourceID)); 269 base::Bind(doneCallback_, sourceID));
263 doneCallback_.Reset(); 270 doneCallback_.Reset();
264 } 271 }
265 272
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 - (void)sourceThumbnailChangedAtIndex:(int)index { 440 - (void)sourceThumbnailChangedAtIndex:(int)index {
434 const DesktopMediaList::Source& source = media_list_->GetSource(index); 441 const DesktopMediaList::Source& source = media_list_->GetSource(index);
435 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail); 442 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail);
436 443
437 DesktopMediaPickerItem* item = [items_ objectAtIndex:index]; 444 DesktopMediaPickerItem* item = [items_ objectAtIndex:index];
438 [item setImageRepresentation:image]; 445 [item setImageRepresentation:image];
439 [sourceBrowser_ reloadData]; 446 [sourceBrowser_ reloadData];
440 } 447 }
441 448
442 @end // @interface DesktopMediaPickerController 449 @end // @interface DesktopMediaPickerController
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/desktop_capture/desktop_media_picker_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698