OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_win.h" | 5 #include "chrome/browser/ui/views/frame/browser_frame_win.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 12 #include "chrome/browser/accessibility/browser_accessibility_state.h" |
13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_list.h" |
14 #include "chrome/browser/ui/views/frame/browser_view.h" | 14 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "grit/theme_resources.h" | 15 #include "grit/theme_resources.h" |
| 16 #include "ui/base/theme_provider.h" |
16 #include "ui/gfx/font.h" | 17 #include "ui/gfx/font.h" |
17 #include "views/screen.h" | 18 #include "views/screen.h" |
18 #include "views/window/non_client_view.h" | 19 #include "views/window/non_client_view.h" |
19 #include "views/window/window.h" | 20 #include "views/window/window.h" |
20 | 21 |
21 // static | 22 // static |
22 static const int kClientEdgeThickness = 3; | 23 static const int kClientEdgeThickness = 3; |
23 static const int kTabDragWindowAlpha = 200; | 24 static const int kTabDragWindowAlpha = 200; |
24 // We need to offset the DWMFrame into the toolbar so that the blackness | 25 // We need to offset the DWMFrame into the toolbar so that the blackness |
25 // doesn't show up on our rounded corners. | 26 // doesn't show up on our rounded corners. |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 STARTUPINFO si = {0}; | 58 STARTUPINFO si = {0}; |
58 si.cb = sizeof(si); | 59 si.cb = sizeof(si); |
59 si.dwFlags = STARTF_USESHOWWINDOW; | 60 si.dwFlags = STARTF_USESHOWWINDOW; |
60 GetStartupInfo(&si); | 61 GetStartupInfo(&si); |
61 return si.wShowWindow; | 62 return si.wShowWindow; |
62 } | 63 } |
63 | 64 |
64 gfx::Insets BrowserFrameWin::GetClientAreaInsets() const { | 65 gfx::Insets BrowserFrameWin::GetClientAreaInsets() const { |
65 // Use the default client insets for an opaque frame or a glass popup/app | 66 // Use the default client insets for an opaque frame or a glass popup/app |
66 // frame. | 67 // frame. |
67 if (!GetWindow()->non_client_view()->UseNativeFrame() || | 68 if (!GetWindow()->ShouldUseNativeFrame() || |
68 !browser_view_->IsBrowserTypeNormal()) { | 69 !browser_view_->IsBrowserTypeNormal()) { |
69 return WindowWin::GetClientAreaInsets(); | 70 return WindowWin::GetClientAreaInsets(); |
70 } | 71 } |
71 | 72 |
72 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); | 73 int border_thickness = GetSystemMetrics(SM_CXSIZEFRAME); |
73 // In fullscreen mode, we have no frame. In restored mode, we draw our own | 74 // In fullscreen mode, we have no frame. In restored mode, we draw our own |
74 // client edge over part of the default frame. | 75 // client edge over part of the default frame. |
75 if (IsFullscreen()) | 76 if (IsFullscreen()) |
76 border_thickness = 0; | 77 border_thickness = 0; |
77 else if (!IsMaximized()) | 78 else if (!IsMaximized()) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 GetWindow()->non_client_view()->Layout(); | 113 GetWindow()->non_client_view()->Layout(); |
113 GetWindow()->non_client_view()->SchedulePaint(); | 114 GetWindow()->non_client_view()->SchedulePaint(); |
114 } | 115 } |
115 } | 116 } |
116 | 117 |
117 void BrowserFrameWin::OnScreenReaderDetected() { | 118 void BrowserFrameWin::OnScreenReaderDetected() { |
118 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); | 119 BrowserAccessibilityState::GetInstance()->OnScreenReaderDetected(); |
119 WindowWin::OnScreenReaderDetected(); | 120 WindowWin::OnScreenReaderDetected(); |
120 } | 121 } |
121 | 122 |
| 123 bool BrowserFrameWin::ShouldUseNativeFrame() const { |
| 124 // App panel windows draw their own frame. |
| 125 if (browser_view_->IsBrowserTypePanel()) |
| 126 return false; |
| 127 |
| 128 // We don't theme popup or app windows, so regardless of whether or not a |
| 129 // theme is active for normal browser windows, we don't want to use the custom |
| 130 // frame for popups/apps. |
| 131 if (!browser_view_->IsBrowserTypeNormal() && |
| 132 WindowWin::ShouldUseNativeFrame()) { |
| 133 return true; |
| 134 } |
| 135 |
| 136 // Otherwise, we use the native frame when we're told we should by the theme |
| 137 // provider (e.g. no custom theme is active). |
| 138 return GetWidget()->GetThemeProvider()->ShouldUseNativeFrame(); |
| 139 } |
| 140 |
122 //////////////////////////////////////////////////////////////////////////////// | 141 //////////////////////////////////////////////////////////////////////////////// |
123 // BrowserFrameWin, NativeBrowserFrame implementation: | 142 // BrowserFrameWin, NativeBrowserFrame implementation: |
124 | 143 |
125 views::NativeWindow* BrowserFrameWin::AsNativeWindow() { | 144 views::NativeWindow* BrowserFrameWin::AsNativeWindow() { |
126 return this; | 145 return this; |
127 } | 146 } |
128 | 147 |
129 const views::NativeWindow* BrowserFrameWin::AsNativeWindow() const { | 148 const views::NativeWindow* BrowserFrameWin::AsNativeWindow() const { |
130 return this; | 149 return this; |
131 } | 150 } |
(...skipping 12 matching lines...) Expand all Loading... |
144 | 163 |
145 void BrowserFrameWin::TabStripDisplayModeChanged() { | 164 void BrowserFrameWin::TabStripDisplayModeChanged() { |
146 UpdateDWMFrame(); | 165 UpdateDWMFrame(); |
147 } | 166 } |
148 | 167 |
149 /////////////////////////////////////////////////////////////////////////////// | 168 /////////////////////////////////////////////////////////////////////////////// |
150 // BrowserFrameWin, private: | 169 // BrowserFrameWin, private: |
151 | 170 |
152 void BrowserFrameWin::UpdateDWMFrame() { | 171 void BrowserFrameWin::UpdateDWMFrame() { |
153 // Nothing to do yet, or we're not showing a DWM frame. | 172 // Nothing to do yet, or we're not showing a DWM frame. |
154 if (!GetWindow()->client_view() || !browser_frame_->AlwaysUseNativeFrame()) | 173 if (!GetWindow()->client_view() || !browser_frame_->ShouldUseNativeFrame()) |
155 return; | 174 return; |
156 | 175 |
157 MARGINS margins = { 0 }; | 176 MARGINS margins = { 0 }; |
158 if (browser_view_->IsBrowserTypeNormal()) { | 177 if (browser_view_->IsBrowserTypeNormal()) { |
159 // In fullscreen mode, we don't extend glass into the client area at all, | 178 // In fullscreen mode, we don't extend glass into the client area at all, |
160 // because the GDI-drawn text in the web content composited over it will | 179 // because the GDI-drawn text in the web content composited over it will |
161 // become semi-transparent over any glass area. | 180 // become semi-transparent over any glass area. |
162 if (!IsMaximized() && !IsFullscreen()) { | 181 if (!IsMaximized() && !IsFullscreen()) { |
163 margins.cxLeftWidth = kClientEdgeThickness + 1; | 182 margins.cxLeftWidth = kClientEdgeThickness + 1; |
164 margins.cxRightWidth = kClientEdgeThickness + 1; | 183 margins.cxRightWidth = kClientEdgeThickness + 1; |
(...skipping 27 matching lines...) Expand all Loading... |
192 //////////////////////////////////////////////////////////////////////////////// | 211 //////////////////////////////////////////////////////////////////////////////// |
193 // NativeBrowserFrame, public: | 212 // NativeBrowserFrame, public: |
194 | 213 |
195 // static | 214 // static |
196 NativeBrowserFrame* NativeBrowserFrame::CreateNativeBrowserFrame( | 215 NativeBrowserFrame* NativeBrowserFrame::CreateNativeBrowserFrame( |
197 BrowserFrame* browser_frame, | 216 BrowserFrame* browser_frame, |
198 BrowserView* browser_view) { | 217 BrowserView* browser_view) { |
199 return new BrowserFrameWin(browser_frame, browser_view); | 218 return new BrowserFrameWin(browser_frame, browser_view); |
200 } | 219 } |
201 | 220 |
OLD | NEW |