| 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 "extensions/shell/browser/shell_desktop_controller.h" | 5 #include "extensions/shell/browser/shell_desktop_controller.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 // A simple layout manager that makes each new window fill its parent. | 47 // A simple layout manager that makes each new window fill its parent. |
| 48 class FillLayout : public aura::LayoutManager { | 48 class FillLayout : public aura::LayoutManager { |
| 49 public: | 49 public: |
| 50 FillLayout() {} | 50 FillLayout() {} |
| 51 virtual ~FillLayout() {} | 51 virtual ~FillLayout() {} |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 // aura::LayoutManager: | 54 // aura::LayoutManager: |
| 55 virtual void OnWindowResized() OVERRIDE {} | 55 virtual void OnWindowResized() override {} |
| 56 | 56 |
| 57 virtual void OnWindowAddedToLayout(aura::Window* child) OVERRIDE { | 57 virtual void OnWindowAddedToLayout(aura::Window* child) override { |
| 58 if (!child->parent()) | 58 if (!child->parent()) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 // Create a rect at 0,0 with the size of the parent. | 61 // Create a rect at 0,0 with the size of the parent. |
| 62 gfx::Size parent_size = child->parent()->bounds().size(); | 62 gfx::Size parent_size = child->parent()->bounds().size(); |
| 63 child->SetBounds(gfx::Rect(parent_size)); | 63 child->SetBounds(gfx::Rect(parent_size)); |
| 64 } | 64 } |
| 65 | 65 |
| 66 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) OVERRIDE {} | 66 virtual void OnWillRemoveWindowFromLayout(aura::Window* child) override {} |
| 67 | 67 |
| 68 virtual void OnWindowRemovedFromLayout(aura::Window* child) OVERRIDE {} | 68 virtual void OnWindowRemovedFromLayout(aura::Window* child) override {} |
| 69 | 69 |
| 70 virtual void OnChildWindowVisibilityChanged(aura::Window* child, | 70 virtual void OnChildWindowVisibilityChanged(aura::Window* child, |
| 71 bool visible) OVERRIDE {} | 71 bool visible) override {} |
| 72 | 72 |
| 73 virtual void SetChildBounds(aura::Window* child, | 73 virtual void SetChildBounds(aura::Window* child, |
| 74 const gfx::Rect& requested_bounds) OVERRIDE { | 74 const gfx::Rect& requested_bounds) override { |
| 75 SetChildBoundsDirect(child, requested_bounds); | 75 SetChildBoundsDirect(child, requested_bounds); |
| 76 } | 76 } |
| 77 | 77 |
| 78 DISALLOW_COPY_AND_ASSIGN(FillLayout); | 78 DISALLOW_COPY_AND_ASSIGN(FillLayout); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 // A class that bridges the gap between CursorManager and Aura. It borrows | 81 // A class that bridges the gap between CursorManager and Aura. It borrows |
| 82 // heavily from AshNativeCursorManager. | 82 // heavily from AshNativeCursorManager. |
| 83 class ShellNativeCursorManager : public wm::NativeCursorManager { | 83 class ShellNativeCursorManager : public wm::NativeCursorManager { |
| 84 public: | 84 public: |
| 85 explicit ShellNativeCursorManager(aura::WindowTreeHost* host) | 85 explicit ShellNativeCursorManager(aura::WindowTreeHost* host) |
| 86 : host_(host), image_cursors_(new ui::ImageCursors) {} | 86 : host_(host), image_cursors_(new ui::ImageCursors) {} |
| 87 virtual ~ShellNativeCursorManager() {} | 87 virtual ~ShellNativeCursorManager() {} |
| 88 | 88 |
| 89 // wm::NativeCursorManager overrides. | 89 // wm::NativeCursorManager overrides. |
| 90 virtual void SetDisplay(const gfx::Display& display, | 90 virtual void SetDisplay(const gfx::Display& display, |
| 91 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 91 wm::NativeCursorManagerDelegate* delegate) override { |
| 92 if (image_cursors_->SetDisplay(display, display.device_scale_factor())) | 92 if (image_cursors_->SetDisplay(display, display.device_scale_factor())) |
| 93 SetCursor(delegate->GetCursor(), delegate); | 93 SetCursor(delegate->GetCursor(), delegate); |
| 94 } | 94 } |
| 95 | 95 |
| 96 virtual void SetCursor(gfx::NativeCursor cursor, | 96 virtual void SetCursor(gfx::NativeCursor cursor, |
| 97 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 97 wm::NativeCursorManagerDelegate* delegate) override { |
| 98 image_cursors_->SetPlatformCursor(&cursor); | 98 image_cursors_->SetPlatformCursor(&cursor); |
| 99 cursor.set_device_scale_factor(image_cursors_->GetScale()); | 99 cursor.set_device_scale_factor(image_cursors_->GetScale()); |
| 100 delegate->CommitCursor(cursor); | 100 delegate->CommitCursor(cursor); |
| 101 | 101 |
| 102 if (delegate->IsCursorVisible()) | 102 if (delegate->IsCursorVisible()) |
| 103 ApplyCursor(cursor); | 103 ApplyCursor(cursor); |
| 104 } | 104 } |
| 105 | 105 |
| 106 virtual void SetVisibility( | 106 virtual void SetVisibility( |
| 107 bool visible, | 107 bool visible, |
| 108 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 108 wm::NativeCursorManagerDelegate* delegate) override { |
| 109 delegate->CommitVisibility(visible); | 109 delegate->CommitVisibility(visible); |
| 110 | 110 |
| 111 if (visible) { | 111 if (visible) { |
| 112 SetCursor(delegate->GetCursor(), delegate); | 112 SetCursor(delegate->GetCursor(), delegate); |
| 113 } else { | 113 } else { |
| 114 gfx::NativeCursor invisible_cursor(ui::kCursorNone); | 114 gfx::NativeCursor invisible_cursor(ui::kCursorNone); |
| 115 image_cursors_->SetPlatformCursor(&invisible_cursor); | 115 image_cursors_->SetPlatformCursor(&invisible_cursor); |
| 116 ApplyCursor(invisible_cursor); | 116 ApplyCursor(invisible_cursor); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 virtual void SetCursorSet( | 120 virtual void SetCursorSet( |
| 121 ui::CursorSetType cursor_set, | 121 ui::CursorSetType cursor_set, |
| 122 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 122 wm::NativeCursorManagerDelegate* delegate) override { |
| 123 image_cursors_->SetCursorSet(cursor_set); | 123 image_cursors_->SetCursorSet(cursor_set); |
| 124 delegate->CommitCursorSet(cursor_set); | 124 delegate->CommitCursorSet(cursor_set); |
| 125 if (delegate->IsCursorVisible()) | 125 if (delegate->IsCursorVisible()) |
| 126 SetCursor(delegate->GetCursor(), delegate); | 126 SetCursor(delegate->GetCursor(), delegate); |
| 127 } | 127 } |
| 128 | 128 |
| 129 virtual void SetMouseEventsEnabled( | 129 virtual void SetMouseEventsEnabled( |
| 130 bool enabled, | 130 bool enabled, |
| 131 wm::NativeCursorManagerDelegate* delegate) OVERRIDE { | 131 wm::NativeCursorManagerDelegate* delegate) override { |
| 132 delegate->CommitMouseEventsEnabled(enabled); | 132 delegate->CommitMouseEventsEnabled(enabled); |
| 133 SetVisibility(delegate->IsCursorVisible(), delegate); | 133 SetVisibility(delegate->IsCursorVisible(), delegate); |
| 134 } | 134 } |
| 135 | 135 |
| 136 private: | 136 private: |
| 137 // Sets |cursor| as the active cursor within Aura. | 137 // Sets |cursor| as the active cursor within Aura. |
| 138 void ApplyCursor(gfx::NativeCursor cursor) { host_->SetCursor(cursor); } | 138 void ApplyCursor(gfx::NativeCursor cursor) { host_->SetCursor(cursor); } |
| 139 | 139 |
| 140 aura::WindowTreeHost* host_; // Not owned. | 140 aura::WindowTreeHost* host_; // Not owned. |
| 141 | 141 |
| 142 scoped_ptr<ui::ImageCursors> image_cursors_; | 142 scoped_ptr<ui::ImageCursors> image_cursors_; |
| 143 | 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(ShellNativeCursorManager); | 144 DISALLOW_COPY_AND_ASSIGN(ShellNativeCursorManager); |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 class AppsFocusRules : public wm::BaseFocusRules { | 147 class AppsFocusRules : public wm::BaseFocusRules { |
| 148 public: | 148 public: |
| 149 AppsFocusRules() {} | 149 AppsFocusRules() {} |
| 150 virtual ~AppsFocusRules() {} | 150 virtual ~AppsFocusRules() {} |
| 151 | 151 |
| 152 virtual bool SupportsChildActivation(aura::Window* window) const OVERRIDE { | 152 virtual bool SupportsChildActivation(aura::Window* window) const override { |
| 153 return true; | 153 return true; |
| 154 } | 154 } |
| 155 | 155 |
| 156 private: | 156 private: |
| 157 DISALLOW_COPY_AND_ASSIGN(AppsFocusRules); | 157 DISALLOW_COPY_AND_ASSIGN(AppsFocusRules); |
| 158 }; | 158 }; |
| 159 | 159 |
| 160 } // namespace | 160 } // namespace |
| 161 | 161 |
| 162 ShellDesktopController::ShellDesktopController() | 162 ShellDesktopController::ShellDesktopController() |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 if (displays.empty()) | 343 if (displays.empty()) |
| 344 return gfx::Size(); | 344 return gfx::Size(); |
| 345 const ui::DisplayMode* mode = displays[0].display->current_mode(); | 345 const ui::DisplayMode* mode = displays[0].display->current_mode(); |
| 346 return mode ? mode->size() : gfx::Size(); | 346 return mode ? mode->size() : gfx::Size(); |
| 347 #else | 347 #else |
| 348 return gfx::Size(); | 348 return gfx::Size(); |
| 349 #endif | 349 #endif |
| 350 } | 350 } |
| 351 | 351 |
| 352 } // namespace extensions | 352 } // namespace extensions |
| OLD | NEW |