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 04862feaa232e9d644e65f2170f50ca1b861c922..011695771f1b7021a95d962944d5c10aef102df3 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" |
| @@ -24,13 +25,80 @@ |
| #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_property_mirror.h" |
| + |
| +// Relays aura content window properties to its root window (the mash frame). |
|
sky
2017/01/27 20:10:45
Explain why this is done.
msw
2017/01/27 21:19:25
Done. (I attempted to give a clear explanation, su
|
| +class MusPropertyMirrorAsh : public views::MusPropertyMirror { |
| + public: |
| + MusPropertyMirrorAsh() {} |
| + ~MusPropertyMirrorAsh() override {} |
| + |
| + // MusPropertyMirror: |
| + void MirrorPropertyFromWidgetWindowToRootWindow(aura::Window* window, |
| + const void* key) override { |
| + DCHECK(!window->IsRootWindow()); |
| + aura::Window* root_window = window->GetRootWindow(); |
| + if (!root_window) |
| + return; |
| + if (key == ash::kShelfIDKey) { |
| + int32_t value = window->GetProperty(ash::kShelfIDKey); |
| + root_window->SetProperty(ash::kShelfIDKey, value); |
| + } else if (key == ash::kShelfItemTypeKey) { |
| + int32_t value = window->GetProperty(ash::kShelfItemTypeKey); |
| + root_window->SetProperty(ash::kShelfItemTypeKey, value); |
| + } else if (key == aura::client::kAppIconKey) { |
| + gfx::ImageSkia* value = window->GetProperty(aura::client::kAppIconKey); |
| + root_window->SetProperty(aura::client::kAppIconKey, value); |
| + } else if (key == aura::client::kAppIdKey) { |
| + std::string* value = window->GetProperty(aura::client::kAppIdKey); |
| + root_window->SetProperty(aura::client::kAppIdKey, value); |
| + } else if (key == aura::client::kDrawAttentionKey) { |
| + bool value = window->GetProperty(aura::client::kDrawAttentionKey); |
| + root_window->SetProperty(aura::client::kDrawAttentionKey, value); |
| + } else if (key == aura::client::kTitleKey) { |
| + base::string16* value = window->GetProperty(aura::client::kTitleKey); |
| + root_window->SetProperty(aura::client::kTitleKey, value); |
| + } else if (key == aura::client::kWindowIconKey) { |
| + gfx::ImageSkia* value = window->GetProperty(aura::client::kWindowIconKey); |
| + root_window->SetProperty(aura::client::kWindowIconKey, value); |
| + } |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(MusPropertyMirrorAsh); |
| +}; |
| ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {} |
| 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); |
| + |
| + mus_client->set_mus_property_mirror( |
| + base::MakeUnique<MusPropertyMirrorAsh>()); |
| + } |
| +} |
| + |
| void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
| if (chrome::ShouldOpenAshOnStartup()) |
| chrome::OpenAsh(gfx::kNullAcceleratedWidget); |