OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/media_stream_capture_indicator.h" | 5 #include "chrome/browser/media/media_stream_capture_indicator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/status_icons/status_icon.h" | 12 #include "chrome/browser/status_icons/status_icon.h" |
13 #include "chrome/browser/status_icons/status_tray.h" | 13 #include "chrome/browser/status_icons/status_tray.h" |
14 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
15 #include "content/public/browser/browser_thread.h" | 15 #include "content/public/browser/browser_thread.h" |
16 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/render_view_host_delegate.h" | |
19 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/browser/web_contents_delegate.h" |
20 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
22 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
23 #include "net/base/net_util.h" | 23 #include "net/base/net_util.h" |
24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
25 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
26 | 26 |
27 using content::BrowserThread; | 27 using content::BrowserThread; |
28 using content::WebContents; | 28 using content::WebContents; |
29 | 29 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 int command_id, ui::Accelerator* accelerator) { | 62 int command_id, ui::Accelerator* accelerator) { |
63 // No accelerators for status icon context menu. | 63 // No accelerators for status icon context menu. |
64 return false; | 64 return false; |
65 } | 65 } |
66 | 66 |
67 void MediaStreamCaptureIndicator::ExecuteCommand(int command_id) { | 67 void MediaStreamCaptureIndicator::ExecuteCommand(int command_id) { |
68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 68 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
69 DCHECK(command_id >= IDC_MEDIA_CONTEXT_MEDIA_STREAM_CAPTURE_LIST_FIRST && | 69 DCHECK(command_id >= IDC_MEDIA_CONTEXT_MEDIA_STREAM_CAPTURE_LIST_FIRST && |
70 command_id <= IDC_MEDIA_CONTEXT_MEDIA_STREAM_CAPTURE_LIST_LAST); | 70 command_id <= IDC_MEDIA_CONTEXT_MEDIA_STREAM_CAPTURE_LIST_LAST); |
71 int index = command_id - IDC_MEDIA_CONTEXT_MEDIA_STREAM_CAPTURE_LIST_FIRST; | 71 int index = command_id - IDC_MEDIA_CONTEXT_MEDIA_STREAM_CAPTURE_LIST_FIRST; |
72 WebContents* tab_content = tab_util::GetWebContentsByID( | 72 WebContents* web_content = tab_util::GetWebContentsByID( |
73 tabs_[index].render_process_id, tabs_[index].render_view_id); | 73 tabs_[index].render_process_id, tabs_[index].render_view_id); |
74 DCHECK(tab_content); | 74 DCHECK(web_content); |
75 if (!tab_content || !tab_content->GetRenderViewHost() || | 75 if (!web_content) { |
76 !tab_content->GetRenderViewHost()->GetDelegate()) { | |
77 NOTREACHED(); | 76 NOTREACHED(); |
78 return; | 77 return; |
79 } | 78 } |
80 | 79 |
81 tab_content->GetRenderViewHost()->GetDelegate()->Activate(); | 80 web_content->GetDelegate()->ActivateContents(web_content); |
82 } | 81 } |
83 | 82 |
84 void MediaStreamCaptureIndicator::CaptureDevicesOpened( | 83 void MediaStreamCaptureIndicator::CaptureDevicesOpened( |
85 int render_process_id, | 84 int render_process_id, |
86 int render_view_id, | 85 int render_view_id, |
87 const content::MediaStreamDevices& devices) { | 86 const content::MediaStreamDevices& devices) { |
88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 87 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
89 DCHECK(!devices.empty()); | 88 DCHECK(!devices.empty()); |
90 | 89 |
91 BrowserThread::PostTask( | 90 BrowserThread::PostTask( |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 360 |
362 // Remove the last character if it is a '/'. | 361 // Remove the last character if it is a '/'. |
363 if (!security_origin.empty()) { | 362 if (!security_origin.empty()) { |
364 std::string::iterator it = security_origin.end() - 1; | 363 std::string::iterator it = security_origin.end() - 1; |
365 if (*it == '/') | 364 if (*it == '/') |
366 security_origin.erase(it); | 365 security_origin.erase(it); |
367 } | 366 } |
368 | 367 |
369 return UTF8ToUTF16(security_origin); | 368 return UTF8ToUTF16(security_origin); |
370 } | 369 } |
OLD | NEW |