Chromium Code Reviews| Index: chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc |
| diff --git a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc |
| index b015a0530e8a33db14487e3161136dcbfa9eb4bc..91e029a03ffa4c0a88f8e1ba28c5706d079448b2 100644 |
| --- a/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc |
| +++ b/chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.cc |
| @@ -6,6 +6,7 @@ |
| #include "ash/root_window_controller.h" |
| #include "ash/shell.h" |
| +#include "ash/wm/window_properties.h" |
| #include "base/memory/ptr_util.h" |
| #include "chrome/browser/chrome_browser_main.h" |
| #include "chrome/browser/ui/ash/ash_init.h" |
| @@ -25,17 +26,87 @@ |
| #include "chrome/browser/ui/views/frame/immersive_handler_factory_mus.h" |
| #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
| #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h" |
| +#include "ui/aura/client/aura_constants.h" |
| +#include "ui/aura/mus/property_converter.h" |
| +#include "ui/aura/window_property.h" |
| #include "ui/keyboard/content/keyboard.h" |
| #include "ui/keyboard/keyboard_controller.h" |
| +#include "ui/views/mus/mus_client.h" |
| +#include "ui/views/mus/mus_client_observer.h" |
| #include "ui/wm/core/capture_controller.h" |
| #include "ui/wm/core/wm_state.h" |
| +// Relays known aura window properties to the grandparent (the mash frame). |
| +class WindowPropertyRelay : public views::MusClientObserver { |
| + public: |
| + explicit WindowPropertyRelay(views::MusClient* mus_client) |
| + : mus_client_(mus_client) { |
| + mus_client_->AddObserver(this); |
| + } |
| + |
| + ~WindowPropertyRelay() override { mus_client_->RemoveObserver(this); } |
| + |
| + // MusClientObserver: |
| + void OnWindowManagerFrameValuesChanged() override {} |
| + void OnWindowPropertyChanged(aura::Window* window, const void* key) override { |
| + if (!window->parent() || !window->parent()->parent()) |
| + return; |
| + aura::Window* grandparent = window->parent()->parent(); |
| + if (key == ash::kShelfIDKey) { |
| + int32_t value = window->GetProperty(ash::kShelfIDKey); |
|
sky
2017/01/27 16:20:20
This sure is ICK, isn't it!
msw
2017/01/27 19:11:34
Yup, let me know if you can envision a better appr
|
| + grandparent->SetProperty(ash::kShelfIDKey, value); |
| + } else if (key == ash::kShelfItemTypeKey) { |
| + int32_t value = window->GetProperty(ash::kShelfItemTypeKey); |
| + grandparent->SetProperty(ash::kShelfItemTypeKey, value); |
| + } else if (key == aura::client::kAppIconKey) { |
| + gfx::ImageSkia* value = window->GetProperty(aura::client::kAppIconKey); |
| + grandparent->SetProperty(aura::client::kAppIconKey, value); |
| + } else if (key == aura::client::kAppIdKey) { |
| + std::string* value = window->GetProperty(aura::client::kAppIdKey); |
| + grandparent->SetProperty(aura::client::kAppIdKey, value); |
| + } else if (key == aura::client::kDrawAttentionKey) { |
| + bool value = window->GetProperty(aura::client::kDrawAttentionKey); |
| + grandparent->SetProperty(aura::client::kDrawAttentionKey, value); |
| + } else if (key == aura::client::kTitleKey) { |
| + base::string16* value = window->GetProperty(aura::client::kTitleKey); |
| + grandparent->SetProperty(aura::client::kTitleKey, value); |
| + } else if (key == aura::client::kWindowIconKey) { |
| + gfx::ImageSkia* value = window->GetProperty(aura::client::kWindowIconKey); |
| + grandparent->SetProperty(aura::client::kWindowIconKey, value); |
| + } |
| + } |
| + |
| + private: |
| + views::MusClient* mus_client_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WindowPropertyRelay); |
| +}; |
| + |
| ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh( |
| ChromeBrowserMainExtraPartsViews* extra_parts_views) |
| : extra_parts_views_(extra_parts_views) {} |
| ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} |
| +void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( |
| + content::ServiceManagerConnection* connection) { |
| + if (chrome::IsRunningInMash()) { |
| + // Register ash-specific window properties with Chrome's property converter. |
| + // This propagates ash properties set on chrome windows to ash, via mojo. |
| + DCHECK(views::MusClient::Exists()); |
| + views::MusClient* mus_client = views::MusClient::Get(); |
| + aura::WindowTreeClientDelegate* delegate = mus_client; |
| + aura::PropertyConverter* converter = delegate->GetPropertyConverter(); |
| + converter->RegisterProperty( |
| + ash::kPanelAttachedKey, |
| + ui::mojom::WindowManager::kPanelAttached_Property); |
| + converter->RegisterProperty( |
| + ash::kShelfItemTypeKey, |
| + ui::mojom::WindowManager::kShelfItemType_Property); |
| + window_property_relay_ = base::MakeUnique<WindowPropertyRelay>(mus_client); |
| + } |
| +} |
| + |
| void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
| if (chrome::ShouldOpenAshOnStartup()) |
| chrome::OpenAsh(gfx::kNullAcceleratedWidget); |