| 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/frame/browser_frame.h" | 5 #include "chrome/browser/ui/views/frame/browser_frame.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "chrome/browser/themes/theme_service.h" | 8 #include "chrome/browser/themes/theme_service.h" |
| 9 #include "chrome/browser/themes/theme_service_factory.h" | 9 #include "chrome/browser/themes/theme_service_factory.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
| 13 #include "chrome/browser/ui/views/frame/browser_root_view.h" | 13 #include "chrome/browser/ui/views/frame/browser_root_view.h" |
| 14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 15 #include "chrome/browser/ui/views/frame/native_browser_frame.h" | 15 #include "chrome/browser/ui/views/frame/native_browser_frame.h" |
| 16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
| 17 #include "ui/base/theme_provider.h" | 17 #include "ui/base/theme_provider.h" |
| 18 #include "ui/gfx/screen.h" | 18 #include "ui/gfx/screen.h" |
| 19 #include "ui/views/widget/native_widget.h" | 19 #include "ui/views/widget/native_widget.h" |
| 20 | 20 |
| 21 #if defined(OS_WIN) && !defined(USE_AURA) | 21 #if defined(OS_WIN) && !defined(USE_AURA) |
| 22 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" | 22 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
| 23 #elif defined(OS_CHROMEOS) | |
| 24 #include "chrome/browser/chromeos/system/runtime_environment.h" | |
| 25 #endif | |
| 26 | |
| 27 #if defined(USE_AURA) | |
| 28 #include "ash/ash_switches.h" | |
| 29 #include "ash/shell.h" | |
| 30 #include "chrome/browser/chromeos/status/status_area_view.h" | |
| 31 #include "chrome/browser/ui/views/ash/chrome_shell_delegate.h" | |
| 32 #endif | 23 #endif |
| 33 | 24 |
| 34 //////////////////////////////////////////////////////////////////////////////// | 25 //////////////////////////////////////////////////////////////////////////////// |
| 35 // BrowserFrame, public: | 26 // BrowserFrame, public: |
| 36 | 27 |
| 37 BrowserFrame::BrowserFrame(BrowserView* browser_view) | 28 BrowserFrame::BrowserFrame(BrowserView* browser_view) |
| 38 : native_browser_frame_(NULL), | 29 : native_browser_frame_(NULL), |
| 39 root_view_(NULL), | 30 root_view_(NULL), |
| 40 browser_frame_view_(NULL), | 31 browser_frame_view_(NULL), |
| 41 browser_view_(browser_view) { | 32 browser_view_(browser_view) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 // created. | 50 // created. |
| 60 params.bounds = browser_view_->browser()->GetSavedWindowBounds(); | 51 params.bounds = browser_view_->browser()->GetSavedWindowBounds(); |
| 61 params.show_state = browser_view_->browser()->GetSavedWindowShowState(); | 52 params.show_state = browser_view_->browser()->GetSavedWindowShowState(); |
| 62 } | 53 } |
| 63 if (browser_view_->IsPanel()) { | 54 if (browser_view_->IsPanel()) { |
| 64 // We need to set the top-most bit when the panel window is created. | 55 // We need to set the top-most bit when the panel window is created. |
| 65 // There is a Windows bug/feature that would very likely prevent the window | 56 // There is a Windows bug/feature that would very likely prevent the window |
| 66 // from being changed to top-most after the window is created without | 57 // from being changed to top-most after the window is created without |
| 67 // activation. | 58 // activation. |
| 68 params.type = views::Widget::InitParams::TYPE_PANEL; | 59 params.type = views::Widget::InitParams::TYPE_PANEL; |
| 69 } else if (browser_view_->browser()->is_type_popup()) { | |
| 70 #if defined(USE_AURA) | |
| 71 // In compact mode there is no launcher, so we need to keep panels always | |
| 72 // on top so they do not get lost. | |
| 73 if (ash::Shell::GetInstance()->IsWindowModeCompact()) | |
| 74 params.keep_on_top = true; | |
| 75 #endif | |
| 76 } | 60 } |
| 77 #if defined(USE_AURA) | 61 #if defined(USE_AURA) |
| 78 // Compact mode has opaque frames, otherwise Aura frames are translucent. | 62 // Aura frames are translucent. |
| 79 if (!ash::Shell::GetInstance()->IsWindowModeCompact()) | 63 params.transparent = true; |
| 80 params.transparent = true; | |
| 81 // Aura compact mode fills the monitor with with its windows. | |
| 82 if (ash::Shell::GetInstance()->IsWindowModeCompact() && | |
| 83 browser_view_->IsBrowserTypeNormal()) { | |
| 84 params.bounds = gfx::Screen::GetPrimaryMonitorBounds(); | |
| 85 params.show_state = ui::SHOW_STATE_MAXIMIZED; | |
| 86 } | |
| 87 #endif | 64 #endif |
| 88 Init(params); | 65 Init(params); |
| 89 | |
| 90 // On ChromeOS and Aura compact mode we always want top-level windows | |
| 91 // to appear active. | |
| 92 bool disable_inactive_rendering = false; | |
| 93 #if defined(USE_AURA) | |
| 94 disable_inactive_rendering = ash::Shell::GetInstance()->IsWindowModeCompact(); | |
| 95 #elif defined(OS_CHROMEOS) | |
| 96 disable_inactive_rendering = true; | |
| 97 #endif | |
| 98 if (disable_inactive_rendering && browser_view_->IsBrowserTypeNormal()) | |
| 99 DisableInactiveRendering(); | |
| 100 } | 66 } |
| 101 | 67 |
| 102 int BrowserFrame::GetMinimizeButtonOffset() const { | 68 int BrowserFrame::GetMinimizeButtonOffset() const { |
| 103 return native_browser_frame_->GetMinimizeButtonOffset(); | 69 return native_browser_frame_->GetMinimizeButtonOffset(); |
| 104 } | 70 } |
| 105 | 71 |
| 106 gfx::Rect BrowserFrame::GetBoundsForTabStrip(views::View* tabstrip) const { | 72 gfx::Rect BrowserFrame::GetBoundsForTabStrip(views::View* tabstrip) const { |
| 107 gfx::Rect tab_strip_bounds = | 73 return browser_frame_view_->GetBoundsForTabStrip(tabstrip); |
| 108 browser_frame_view_->GetBoundsForTabStrip(tabstrip); | |
| 109 #if defined(USE_AURA) | |
| 110 // Leave space for status area in Aura compact window mode. | |
| 111 if (ash::Shell::GetInstance()->IsWindowModeCompact() && | |
| 112 ChromeShellDelegate::instance()) { | |
| 113 StatusAreaView* status_area = | |
| 114 ChromeShellDelegate::instance()->GetStatusArea(); | |
| 115 if (status_area) { | |
| 116 int reserve_width = 0; | |
| 117 gfx::Rect screen_bounds = gfx::Screen::GetPrimaryMonitorBounds(); | |
| 118 if (base::i18n::IsRTL()) { | |
| 119 // Get top-right corner of status area in screen coordinates. | |
| 120 gfx::Point status_origin(status_area->bounds().right(), 0); | |
| 121 views::View::ConvertPointToScreen(status_area, &status_origin); | |
| 122 // Reserve the width between the left edge of screen and the right edge | |
| 123 // of status area. | |
| 124 reserve_width = status_origin.x() - screen_bounds.x(); | |
| 125 } else { | |
| 126 // Get top-left corner of status area in screen coordinates. | |
| 127 gfx::Point status_origin; | |
| 128 views::View::ConvertPointToScreen(status_area, &status_origin); | |
| 129 // Reserve the width between the right edge of screen and the left edge | |
| 130 // of status area. | |
| 131 reserve_width = screen_bounds.right() - status_origin.x(); | |
| 132 } | |
| 133 // Views handles the RTL adjustment of tab strip. | |
| 134 tab_strip_bounds.set_width(tab_strip_bounds.width() - reserve_width); | |
| 135 } | |
| 136 } | |
| 137 #endif | |
| 138 return tab_strip_bounds; | |
| 139 } | 74 } |
| 140 | 75 |
| 141 int BrowserFrame::GetHorizontalTabStripVerticalOffset(bool restored) const { | 76 int BrowserFrame::GetHorizontalTabStripVerticalOffset(bool restored) const { |
| 142 return browser_frame_view_->GetHorizontalTabStripVerticalOffset(restored); | 77 return browser_frame_view_->GetHorizontalTabStripVerticalOffset(restored); |
| 143 } | 78 } |
| 144 | 79 |
| 145 void BrowserFrame::UpdateThrobber(bool running) { | 80 void BrowserFrame::UpdateThrobber(bool running) { |
| 146 browser_frame_view_->UpdateThrobber(running); | 81 browser_frame_view_->UpdateThrobber(running); |
| 147 } | 82 } |
| 148 | 83 |
| 149 views::View* BrowserFrame::GetFrameView() const { | 84 views::View* BrowserFrame::GetFrameView() const { |
| 150 return browser_frame_view_; | 85 return browser_frame_view_; |
| 151 } | 86 } |
| 152 | 87 |
| 153 void BrowserFrame::TabStripDisplayModeChanged() { | 88 void BrowserFrame::TabStripDisplayModeChanged() { |
| 154 if (GetRootView()->has_children()) { | 89 if (GetRootView()->has_children()) { |
| 155 // Make sure the child of the root view gets Layout again. | 90 // Make sure the child of the root view gets Layout again. |
| 156 GetRootView()->child_at(0)->InvalidateLayout(); | 91 GetRootView()->child_at(0)->InvalidateLayout(); |
| 157 } | 92 } |
| 158 GetRootView()->Layout(); | 93 GetRootView()->Layout(); |
| 159 native_browser_frame_->TabStripDisplayModeChanged(); | 94 native_browser_frame_->TabStripDisplayModeChanged(); |
| 160 } | 95 } |
| 161 | 96 |
| 162 bool BrowserFrame::IsSingleWindowMode() const { | |
| 163 bool single_window_mode = false; | |
| 164 #if defined(USE_AURA) | |
| 165 single_window_mode = ash::Shell::GetInstance()->IsWindowModeCompact(); | |
| 166 #elif defined(OS_CHROMEOS) | |
| 167 single_window_mode = | |
| 168 chromeos::system::runtime_environment::IsRunningOnChromeOS(); | |
| 169 #endif | |
| 170 return single_window_mode; | |
| 171 } | |
| 172 | |
| 173 /////////////////////////////////////////////////////////////////////////////// | 97 /////////////////////////////////////////////////////////////////////////////// |
| 174 // BrowserFrame, views::Widget overrides: | 98 // BrowserFrame, views::Widget overrides: |
| 175 | 99 |
| 176 bool BrowserFrame::IsMaximized() const { | 100 bool BrowserFrame::IsMaximized() const { |
| 177 #if defined(OS_CHROMEOS) && !defined(USE_AURA) | 101 #if defined(OS_CHROMEOS) && !defined(USE_AURA) |
| 178 if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) { | 102 if (chromeos::system::runtime_environment::IsRunningOnChromeOS()) { |
| 179 return !IsFullscreen() && | 103 return !IsFullscreen() && |
| 180 (browser_view_->IsBrowserTypeNormal() || Widget::IsMaximized()); | 104 (browser_view_->IsBrowserTypeNormal() || Widget::IsMaximized()); |
| 181 } | 105 } |
| 182 #endif | 106 #endif |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // set ourselves as the last active browser window to ensure that we get | 145 // set ourselves as the last active browser window to ensure that we get |
| 222 // treated as such by the rest of Chrome. | 146 // treated as such by the rest of Chrome. |
| 223 BrowserList::SetLastActive(browser_view_->browser()); | 147 BrowserList::SetLastActive(browser_view_->browser()); |
| 224 } | 148 } |
| 225 Widget::OnNativeWidgetActivationChanged(active); | 149 Widget::OnNativeWidgetActivationChanged(active); |
| 226 } | 150 } |
| 227 | 151 |
| 228 AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { | 152 AvatarMenuButton* BrowserFrame::GetAvatarMenuButton() { |
| 229 return browser_frame_view_->avatar_button(); | 153 return browser_frame_view_->avatar_button(); |
| 230 } | 154 } |
| OLD | NEW |