| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" | 5 #include "ash/common/system/chromeos/virtual_keyboard/virtual_keyboard_tray.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "ash/common/keyboard/keyboard_ui.h" | 9 #include "ash/common/keyboard/keyboard_ui.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 icon_->SetImage(image_md); | 34 icon_->SetImage(image_md); |
| 35 } else { | 35 } else { |
| 36 gfx::ImageSkia* image_non_md = | 36 gfx::ImageSkia* image_non_md = |
| 37 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 37 ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 38 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD); | 38 IDR_AURA_UBER_TRAY_VIRTUAL_KEYBOARD); |
| 39 icon_->SetImage(image_non_md); | 39 icon_->SetImage(image_non_md); |
| 40 } | 40 } |
| 41 | 41 |
| 42 SetIconBorderForShelfAlignment(); | 42 SetIconBorderForShelfAlignment(); |
| 43 tray_container()->AddChildView(icon_); | 43 tray_container()->AddChildView(icon_); |
| 44 SetContentsBackground(); | 44 SetContentsBackground(true); |
| 45 // The Shell may not exist in some unit tests. | 45 // The Shell may not exist in some unit tests. |
| 46 if (WmShell::HasInstance()) | 46 if (WmShell::HasInstance()) |
| 47 WmShell::Get()->keyboard_ui()->AddObserver(this); | 47 WmShell::Get()->keyboard_ui()->AddObserver(this); |
| 48 // Try observing keyboard controller, in case it is already constructed. | 48 // Try observing keyboard controller, in case it is already constructed. |
| 49 ObserveKeyboardController(); | 49 ObserveKeyboardController(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 VirtualKeyboardTray::~VirtualKeyboardTray() { | 52 VirtualKeyboardTray::~VirtualKeyboardTray() { |
| 53 // Try unobserving keyboard controller, in case it still exists. | 53 // Try unobserving keyboard controller, in case it still exists. |
| 54 UnobserveKeyboardController(); | 54 UnobserveKeyboardController(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // shown/hidden. | 87 // shown/hidden. |
| 88 ObserveKeyboardController(); | 88 ObserveKeyboardController(); |
| 89 } else { | 89 } else { |
| 90 // Try unobserving keyboard controller, in case it is not yet destroyed. | 90 // Try unobserving keyboard controller, in case it is not yet destroyed. |
| 91 UnobserveKeyboardController(); | 91 UnobserveKeyboardController(); |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 | 94 |
| 95 void VirtualKeyboardTray::OnKeyboardBoundsChanging( | 95 void VirtualKeyboardTray::OnKeyboardBoundsChanging( |
| 96 const gfx::Rect& new_bounds) { | 96 const gfx::Rect& new_bounds) { |
| 97 SetDrawBackgroundAsActive(!new_bounds.IsEmpty()); | 97 SetIsActive(!new_bounds.IsEmpty()); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void VirtualKeyboardTray::OnKeyboardClosed() {} | 100 void VirtualKeyboardTray::OnKeyboardClosed() {} |
| 101 | 101 |
| 102 void VirtualKeyboardTray::SetIconBorderForShelfAlignment() { | 102 void VirtualKeyboardTray::SetIconBorderForShelfAlignment() { |
| 103 // Every time shelf alignment is updated, StatusAreaWidgetDelegate resets the | 103 // Every time shelf alignment is updated, StatusAreaWidgetDelegate resets the |
| 104 // border to a non-null border. So, we need to remove it. | 104 // border to a non-null border. So, we need to remove it. |
| 105 if (!ash::MaterialDesignController::IsShelfMaterial()) | 105 if (!ash::MaterialDesignController::IsShelfMaterial()) |
| 106 tray_container()->SetBorder(views::NullBorder()); | 106 tray_container()->SetBorder(views::NullBorder()); |
| 107 const gfx::ImageSkia& image = icon_->GetImage(); | 107 const gfx::ImageSkia& image = icon_->GetImage(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 void VirtualKeyboardTray::UnobserveKeyboardController() { | 129 void VirtualKeyboardTray::UnobserveKeyboardController() { |
| 130 keyboard::KeyboardController* keyboard_controller = | 130 keyboard::KeyboardController* keyboard_controller = |
| 131 keyboard::KeyboardController::GetInstance(); | 131 keyboard::KeyboardController::GetInstance(); |
| 132 if (keyboard_controller) | 132 if (keyboard_controller) |
| 133 keyboard_controller->RemoveObserver(this); | 133 keyboard_controller->RemoveObserver(this); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace ash | 136 } // namespace ash |
| OLD | NEW |