Chromium Code Reviews| 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/ui/views/ash/chrome_browser_main_extra_parts_ash.h" | 5 #include "chrome/browser/ui/views/ash/chrome_browser_main_extra_parts_ash.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/window_properties.h" | |
| 9 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 10 #include "chrome/browser/chrome_browser_main.h" | 11 #include "chrome/browser/chrome_browser_main.h" |
| 11 #include "chrome/browser/ui/ash/ash_init.h" | 12 #include "chrome/browser/ui/ash/ash_init.h" |
| 12 #include "chrome/browser/ui/ash/ash_util.h" | 13 #include "chrome/browser/ui/ash/ash_util.h" |
| 13 #include "chrome/browser/ui/ash/cast_config_client_media_router.h" | 14 #include "chrome/browser/ui/ash/cast_config_client_media_router.h" |
| 14 #include "chrome/browser/ui/ash/chrome_new_window_client.h" | 15 #include "chrome/browser/ui/ash/chrome_new_window_client.h" |
| 15 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" | 16 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" |
| 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h" | 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h" |
| 17 #include "chrome/browser/ui/ash/media_client.h" | 18 #include "chrome/browser/ui/ash/media_client.h" |
| 18 #include "chrome/browser/ui/ash/session_controller_client.h" | 19 #include "chrome/browser/ui/ash/session_controller_client.h" |
| 19 #include "chrome/browser/ui/ash/system_tray_client.h" | 20 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 20 #include "chrome/browser/ui/ash/volume_controller.h" | 21 #include "chrome/browser/ui/ash/volume_controller.h" |
| 21 #include "chrome/browser/ui/ash/vpn_list_forwarder.h" | 22 #include "chrome/browser/ui/ash/vpn_list_forwarder.h" |
| 22 #include "chrome/browser/ui/views/ash/tab_scrubber.h" | 23 #include "chrome/browser/ui/views/ash/tab_scrubber.h" |
| 23 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" | 24 #include "chrome/browser/ui/views/chrome_browser_main_extra_parts_views.h" |
| 24 #include "chrome/browser/ui/views/frame/immersive_context_mus.h" | 25 #include "chrome/browser/ui/views/frame/immersive_context_mus.h" |
| 25 #include "chrome/browser/ui/views/frame/immersive_handler_factory_mus.h" | 26 #include "chrome/browser/ui/views/frame/immersive_handler_factory_mus.h" |
| 26 #include "chrome/browser/ui/views/select_file_dialog_extension.h" | 27 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
| 27 #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h" | 28 #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h" |
| 29 #include "ui/aura/client/aura_constants.h" | |
| 30 #include "ui/aura/mus/property_converter.h" | |
| 31 #include "ui/aura/window_property.h" | |
| 28 #include "ui/keyboard/content/keyboard.h" | 32 #include "ui/keyboard/content/keyboard.h" |
| 29 #include "ui/keyboard/keyboard_controller.h" | 33 #include "ui/keyboard/keyboard_controller.h" |
| 34 #include "ui/views/mus/mus_client.h" | |
| 35 #include "ui/views/mus/mus_client_observer.h" | |
| 30 #include "ui/wm/core/capture_controller.h" | 36 #include "ui/wm/core/capture_controller.h" |
| 31 #include "ui/wm/core/wm_state.h" | 37 #include "ui/wm/core/wm_state.h" |
| 32 | 38 |
| 39 // Relays known aura window properties to the grandparent (the mash frame). | |
| 40 class WindowPropertyRelay : public views::MusClientObserver { | |
| 41 public: | |
| 42 explicit WindowPropertyRelay(views::MusClient* mus_client) | |
| 43 : mus_client_(mus_client) { | |
| 44 mus_client_->AddObserver(this); | |
| 45 } | |
| 46 | |
| 47 ~WindowPropertyRelay() override { mus_client_->RemoveObserver(this); } | |
| 48 | |
| 49 // MusClientObserver: | |
| 50 void OnWindowManagerFrameValuesChanged() override {} | |
| 51 void OnWindowPropertyChanged(aura::Window* window, const void* key) override { | |
| 52 if (!window->parent() || !window->parent()->parent()) | |
| 53 return; | |
| 54 aura::Window* grandparent = window->parent()->parent(); | |
| 55 if (key == ash::kShelfIDKey) { | |
| 56 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
| |
| 57 grandparent->SetProperty(ash::kShelfIDKey, value); | |
| 58 } else if (key == ash::kShelfItemTypeKey) { | |
| 59 int32_t value = window->GetProperty(ash::kShelfItemTypeKey); | |
| 60 grandparent->SetProperty(ash::kShelfItemTypeKey, value); | |
| 61 } else if (key == aura::client::kAppIconKey) { | |
| 62 gfx::ImageSkia* value = window->GetProperty(aura::client::kAppIconKey); | |
| 63 grandparent->SetProperty(aura::client::kAppIconKey, value); | |
| 64 } else if (key == aura::client::kAppIdKey) { | |
| 65 std::string* value = window->GetProperty(aura::client::kAppIdKey); | |
| 66 grandparent->SetProperty(aura::client::kAppIdKey, value); | |
| 67 } else if (key == aura::client::kDrawAttentionKey) { | |
| 68 bool value = window->GetProperty(aura::client::kDrawAttentionKey); | |
| 69 grandparent->SetProperty(aura::client::kDrawAttentionKey, value); | |
| 70 } else if (key == aura::client::kTitleKey) { | |
| 71 base::string16* value = window->GetProperty(aura::client::kTitleKey); | |
| 72 grandparent->SetProperty(aura::client::kTitleKey, value); | |
| 73 } else if (key == aura::client::kWindowIconKey) { | |
| 74 gfx::ImageSkia* value = window->GetProperty(aura::client::kWindowIconKey); | |
| 75 grandparent->SetProperty(aura::client::kWindowIconKey, value); | |
| 76 } | |
| 77 } | |
| 78 | |
| 79 private: | |
| 80 views::MusClient* mus_client_; | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(WindowPropertyRelay); | |
| 83 }; | |
| 84 | |
| 33 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh( | 85 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh( |
| 34 ChromeBrowserMainExtraPartsViews* extra_parts_views) | 86 ChromeBrowserMainExtraPartsViews* extra_parts_views) |
| 35 : extra_parts_views_(extra_parts_views) {} | 87 : extra_parts_views_(extra_parts_views) {} |
| 36 | 88 |
| 37 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} | 89 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} |
| 38 | 90 |
| 91 void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( | |
| 92 content::ServiceManagerConnection* connection) { | |
| 93 if (chrome::IsRunningInMash()) { | |
| 94 // Register ash-specific window properties with Chrome's property converter. | |
| 95 // This propagates ash properties set on chrome windows to ash, via mojo. | |
| 96 DCHECK(views::MusClient::Exists()); | |
| 97 views::MusClient* mus_client = views::MusClient::Get(); | |
| 98 aura::WindowTreeClientDelegate* delegate = mus_client; | |
| 99 aura::PropertyConverter* converter = delegate->GetPropertyConverter(); | |
| 100 converter->RegisterProperty( | |
| 101 ash::kPanelAttachedKey, | |
| 102 ui::mojom::WindowManager::kPanelAttached_Property); | |
| 103 converter->RegisterProperty( | |
| 104 ash::kShelfItemTypeKey, | |
| 105 ui::mojom::WindowManager::kShelfItemType_Property); | |
| 106 window_property_relay_ = base::MakeUnique<WindowPropertyRelay>(mus_client); | |
| 107 } | |
| 108 } | |
| 109 | |
| 39 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { | 110 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
| 40 if (chrome::ShouldOpenAshOnStartup()) | 111 if (chrome::ShouldOpenAshOnStartup()) |
| 41 chrome::OpenAsh(gfx::kNullAcceleratedWidget); | 112 chrome::OpenAsh(gfx::kNullAcceleratedWidget); |
| 42 | 113 |
| 43 if (chrome::IsRunningInMash()) { | 114 if (chrome::IsRunningInMash()) { |
| 44 immersive_context_ = base::MakeUnique<ImmersiveContextMus>( | 115 immersive_context_ = base::MakeUnique<ImmersiveContextMus>( |
| 45 extra_parts_views_->wm_state()->capture_controller()); | 116 extra_parts_views_->wm_state()->capture_controller()); |
| 46 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryMus>(); | 117 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryMus>(); |
| 47 } | 118 } |
| 48 | 119 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 vpn_list_forwarder_.reset(); | 162 vpn_list_forwarder_.reset(); |
| 92 volume_controller_.reset(); | 163 volume_controller_.reset(); |
| 93 new_window_client_.reset(); | 164 new_window_client_.reset(); |
| 94 system_tray_client_.reset(); | 165 system_tray_client_.reset(); |
| 95 media_client_.reset(); | 166 media_client_.reset(); |
| 96 cast_config_client_media_router_.reset(); | 167 cast_config_client_media_router_.reset(); |
| 97 session_controller_client_.reset(); | 168 session_controller_client_.reset(); |
| 98 | 169 |
| 99 chrome::CloseAsh(); | 170 chrome::CloseAsh(); |
| 100 } | 171 } |
| OLD | NEW |