| 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/frame/immersive_context_mus.h" | 24 #include "chrome/browser/ui/views/frame/immersive_context_mus.h" |
| 24 #include "chrome/browser/ui/views/frame/immersive_handler_factory_mus.h" | 25 #include "chrome/browser/ui/views/frame/immersive_handler_factory_mus.h" |
| 25 #include "chrome/browser/ui/views/select_file_dialog_extension.h" | 26 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
| 26 #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" |
| 30 #include "ui/aura/window_property.h" |
| 27 #include "ui/keyboard/content/keyboard.h" | 31 #include "ui/keyboard/content/keyboard.h" |
| 28 #include "ui/keyboard/keyboard_controller.h" | 32 #include "ui/keyboard/keyboard_controller.h" |
| 33 #include "ui/views/mus/mus_client.h" |
| 34 #include "ui/views/mus/mus_property_mirror.h" |
| 35 |
| 36 // Relays aura content window properties to its root window (the mash frame). |
| 37 // Ash relies on various window properties for frame titles, shelf items, etc. |
| 38 // These properties are read from the client's root, not child content windows. |
| 39 class MusPropertyMirrorAsh : public views::MusPropertyMirror { |
| 40 public: |
| 41 MusPropertyMirrorAsh() {} |
| 42 ~MusPropertyMirrorAsh() override {} |
| 43 |
| 44 // MusPropertyMirror: |
| 45 void MirrorPropertyFromWidgetWindowToRootWindow(aura::Window* window, |
| 46 aura::Window* root_window, |
| 47 const void* key) override { |
| 48 if (key == ash::kShelfIDKey) { |
| 49 int32_t value = window->GetProperty(ash::kShelfIDKey); |
| 50 root_window->SetProperty(ash::kShelfIDKey, value); |
| 51 } else if (key == ash::kShelfItemTypeKey) { |
| 52 int32_t value = window->GetProperty(ash::kShelfItemTypeKey); |
| 53 root_window->SetProperty(ash::kShelfItemTypeKey, value); |
| 54 } else if (key == aura::client::kAppIconKey) { |
| 55 gfx::ImageSkia* value = window->GetProperty(aura::client::kAppIconKey); |
| 56 root_window->SetProperty(aura::client::kAppIconKey, value); |
| 57 } else if (key == aura::client::kAppIdKey) { |
| 58 std::string* value = window->GetProperty(aura::client::kAppIdKey); |
| 59 root_window->SetProperty(aura::client::kAppIdKey, value); |
| 60 } else if (key == aura::client::kDrawAttentionKey) { |
| 61 bool value = window->GetProperty(aura::client::kDrawAttentionKey); |
| 62 root_window->SetProperty(aura::client::kDrawAttentionKey, value); |
| 63 } else if (key == aura::client::kTitleKey) { |
| 64 base::string16* value = window->GetProperty(aura::client::kTitleKey); |
| 65 root_window->SetProperty(aura::client::kTitleKey, value); |
| 66 } else if (key == aura::client::kWindowIconKey) { |
| 67 gfx::ImageSkia* value = window->GetProperty(aura::client::kWindowIconKey); |
| 68 root_window->SetProperty(aura::client::kWindowIconKey, value); |
| 69 } |
| 70 } |
| 71 |
| 72 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(MusPropertyMirrorAsh); |
| 74 }; |
| 29 | 75 |
| 30 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {} | 76 ChromeBrowserMainExtraPartsAsh::ChromeBrowserMainExtraPartsAsh() {} |
| 31 | 77 |
| 32 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} | 78 ChromeBrowserMainExtraPartsAsh::~ChromeBrowserMainExtraPartsAsh() {} |
| 33 | 79 |
| 80 void ChromeBrowserMainExtraPartsAsh::ServiceManagerConnectionStarted( |
| 81 content::ServiceManagerConnection* connection) { |
| 82 if (chrome::IsRunningInMash()) { |
| 83 // Register ash-specific window properties with Chrome's property converter. |
| 84 // This propagates ash properties set on chrome windows to ash, via mojo. |
| 85 DCHECK(views::MusClient::Exists()); |
| 86 views::MusClient* mus_client = views::MusClient::Get(); |
| 87 aura::WindowTreeClientDelegate* delegate = mus_client; |
| 88 aura::PropertyConverter* converter = delegate->GetPropertyConverter(); |
| 89 converter->RegisterProperty( |
| 90 ash::kPanelAttachedKey, |
| 91 ui::mojom::WindowManager::kPanelAttached_Property); |
| 92 converter->RegisterProperty( |
| 93 ash::kShelfItemTypeKey, |
| 94 ui::mojom::WindowManager::kShelfItemType_Property); |
| 95 |
| 96 mus_client->SetMusPropertyMirror(base::MakeUnique<MusPropertyMirrorAsh>()); |
| 97 } |
| 98 } |
| 99 |
| 34 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { | 100 void ChromeBrowserMainExtraPartsAsh::PreProfileInit() { |
| 35 if (chrome::ShouldOpenAshOnStartup()) | 101 if (chrome::ShouldOpenAshOnStartup()) |
| 36 chrome::OpenAsh(gfx::kNullAcceleratedWidget); | 102 chrome::OpenAsh(gfx::kNullAcceleratedWidget); |
| 37 | 103 |
| 38 if (chrome::IsRunningInMash()) { | 104 if (chrome::IsRunningInMash()) { |
| 39 immersive_context_ = base::MakeUnique<ImmersiveContextMus>(); | 105 immersive_context_ = base::MakeUnique<ImmersiveContextMus>(); |
| 40 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryMus>(); | 106 immersive_handler_factory_ = base::MakeUnique<ImmersiveHandlerFactoryMus>(); |
| 41 } | 107 } |
| 42 | 108 |
| 43 session_controller_client_ = base::MakeUnique<SessionControllerClient>(); | 109 session_controller_client_ = base::MakeUnique<SessionControllerClient>(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 vpn_list_forwarder_.reset(); | 151 vpn_list_forwarder_.reset(); |
| 86 volume_controller_.reset(); | 152 volume_controller_.reset(); |
| 87 new_window_client_.reset(); | 153 new_window_client_.reset(); |
| 88 system_tray_client_.reset(); | 154 system_tray_client_.reset(); |
| 89 media_client_.reset(); | 155 media_client_.reset(); |
| 90 cast_config_client_media_router_.reset(); | 156 cast_config_client_media_router_.reset(); |
| 91 session_controller_client_.reset(); | 157 session_controller_client_.reset(); |
| 92 | 158 |
| 93 chrome::CloseAsh(); | 159 chrome::CloseAsh(); |
| 94 } | 160 } |
| OLD | NEW |