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