| Index: content/public/browser/desktop_media_id.cc
|
| diff --git a/content/public/browser/desktop_media_id.cc b/content/public/browser/desktop_media_id.cc
|
| index 7817766e4d3e61de7ecd159d032a3cddb23b9dc8..c5351884b1229367e195b88d1487d60ff7d4244d 100644
|
| --- a/content/public/browser/desktop_media_id.cc
|
| +++ b/content/public/browser/desktop_media_id.cc
|
| @@ -49,16 +49,29 @@ class AuraWindowRegistry : public aura::WindowObserver {
|
| return (it != id_to_window_map_.end()) ? it->second : nullptr;
|
| }
|
|
|
| + void RegisterVirtualScreenWindow(aura::Window* window) {
|
| + DCHECK(!virtual_screen_window_);
|
| + virtual_screen_window_ = window;
|
| + window->AddObserver(this);
|
| + }
|
| +
|
| + aura::Window* GetVirtualScreenWindow() { return virtual_screen_window_; }
|
| +
|
| private:
|
| friend struct DefaultSingletonTraits<AuraWindowRegistry>;
|
|
|
| AuraWindowRegistry()
|
| - : next_id_(1) {
|
| + : next_id_(1),
|
| + virtual_screen_window_(nullptr) {
|
| }
|
| ~AuraWindowRegistry() override {}
|
|
|
| // WindowObserver overrides.
|
| void OnWindowDestroying(aura::Window* window) override {
|
| + if (window == virtual_screen_window_) {
|
| + virtual_screen_window_ = nullptr;
|
| + return;
|
| + }
|
| std::map<aura::Window*, int>::iterator it = window_to_id_map_.find(window);
|
| DCHECK(it != window_to_id_map_.end());
|
| id_to_window_map_.erase(it->second);
|
| @@ -69,6 +82,8 @@ class AuraWindowRegistry : public aura::WindowObserver {
|
| std::map<aura::Window*, int> window_to_id_map_;
|
| std::map<int, aura::Window*> id_to_window_map_;
|
|
|
| + aura::Window* virtual_screen_window_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AuraWindowRegistry);
|
| };
|
|
|
| @@ -81,6 +96,7 @@ namespace content {
|
| const char kScreenPrefix[] = "screen";
|
| const char kWindowPrefix[] = "window";
|
| const char kAuraWindowPrefix[] = "aura_window";
|
| +const char kAuraVirtualScreenPrefix[] = "aura_virtual_screen";
|
|
|
| #if defined(USE_AURA)
|
|
|
| @@ -92,7 +108,15 @@ DesktopMediaID DesktopMediaID::RegisterAuraWindow(aura::Window* window) {
|
| }
|
|
|
| // static
|
| +void DesktopMediaID::RegisterVirtualScreenAuraWindow(aura::Window* window) {
|
| + AuraWindowRegistry::GetInstance()->RegisterVirtualScreenWindow(window);
|
| +}
|
| +
|
| +// static
|
| aura::Window* DesktopMediaID::GetAuraWindowById(const DesktopMediaID& id) {
|
| + if (id.type == TYPE_AURA_VIRTUAL_SCREEN)
|
| + return AuraWindowRegistry::GetInstance()->GetVirtualScreenWindow();
|
| +
|
| DCHECK_EQ(id.type, TYPE_AURA_WINDOW);
|
| return AuraWindowRegistry::GetInstance()->GetWindowById(id.id);
|
| }
|
| @@ -114,6 +138,8 @@ DesktopMediaID DesktopMediaID::Parse(const std::string& str) {
|
| type = TYPE_WINDOW;
|
| } else if (parts[0] == kAuraWindowPrefix) {
|
| type = TYPE_AURA_WINDOW;
|
| + } else if (parts[0] == kAuraVirtualScreenPrefix) {
|
| + type = TYPE_AURA_VIRTUAL_SCREEN;
|
| } else {
|
| return DesktopMediaID(TYPE_NONE, 0);
|
| }
|
| @@ -140,6 +166,9 @@ std::string DesktopMediaID::ToString() {
|
| case TYPE_AURA_WINDOW:
|
| prefix = kAuraWindowPrefix;
|
| break;
|
| + case TYPE_AURA_VIRTUAL_SCREEN:
|
| + prefix = kAuraVirtualScreenPrefix;
|
| + break;
|
| }
|
| DCHECK(!prefix.empty());
|
|
|
|
|