| 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 #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 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" | 13 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" |
| 14 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h" | 14 #import "chrome/browser/ui/cocoa/media_picker/desktop_media_picker_item.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/grit/generated_resources.h" | 16 #include "chrome/grit/generated_resources.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/render_frame_host.h" |
| 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/browser/web_contents_delegate.h" |
| 18 #include "grit/components_strings.h" | 21 #include "grit/components_strings.h" |
| 19 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" | 22 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw
eaker.h" |
| 20 #import "ui/base/cocoa/flipped_view.h" | 23 #import "ui/base/cocoa/flipped_view.h" |
| 21 #import "ui/base/cocoa/window_size_constants.h" | 24 #import "ui/base/cocoa/window_size_constants.h" |
| 22 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
| 23 #include "ui/gfx/image/image_skia_util_mac.h" | 26 #include "ui/gfx/image/image_skia_util_mac.h" |
| 24 | 27 |
| 25 namespace { | 28 namespace { |
| 26 | 29 |
| 27 const int kInitialContentWidth = 620; | 30 const int kInitialContentWidth = 620; |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 } | 221 } |
| 219 | 222 |
| 220 - (void)reportResult:(content::DesktopMediaID)sourceID { | 223 - (void)reportResult:(content::DesktopMediaID)sourceID { |
| 221 if (doneCallback_.is_null()) { | 224 if (doneCallback_.is_null()) { |
| 222 return; | 225 return; |
| 223 } | 226 } |
| 224 | 227 |
| 225 sourceID.audio_share = [audioShareCheckbox_ isEnabled] && | 228 sourceID.audio_share = [audioShareCheckbox_ isEnabled] && |
| 226 [audioShareCheckbox_ state] == NSOnState; | 229 [audioShareCheckbox_ state] == NSOnState; |
| 227 | 230 |
| 231 // If the media source is an tab, activate it. |
| 232 if (sourceID.type == content::DesktopMediaID::TYPE_WEB_CONTENTS) { |
| 233 content::WebContents* tab = content::WebContents::FromRenderFrameHost( |
| 234 content::RenderFrameHost::FromID( |
| 235 sourceID.web_contents_id.render_process_id, |
| 236 sourceID.web_contents_id.main_render_frame_id)); |
| 237 if (tab) |
| 238 tab->GetDelegate()->ActivateContents(tab); |
| 239 } |
| 240 |
| 228 // Notify the |callback_| asynchronously because it may release the | 241 // Notify the |callback_| asynchronously because it may release the |
| 229 // controller. | 242 // controller. |
| 230 content::BrowserThread::PostTask( | 243 content::BrowserThread::PostTask( |
| 231 content::BrowserThread::UI, FROM_HERE, | 244 content::BrowserThread::UI, FROM_HERE, |
| 232 base::Bind(doneCallback_, sourceID)); | 245 base::Bind(doneCallback_, sourceID)); |
| 233 doneCallback_.Reset(); | 246 doneCallback_.Reset(); |
| 234 } | 247 } |
| 235 | 248 |
| 236 - (void)sharePressed:(id)sender { | 249 - (void)sharePressed:(id)sender { |
| 237 NSIndexSet* indexes = [sourceBrowser_ selectionIndexes]; | 250 NSIndexSet* indexes = [sourceBrowser_ selectionIndexes]; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 - (void)sourceThumbnailChangedAtIndex:(int)index { | 405 - (void)sourceThumbnailChangedAtIndex:(int)index { |
| 393 const DesktopMediaList::Source& source = media_list_->GetSource(index); | 406 const DesktopMediaList::Source& source = media_list_->GetSource(index); |
| 394 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail); | 407 NSImage* image = gfx::NSImageFromImageSkia(source.thumbnail); |
| 395 | 408 |
| 396 DesktopMediaPickerItem* item = [items_ objectAtIndex:index]; | 409 DesktopMediaPickerItem* item = [items_ objectAtIndex:index]; |
| 397 [item setImageRepresentation:image]; | 410 [item setImageRepresentation:image]; |
| 398 [sourceBrowser_ reloadData]; | 411 [sourceBrowser_ reloadData]; |
| 399 } | 412 } |
| 400 | 413 |
| 401 @end // @interface DesktopMediaPickerController | 414 @end // @interface DesktopMediaPickerController |
| OLD | NEW |