Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/ui/views/frame/desktop_browser_frame_aura.h" |
| 6 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 7 | #include "chrome/app/chrome_command_ids.h" |
| 8 | #include "chrome/browser/ui/views/frame/browser_desktop_root_window_host.h" |
| 9 | #include "chrome/browser/ui/views/frame/browser_view.h" |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 10 | #include "chrome/browser/ui/views/frame/desktop_user_action_handler_aura.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 11 | #include "grit/chromium_strings.h" |
| 12 | #include "grit/generated_resources.h" |
| 13 | #include "ui/aura/client/aura_constants.h" |
| 14 | #include "ui/aura/root_window.h" |
| 15 | #include "ui/aura/window.h" |
| 16 | #include "ui/aura/window_observer.h" |
| 17 | #include "ui/base/hit_test.h" |
| 18 | #include "ui/base/l10n/l10n_util.h" |
| 19 | #include "ui/base/models/simple_menu_model.h" |
| 20 | #include "ui/gfx/font.h" |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 21 | #include "ui/views/corewm/visibility_controller.h" |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 22 | #include "ui/views/view.h" |
| 23 | |
| 24 | using aura::Window; |
| 25 | |
| 26 | /////////////////////////////////////////////////////////////////////////////// |
| 27 | // DesktopBrowserFrameAura, public: |
| 28 | |
| 29 | DesktopBrowserFrameAura::DesktopBrowserFrameAura( |
| 30 | BrowserFrame* browser_frame, |
| 31 | BrowserView* browser_view) |
| 32 | : views::DesktopNativeWidgetAura(browser_frame), |
| 33 | browser_view_(browser_view), |
| 34 | browser_frame_(browser_frame), |
| 35 | browser_desktop_root_window_host_(NULL) { |
| 36 | GetNativeWindow()->SetName("BrowserFrameAura"); |
| 37 | } |
| 38 | |
| 39 | /////////////////////////////////////////////////////////////////////////////// |
Torne (Richard Coles) | 58537e2 | 2013-09-12 12:10:22 +0100 | [diff] [blame] | 40 | // DesktopBrowserFrameAura, protected: |
| 41 | |
| 42 | DesktopBrowserFrameAura::~DesktopBrowserFrameAura() { |
| 43 | } |
| 44 | |
| 45 | /////////////////////////////////////////////////////////////////////////////// |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 46 | // DesktopBrowserFrameAura, views::DesktopNativeWidgetAura overrides: |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 47 | |
Torne (Richard Coles) | 4e180b6 | 2013-10-18 15:46:22 +0100 | [diff] [blame^] | 48 | void DesktopBrowserFrameAura::OnHostClosed() { |
| 49 | aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), NULL); |
| 50 | DesktopNativeWidgetAura::OnHostClosed(); |
| 51 | } |
| 52 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 53 | void DesktopBrowserFrameAura::InitNativeWidget( |
| 54 | const views::Widget::InitParams& params) { |
| 55 | browser_desktop_root_window_host_ = |
| 56 | BrowserDesktopRootWindowHost::CreateBrowserDesktopRootWindowHost( |
| 57 | browser_frame_, |
| 58 | this, |
| 59 | params.bounds, |
| 60 | browser_view_, |
| 61 | browser_frame_); |
| 62 | views::Widget::InitParams modified_params = params; |
| 63 | modified_params.desktop_root_window_host = |
| 64 | browser_desktop_root_window_host_->AsDesktopRootWindowHost(); |
| 65 | DesktopNativeWidgetAura::InitNativeWidget(modified_params); |
| 66 | |
Torne (Richard Coles) | 90dce4d | 2013-05-29 14:40:03 +0100 | [diff] [blame] | 67 | user_action_client_.reset( |
| 68 | new DesktopUserActionHandlerAura(browser_view_->browser())); |
| 69 | aura::client::SetUserActionClient(GetNativeView()->GetRootWindow(), |
| 70 | user_action_client_.get()); |
| 71 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 72 | visibility_controller_.reset(new views::corewm::VisibilityController); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 73 | aura::client::SetVisibilityClient(GetNativeView()->GetRootWindow(), |
| 74 | visibility_controller_.get()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 75 | views::corewm::SetChildWindowVisibilityChangesAnimated( |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 76 | GetNativeView()->GetRootWindow()); |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 79 | //////////////////////////////////////////////////////////////////////////////// |
| 80 | // DesktopBrowserFrameAura, NativeBrowserFrame implementation: |
| 81 | |
| 82 | views::NativeWidget* DesktopBrowserFrameAura::AsNativeWidget() { |
| 83 | return this; |
| 84 | } |
| 85 | |
| 86 | const views::NativeWidget* DesktopBrowserFrameAura::AsNativeWidget() const { |
| 87 | return this; |
| 88 | } |
| 89 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 90 | bool DesktopBrowserFrameAura::UsesNativeSystemMenu() const { |
| 91 | return browser_desktop_root_window_host_->UsesNativeSystemMenu(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | int DesktopBrowserFrameAura::GetMinimizeButtonOffset() const { |
| 95 | return browser_desktop_root_window_host_->GetMinimizeButtonOffset(); |
| 96 | } |
| 97 | |
| 98 | void DesktopBrowserFrameAura::TabStripDisplayModeChanged() { |
| 99 | } |