| 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/public/cpp/mus_property_mirror_ash.h" |
| 8 #include "ash/public/cpp/window_properties.h" |
| 7 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 8 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 9 #include "ash/wm/window_properties.h" | |
| 10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 11 #include "chrome/browser/chrome_browser_main.h" | 12 #include "chrome/browser/chrome_browser_main.h" |
| 12 #include "chrome/browser/ui/ash/ash_init.h" | 13 #include "chrome/browser/ui/ash/ash_init.h" |
| 13 #include "chrome/browser/ui/ash/ash_util.h" | 14 #include "chrome/browser/ui/ash/ash_util.h" |
| 14 #include "chrome/browser/ui/ash/cast_config_client_media_router.h" | 15 #include "chrome/browser/ui/ash/cast_config_client_media_router.h" |
| 15 #include "chrome/browser/ui/ash/chrome_new_window_client.h" | 16 #include "chrome/browser/ui/ash/chrome_new_window_client.h" |
| 16 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" | 17 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" |
| 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h" | 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h" |
| 18 #include "chrome/browser/ui/ash/media_client.h" | 19 #include "chrome/browser/ui/ash/media_client.h" |
| 19 #include "chrome/browser/ui/ash/session_controller_client.h" | 20 #include "chrome/browser/ui/ash/session_controller_client.h" |
| 20 #include "chrome/browser/ui/ash/system_tray_client.h" | 21 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 21 #include "chrome/browser/ui/ash/volume_controller.h" | 22 #include "chrome/browser/ui/ash/volume_controller.h" |
| 22 #include "chrome/browser/ui/ash/vpn_list_forwarder.h" | 23 #include "chrome/browser/ui/ash/vpn_list_forwarder.h" |
| 23 #include "chrome/browser/ui/views/ash/tab_scrubber.h" | 24 #include "chrome/browser/ui/views/ash/tab_scrubber.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" |
| 28 #include "ui/aura/client/aura_constants.h" | |
| 29 #include "ui/aura/mus/property_converter.h" | 29 #include "ui/aura/mus/property_converter.h" |
| 30 #include "ui/base/class_property.h" | 30 #include "ui/base/class_property.h" |
| 31 #include "ui/keyboard/content/keyboard.h" | 31 #include "ui/keyboard/content/keyboard.h" |
| 32 #include "ui/keyboard/keyboard_controller.h" | 32 #include "ui/keyboard/keyboard_controller.h" |
| 33 #include "ui/views/mus/mus_client.h" | 33 #include "ui/views/mus/mus_client.h" |
| 34 #include "ui/views/mus/mus_property_mirror.h" | |
| 35 | |
| 36 namespace { | |
| 37 | |
| 38 void MirrorIcon(aura::Window* window, | |
| 39 aura::Window* root_window, | |
| 40 const aura::WindowProperty<gfx::ImageSkia*>* key) { | |
| 41 gfx::ImageSkia* value = window->GetProperty(key); | |
| 42 if (!value || value->isNull()) | |
| 43 root_window->ClearProperty(key); | |
| 44 else | |
| 45 root_window->SetProperty(key, new gfx::ImageSkia(*value)); | |
| 46 } | |
| 47 | |
| 48 } // namespace | |
| 49 | |
| 50 // Relays aura content window properties to its root window (the mash frame). | |
| 51 // Ash relies on various window properties for frame titles, shelf items, etc. | |
| 52 // These properties are read from the client's root, not child content windows. | |
| 53 class MusPropertyMirrorAsh : public views::MusPropertyMirror { | |
| 54 public: | |
| 55 MusPropertyMirrorAsh() {} | |
| 56 ~MusPropertyMirrorAsh() override {} | |
| 57 | |
| 58 // MusPropertyMirror: | |
| 59 void MirrorPropertyFromWidgetWindowToRootWindow(aura::Window* window, | |
| 60 aura::Window* root_window, | |
| 61 const void* key) override { | |
| 62 if (key == ash::kShelfIDKey) { | |
| 63 int32_t value = window->GetProperty(ash::kShelfIDKey); | |
| 64 root_window->SetProperty(ash::kShelfIDKey, value); | |
| 65 } else if (key == ash::kShelfItemTypeKey) { | |
| 66 int32_t value = window->GetProperty(ash::kShelfItemTypeKey); | |
| 67 root_window->SetProperty(ash::kShelfItemTypeKey, value); | |
| 68 } else if (key == aura::client::kAppIconKey) { | |
| 69 MirrorIcon(window, root_window, aura::client::kAppIconKey); | |
| 70 } else if (key == aura::client::kAppIdKey) { | |
| 71 std::string* value = window->GetProperty(aura::client::kAppIdKey); | |
| 72 root_window->SetProperty(aura::client::kAppIdKey, value); | |
| 73 } else if (key == aura::client::kDrawAttentionKey) { | |
| 74 bool value = window->GetProperty(aura::client::kDrawAttentionKey); | |
| 75 root_window->SetProperty(aura::client::kDrawAttentionKey, value); | |
| 76 } else if (key == aura::client::kTitleKey) { | |
| 77 base::string16* value = window->GetProperty(aura::client::kTitleKey); | |
| 78 root_window->SetProperty(aura::client::kTitleKey, value); | |
| 79 } else if (key == aura::client::kWindowIconKey) { | |
| 80 MirrorIcon(window, root_window, aura::client::kWindowIconKey); | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 private: | |
| 85 DISALLOW_COPY_AND_ASSIGN(MusPropertyMirrorAsh); | |
| 86 }; | |
| 87 | 34 |
| 88 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {} | 35 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {} |
| 89 | 36 |
| 90 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} | 37 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} |
| 91 | 38 |
| 92 void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( | 39 void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( |
| 93 content::ServiceManagerConnection* connection) { | 40 content::ServiceManagerConnection* connection) { |
| 94 if (chrome::IsRunningInMash()) { | 41 if (chrome::IsRunningInMash()) { |
| 95 // Register ash-specific window properties with Chrome's property converter. | 42 // Register ash-specific window properties with Chrome's property converter. |
| 96 // This propagates ash properties set on chrome windows to ash, via mojo. | 43 // This propagates ash properties set on chrome windows to ash, via mojo. |
| 97 DCHECK(views::MusClient::Exists()); | 44 DCHECK(views::MusClient::Exists()); |
| 98 views::MusClient* mus_client = views::MusClient::Get(); | 45 views::MusClient* mus_client = views::MusClient::Get(); |
| 99 aura::WindowTreeClientDelegate* delegate = mus_client; | 46 aura::WindowTreeClientDelegate* delegate = mus_client; |
| 100 aura::PropertyConverter* converter = delegate->GetPropertyConverter(); | 47 aura::PropertyConverter* converter = delegate->GetPropertyConverter(); |
| 101 converter->RegisterProperty( | 48 converter->RegisterProperty( |
| 102 ash::kPanelAttachedKey, | 49 ash::kPanelAttachedKey, |
| 103 ui::mojom::WindowManager::kPanelAttached_Property); | 50 ui::mojom::WindowManager::kPanelAttached_Property); |
| 104 converter->RegisterProperty( | 51 converter->RegisterProperty( |
| 105 ash::kShelfItemTypeKey, | 52 ash::kShelfItemTypeKey, |
| 106 ui::mojom::WindowManager::kShelfItemType_Property); | 53 ui::mojom::WindowManager::kShelfItemType_Property); |
| 107 | 54 |
| 108 mus_client->SetMusPropertyMirror(base::MakeUnique<MusPropertyMirrorAsh>()); | 55 mus_client->SetMusPropertyMirror( |
| 56 base::MakeUnique<ash::MusPropertyMirrorAsh>()); |
| 109 } | 57 } |
| 110 } | 58 } |
| 111 | 59 |
| 112 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { | 60 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
| 113 if (chrome::ShouldOpenAshOnStartup()) | 61 if (chrome::ShouldOpenAshOnStartup()) |
| 114 chrome::OpenAsh(gfx::kNullAcceleratedWidget); | 62 chrome::OpenAsh(gfx::kNullAcceleratedWidget); |
| 115 | 63 |
| 116 if (chrome::IsRunningInMash()) { | 64 if (chrome::IsRunningInMash()) { |
| 117 immersive_context_ = base::MakeUnique<ImmersiveContextMus>(); | 65 immersive_context_ = base::MakeUnique<ImmersiveContextMus>(); |
| 118 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryMus>(); | 66 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryMus>(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 vpn_list_forwarder_.reset(); | 111 vpn_list_forwarder_.reset(); |
| 164 volume_controller_.reset(); | 112 volume_controller_.reset(); |
| 165 new_window_client_.reset(); | 113 new_window_client_.reset(); |
| 166 system_tray_client_.reset(); | 114 system_tray_client_.reset(); |
| 167 media_client_.reset(); | 115 media_client_.reset(); |
| 168 cast_config_client_media_router_.reset(); | 116 cast_config_client_media_router_.reset(); |
| 169 session_controller_client_.reset(); | 117 session_controller_client_.reset(); |
| 170 | 118 |
| 171 chrome::CloseAsh(); | 119 chrome::CloseAsh(); |
| 172 } | 120 } |
| OLD | NEW |