| Index: chrome/browser/media/desktop_media_list_ash.cc
|
| diff --git a/chrome/browser/media/desktop_media_list_ash.cc b/chrome/browser/media/desktop_media_list_ash.cc
|
| index a9ab1a4224b0d9c05d9e9ecf0fe2c367df90dc2b..e225bc5fbd56ab1223abbcdb835792003867e472 100644
|
| --- a/chrome/browser/media/desktop_media_list_ash.cc
|
| +++ b/chrome/browser/media/desktop_media_list_ash.cc
|
| @@ -15,8 +15,15 @@
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/sequenced_worker_pool.h"
|
| #include "chrome/browser/media/desktop_media_list_observer.h"
|
| +#include "chrome/browser/profiles/profile_manager.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| +#include "chrome/browser/ui/browser_iterator.h"
|
| +#include "chrome/browser/ui/tabs/tab_strip_model.h"
|
| #include "chrome/grit/generated_resources.h"
|
| +#include "components/favicon/content/content_favicon_driver.h"
|
| #include "content/public/browser/browser_thread.h"
|
| +#include "content/public/browser/render_frame_host.h"
|
| +#include "content/public/browser/render_process_host.h"
|
| #include "media/base/video_util.h"
|
| #include "ui/base/l10n/l10n_util.h"
|
| #include "ui/compositor/dip_util.h"
|
| @@ -171,6 +178,61 @@ void DesktopMediaListAsh::EnumerateWindowsForRoot(
|
| }
|
| }
|
|
|
| +void DesktopMediaListAsh::EnumerateTabs(
|
| + std::vector<DesktopMediaListAsh::SourceDescription>* sources) {
|
| + DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| +
|
| + std::map<base::TimeTicks, SourceDescription> tab_map;
|
| +
|
| + // Enumerate all tabs with their titles and favicons for a user profile.
|
| + Profile* profile = ProfileManager::GetLastUsedProfileAllowedByPolicy();
|
| + std::vector<Browser*> browsers;
|
| + for (chrome::BrowserIterator it; !it.done(); it.Next()) {
|
| + if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile())
|
| + browsers.push_back(*it);
|
| + }
|
| +
|
| + for (auto browser : browsers) {
|
| + TabStripModel* tab_strip_model = browser->tab_strip_model();
|
| + DCHECK(tab_strip_model);
|
| +
|
| + for (int i = 0; i < tab_strip_model->count(); i++) {
|
| + content::WebContents* contents = tab_strip_model->GetWebContentsAt(i);
|
| + content::RenderFrameHost* const main_frame = contents->GetMainFrame();
|
| + DCHECK(main_frame);
|
| + DesktopMediaID media_id(
|
| + DesktopMediaID::TYPE_WEB_CONTENTS, DesktopMediaID::kNullId,
|
| + content::WebContentsMediaCaptureId(main_frame->GetProcess()->GetID(),
|
| + main_frame->GetRoutingID()));
|
| +
|
| + // Create display tab title.
|
| + base::string16 title = l10n_util::GetStringFUTF16(
|
| + IDS_DESKTOP_MEDIA_PICKER_CHROME_TAB_TITLE, contents->GetTitle());
|
| +
|
| + // Get tab's last active time stamp.
|
| + base::TimeTicks t = contents->GetLastActiveTime();
|
| + tab_map.insert(std::make_pair(t, SourceDescription(media_id, title)));
|
| +
|
| + // Create thumbnail based on favicon for tab.
|
| + favicon::FaviconDriver* favicon_driver =
|
| + favicon::ContentFaviconDriver::FromWebContents(contents);
|
| + if (favicon_driver) {
|
| + gfx::Image tab_icon = favicon_driver->GetFavicon();
|
| + tab_map[t].thumbnail =
|
| + CreateEnlargedFaviconImage(thumbnail_size_, tab_icon);
|
| + }
|
| + }
|
| + }
|
| +
|
| + // Add timely sorted tab sources into vector. Most recent one first.
|
| + for (auto it = tab_map.rbegin(); it != tab_map.rend(); ++it) {
|
| + SourceDescription& source = it->second;
|
| + sources->push_back(source);
|
| + if (!it->second.thumbnail.isNull())
|
| + OnThumbnailCaptured(source.id, gfx::Image(source.thumbnail));
|
| + }
|
| +}
|
| +
|
| void DesktopMediaListAsh::EnumerateSources(
|
| std::vector<DesktopMediaListAsh::SourceDescription>* sources) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| @@ -211,6 +273,9 @@ void DesktopMediaListAsh::EnumerateSources(
|
| EnumerateWindowsForRoot(
|
| sources, root_windows[i], ash::kShellWindowId_DockedContainer);
|
| }
|
| +
|
| + if (source_types_ & TABS)
|
| + EnumerateTabs(sources);
|
| }
|
| }
|
|
|
|
|