| 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" | |
| 9 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 10 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/wm/window_properties.h" |
| 11 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 12 #include "chrome/browser/chrome_browser_main.h" | 11 #include "chrome/browser/chrome_browser_main.h" |
| 13 #include "chrome/browser/ui/ash/ash_init.h" | 12 #include "chrome/browser/ui/ash/ash_init.h" |
| 14 #include "chrome/browser/ui/ash/ash_util.h" | 13 #include "chrome/browser/ui/ash/ash_util.h" |
| 15 #include "chrome/browser/ui/ash/cast_config_client_media_router.h" | 14 #include "chrome/browser/ui/ash/cast_config_client_media_router.h" |
| 16 #include "chrome/browser/ui/ash/chrome_new_window_client.h" | 15 #include "chrome/browser/ui/ash/chrome_new_window_client.h" |
| 17 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" | 16 #include "chrome/browser/ui/ash/chrome_shell_content_state.h" |
| 18 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h" | 17 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_mus.h" |
| 19 #include "chrome/browser/ui/ash/media_client.h" | 18 #include "chrome/browser/ui/ash/media_client.h" |
| 20 #include "chrome/browser/ui/ash/session_controller_client.h" | 19 #include "chrome/browser/ui/ash/session_controller_client.h" |
| 21 #include "chrome/browser/ui/ash/system_tray_client.h" | 20 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 22 #include "chrome/browser/ui/ash/volume_controller.h" | 21 #include "chrome/browser/ui/ash/volume_controller.h" |
| 23 #include "chrome/browser/ui/ash/vpn_list_forwarder.h" | 22 #include "chrome/browser/ui/ash/vpn_list_forwarder.h" |
| 24 #include "chrome/browser/ui/views/ash/tab_scrubber.h" | 23 #include "chrome/browser/ui/views/ash/tab_scrubber.h" |
| 25 #include "chrome/browser/ui/views/frame/immersive_context_mus.h" | 24 #include "chrome/browser/ui/views/frame/immersive_context_mus.h" |
| 26 #include "chrome/browser/ui/views/frame/immersive_handler_factory_mus.h" | 25 #include "chrome/browser/ui/views/frame/immersive_handler_factory_mus.h" |
| 27 #include "chrome/browser/ui/views/select_file_dialog_extension.h" | 26 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
| 28 #include "chrome/browser/ui/views/select_file_dialog_extension_factory.h" | 27 #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 }; |
| 34 | 87 |
| 35 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {} | 88 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {} |
| 36 | 89 |
| 37 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} | 90 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} |
| 38 | 91 |
| 39 void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( | 92 void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( |
| 40 content::ServiceManagerConnection* connection) { | 93 content::ServiceManagerConnection* connection) { |
| 41 if (chrome::IsRunningInMash()) { | 94 if (chrome::IsRunningInMash()) { |
| 42 // Register ash-specific window properties with Chrome's property converter. | 95 // Register ash-specific window properties with Chrome's property converter. |
| 43 // This propagates ash properties set on chrome windows to ash, via mojo. | 96 // This propagates ash properties set on chrome windows to ash, via mojo. |
| 44 DCHECK(views::MusClient::Exists()); | 97 DCHECK(views::MusClient::Exists()); |
| 45 views::MusClient* mus_client = views::MusClient::Get(); | 98 views::MusClient* mus_client = views::MusClient::Get(); |
| 46 aura::WindowTreeClientDelegate* delegate = mus_client; | 99 aura::WindowTreeClientDelegate* delegate = mus_client; |
| 47 aura::PropertyConverter* converter = delegate->GetPropertyConverter(); | 100 aura::PropertyConverter* converter = delegate->GetPropertyConverter(); |
| 48 converter->RegisterProperty( | 101 converter->RegisterProperty( |
| 49 ash::kPanelAttachedKey, | 102 ash::kPanelAttachedKey, |
| 50 ui::mojom::WindowManager::kPanelAttached_Property); | 103 ui::mojom::WindowManager::kPanelAttached_Property); |
| 51 converter->RegisterProperty( | 104 converter->RegisterProperty( |
| 52 ash::kShelfItemTypeKey, | 105 ash::kShelfItemTypeKey, |
| 53 ui::mojom::WindowManager::kShelfItemType_Property); | 106 ui::mojom::WindowManager::kShelfItemType_Property); |
| 54 | 107 |
| 55 mus_client->SetMusPropertyMirror( | 108 mus_client->SetMusPropertyMirror(base::MakeUnique<MusPropertyMirrorAsh>()); |
| 56 base::MakeUnique<ash::MusPropertyMirrorAsh>()); | |
| 57 } | 109 } |
| 58 } | 110 } |
| 59 | 111 |
| 60 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { | 112 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
| 61 if (chrome::ShouldOpenAshOnStartup()) | 113 if (chrome::ShouldOpenAshOnStartup()) |
| 62 chrome::OpenAsh(gfx::kNullAcceleratedWidget); | 114 chrome::OpenAsh(gfx::kNullAcceleratedWidget); |
| 63 | 115 |
| 64 if (chrome::IsRunningInMash()) { | 116 if (chrome::IsRunningInMash()) { |
| 65 immersive_context_ = base::MakeUnique<ImmersiveContextMus>(); | 117 immersive_context_ = base::MakeUnique<ImmersiveContextMus>(); |
| 66 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryMus>(); | 118 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryMus>(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 vpn_list_forwarder_.reset(); | 163 vpn_list_forwarder_.reset(); |
| 112 volume_controller_.reset(); | 164 volume_controller_.reset(); |
| 113 new_window_client_.reset(); | 165 new_window_client_.reset(); |
| 114 system_tray_client_.reset(); | 166 system_tray_client_.reset(); |
| 115 media_client_.reset(); | 167 media_client_.reset(); |
| 116 cast_config_client_media_router_.reset(); | 168 cast_config_client_media_router_.reset(); |
| 117 session_controller_client_.reset(); | 169 session_controller_client_.reset(); |
| 118 | 170 |
| 119 chrome::CloseAsh(); | 171 chrome::CloseAsh(); |
| 120 } | 172 } |
| OLD | NEW |