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/glass_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 std::min(frame_->GetMinimizeButtonOffset(), width()); | 123 std::min(frame_->GetMinimizeButtonOffset(), width()); |
124 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? | 124 int tabstrip_x = browser_view_->ShouldShowOffTheRecordAvatar() ? |
125 (otr_avatar_bounds_.right() + kOTRSideSpacing) : | 125 (otr_avatar_bounds_.right() + kOTRSideSpacing) : |
126 NonClientBorderThickness(); | 126 NonClientBorderThickness(); |
127 // In RTL languages, we have moved an avatar icon left by the size of window | 127 // In RTL languages, we have moved an avatar icon left by the size of window |
128 // controls to prevent it from being rendered over them. So, we use its x | 128 // controls to prevent it from being rendered over them. So, we use its x |
129 // position to move this tab strip left when maximized. Also, we can render | 129 // position to move this tab strip left when maximized. Also, we can render |
130 // a tab strip until the left end of this window without considering the size | 130 // a tab strip until the left end of this window without considering the size |
131 // of window controls in RTL languages. | 131 // of window controls in RTL languages. |
132 if (base::i18n::IsRTL()) { | 132 if (base::i18n::IsRTL()) { |
133 if (!browser_view_->ShouldShowOffTheRecordAvatar() && | 133 if (!browser_view_->ShouldShowOffTheRecordAvatar() && frame_->IsMaximized()) |
134 frame_->GetWindow()->IsMaximized()) | |
135 tabstrip_x += otr_avatar_bounds_.x(); | 134 tabstrip_x += otr_avatar_bounds_.x(); |
136 minimize_button_offset = width(); | 135 minimize_button_offset = width(); |
137 } | 136 } |
138 int maximized_spacing = | 137 int maximized_spacing = |
139 kNewTabCaptionMaximizedSpacing + | 138 kNewTabCaptionMaximizedSpacing + |
140 (show_profile_button() && profile_button_->IsVisible() ? | 139 (show_profile_button() && profile_button_->IsVisible() ? |
141 profile_button_->GetPreferredSize().width() + | 140 profile_button_->GetPreferredSize().width() + |
142 ProfileMenuButton::kProfileTagHorizontalSpacing : 0); | 141 ProfileMenuButton::kProfileTagHorizontalSpacing : 0); |
143 int tabstrip_width = minimize_button_offset - tabstrip_x - | 142 int tabstrip_width = minimize_button_offset - tabstrip_x - |
144 (frame_->GetWindow()->IsMaximized() ? | 143 (frame_->IsMaximized() ? |
145 maximized_spacing : kNewTabCaptionRestoredSpacing); | 144 maximized_spacing : kNewTabCaptionRestoredSpacing); |
146 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), | 145 return gfx::Rect(tabstrip_x, GetHorizontalTabStripVerticalOffset(false), |
147 std::max(0, tabstrip_width), | 146 std::max(0, tabstrip_width), |
148 tabstrip->GetPreferredSize().height()); | 147 tabstrip->GetPreferredSize().height()); |
149 } | 148 } |
150 | 149 |
151 int GlassBrowserFrameView::GetHorizontalTabStripVerticalOffset( | 150 int GlassBrowserFrameView::GetHorizontalTabStripVerticalOffset( |
152 bool restored) const { | 151 bool restored) const { |
153 return NonClientTopBorderHeight(restored, true); | 152 return NonClientTopBorderHeight(restored, true); |
154 } | 153 } |
(...skipping 16 matching lines...) Expand all Loading... |
171 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { | 170 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const { |
172 return client_view_bounds_; | 171 return client_view_bounds_; |
173 } | 172 } |
174 | 173 |
175 bool GlassBrowserFrameView::AlwaysUseNativeFrame() const { | 174 bool GlassBrowserFrameView::AlwaysUseNativeFrame() const { |
176 return frame_->AlwaysUseNativeFrame(); | 175 return frame_->AlwaysUseNativeFrame(); |
177 } | 176 } |
178 | 177 |
179 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( | 178 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds( |
180 const gfx::Rect& client_bounds) const { | 179 const gfx::Rect& client_bounds) const { |
181 HWND hwnd = frame_->GetWindow()->GetNativeWindow(); | 180 HWND hwnd = frame_->GetNativeWindow(); |
182 if (!browser_view_->IsTabStripVisible() && hwnd) { | 181 if (!browser_view_->IsTabStripVisible() && hwnd) { |
183 // If we don't have a tabstrip, we're either a popup or an app window, in | 182 // If we don't have a tabstrip, we're either a popup or an app window, in |
184 // which case we have a standard size non-client area and can just use | 183 // which case we have a standard size non-client area and can just use |
185 // AdjustWindowRectEx to obtain it. We check for a non-NULL window handle in | 184 // AdjustWindowRectEx to obtain it. We check for a non-NULL window handle in |
186 // case this gets called before the window is actually created. | 185 // case this gets called before the window is actually created. |
187 RECT rect = client_bounds.ToRECT(); | 186 RECT rect = client_bounds.ToRECT(); |
188 AdjustWindowRectEx(&rect, GetWindowLong(hwnd, GWL_STYLE), FALSE, | 187 AdjustWindowRectEx(&rect, GetWindowLong(hwnd, GWL_STYLE), FALSE, |
189 GetWindowLong(hwnd, GWL_EXSTYLE)); | 188 GetWindowLong(hwnd, GWL_EXSTYLE)); |
190 return gfx::Rect(rect); | 189 return gfx::Rect(rect); |
191 } | 190 } |
192 | 191 |
193 int top_height = NonClientTopBorderHeight(false, false); | 192 int top_height = NonClientTopBorderHeight(false, false); |
194 int border_thickness = NonClientBorderThickness(); | 193 int border_thickness = NonClientBorderThickness(); |
195 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), | 194 return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), |
196 std::max(0, client_bounds.y() - top_height), | 195 std::max(0, client_bounds.y() - top_height), |
197 client_bounds.width() + (2 * border_thickness), | 196 client_bounds.width() + (2 * border_thickness), |
198 client_bounds.height() + top_height + border_thickness); | 197 client_bounds.height() + top_height + border_thickness); |
199 } | 198 } |
200 | 199 |
201 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { | 200 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) { |
202 // If the browser isn't in normal mode, we haven't customized the frame, so | 201 // If the browser isn't in normal mode, we haven't customized the frame, so |
203 // Windows can figure this out. If the point isn't within our bounds, then | 202 // Windows can figure this out. If the point isn't within our bounds, then |
204 // it's in the native portion of the frame, so again Windows can figure it | 203 // it's in the native portion of the frame, so again Windows can figure it |
205 // out. | 204 // out. |
206 if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point)) | 205 if (!browser_view_->IsBrowserTypeNormal() || !bounds().Contains(point)) |
207 return HTNOWHERE; | 206 return HTNOWHERE; |
208 | 207 |
209 int frame_component = | 208 int frame_component = frame_->client_view()->NonClientHitTest(point); |
210 frame_->GetWindow()->client_view()->NonClientHitTest(point); | |
211 | 209 |
212 // See if we're in the sysmenu region. We still have to check the tabstrip | 210 // See if we're in the sysmenu region. We still have to check the tabstrip |
213 // first so that clicks in a tab don't get treated as sysmenu clicks. | 211 // first so that clicks in a tab don't get treated as sysmenu clicks. |
214 int nonclient_border_thickness = NonClientBorderThickness(); | 212 int nonclient_border_thickness = NonClientBorderThickness(); |
215 if (gfx::Rect(nonclient_border_thickness, GetSystemMetrics(SM_CXSIZEFRAME), | 213 if (gfx::Rect(nonclient_border_thickness, GetSystemMetrics(SM_CXSIZEFRAME), |
216 GetSystemMetrics(SM_CXSMICON), | 214 GetSystemMetrics(SM_CXSMICON), |
217 GetSystemMetrics(SM_CYSMICON)).Contains(point)) | 215 GetSystemMetrics(SM_CYSMICON)).Contains(point)) |
218 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; | 216 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU; |
219 | 217 |
220 if (frame_component != HTNOWHERE) | 218 if (frame_component != HTNOWHERE) |
221 return frame_component; | 219 return frame_component; |
222 | 220 |
223 // See if the point is within the profile menu button. | 221 // See if the point is within the profile menu button. |
224 if (show_profile_button() && profile_button_->IsVisible() && | 222 if (show_profile_button() && profile_button_->IsVisible() && |
225 profile_button_->GetMirroredBounds().Contains(point)) | 223 profile_button_->GetMirroredBounds().Contains(point)) |
226 return HTCLIENT; | 224 return HTCLIENT; |
227 | 225 |
228 int frame_border_thickness = FrameBorderThickness(); | 226 int frame_border_thickness = FrameBorderThickness(); |
229 int window_component = GetHTComponentForFrame(point, frame_border_thickness, | 227 int window_component = GetHTComponentForFrame(point, frame_border_thickness, |
230 nonclient_border_thickness, frame_border_thickness, | 228 nonclient_border_thickness, frame_border_thickness, |
231 kResizeAreaCornerSize - frame_border_thickness, | 229 kResizeAreaCornerSize - frame_border_thickness, |
232 frame_->GetWindow()->window_delegate()->CanResize()); | 230 frame_->window_delegate()->CanResize()); |
233 // Fall back to the caption if no other component matches. | 231 // Fall back to the caption if no other component matches. |
234 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; | 232 return (window_component == HTNOWHERE) ? HTCAPTION : window_component; |
235 } | 233 } |
236 | 234 |
237 /////////////////////////////////////////////////////////////////////////////// | 235 /////////////////////////////////////////////////////////////////////////////// |
238 // GlassBrowserFrameView, views::ViewMenuDelegate implementation: | 236 // GlassBrowserFrameView, views::ViewMenuDelegate implementation: |
239 void GlassBrowserFrameView::RunMenu(views::View *source, const gfx::Point &pt) { | 237 void GlassBrowserFrameView::RunMenu(views::View *source, const gfx::Point &pt) { |
240 if (profile_menu_model_ == NULL) | 238 if (profile_menu_model_ == NULL) |
241 profile_menu_model_.reset(new ProfileMenuModel); | 239 profile_menu_model_.reset(new ProfileMenuModel); |
242 gfx::Point menu_point(pt.x(), | 240 gfx::Point menu_point(pt.x(), |
243 pt.y() + kMenuDisplayOffset); | 241 pt.y() + kMenuDisplayOffset); |
244 profile_menu_model_->RunMenuAt(menu_point); | 242 profile_menu_model_->RunMenuAt(menu_point); |
245 } | 243 } |
246 | 244 |
247 /////////////////////////////////////////////////////////////////////////////// | 245 /////////////////////////////////////////////////////////////////////////////// |
248 // GlassBrowserFrameView, views::View overrides: | 246 // GlassBrowserFrameView, views::View overrides: |
249 | 247 |
250 void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) { | 248 void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
251 if (!browser_view_->IsTabStripVisible()) | 249 if (!browser_view_->IsTabStripVisible()) |
252 return; // Nothing is visible, so don't bother to paint. | 250 return; // Nothing is visible, so don't bother to paint. |
253 | 251 |
254 PaintToolbarBackground(canvas); | 252 PaintToolbarBackground(canvas); |
255 if (browser_view_->ShouldShowOffTheRecordAvatar()) | 253 if (browser_view_->ShouldShowOffTheRecordAvatar()) |
256 PaintOTRAvatar(canvas); | 254 PaintOTRAvatar(canvas); |
257 if (!frame_->GetWindow()->IsMaximized()) | 255 if (!frame_->IsMaximized()) |
258 PaintRestoredClientEdge(canvas); | 256 PaintRestoredClientEdge(canvas); |
259 } | 257 } |
260 | 258 |
261 void GlassBrowserFrameView::Layout() { | 259 void GlassBrowserFrameView::Layout() { |
262 LayoutOTRAvatar(); | 260 LayoutOTRAvatar(); |
263 LayoutClientView(); | 261 LayoutClientView(); |
264 LayoutProfileTag(); | 262 LayoutProfileTag(); |
265 } | 263 } |
266 | 264 |
267 bool GlassBrowserFrameView::HitTest(const gfx::Point& l) const { | 265 bool GlassBrowserFrameView::HitTest(const gfx::Point& l) const { |
268 // The ProfileMenuButton intrudes into the client area when the window is | 266 // The ProfileMenuButton intrudes into the client area when the window is |
269 // maximized. | 267 // maximized. |
270 if (frame_->GetWindow()->IsMaximized() && show_profile_button() && | 268 if (frame_->IsMaximized() && show_profile_button() && |
271 profile_button_->IsVisible() && | 269 profile_button_->IsVisible() && |
272 profile_button_->GetMirroredBounds().Contains(l)) { | 270 profile_button_->GetMirroredBounds().Contains(l)) { |
273 return true; | 271 return true; |
274 } else { | 272 } else { |
275 return !GetWindow()->client_view()->bounds().Contains(l); | 273 return !frame_->client_view()->bounds().Contains(l); |
276 } | 274 } |
277 } | 275 } |
278 | 276 |
279 /////////////////////////////////////////////////////////////////////////////// | 277 /////////////////////////////////////////////////////////////////////////////// |
280 // GlassBrowserFrameView, private: | 278 // GlassBrowserFrameView, private: |
281 | 279 |
282 int GlassBrowserFrameView::FrameBorderThickness() const { | 280 int GlassBrowserFrameView::FrameBorderThickness() const { |
283 views::Window* window = frame_->GetWindow(); | 281 return (frame_->IsMaximized() || frame_->IsFullscreen()) ? |
284 return (window->IsMaximized() || window->IsFullscreen()) ? | |
285 0 : GetSystemMetrics(SM_CXSIZEFRAME); | 282 0 : GetSystemMetrics(SM_CXSIZEFRAME); |
286 } | 283 } |
287 | 284 |
288 int GlassBrowserFrameView::NonClientBorderThickness() const { | 285 int GlassBrowserFrameView::NonClientBorderThickness() const { |
289 views::Window* window = frame_->GetWindow(); | 286 if (frame_->IsMaximized() || frame_->IsFullscreen()) |
290 if (window->IsMaximized() || window->IsFullscreen()) | |
291 return 0; | 287 return 0; |
292 | 288 |
293 return browser_view_->UseVerticalTabs() ? | 289 return browser_view_->UseVerticalTabs() ? |
294 kNonClientVerticalTabStripBorderThickness : | 290 kNonClientVerticalTabStripBorderThickness : |
295 kNonClientBorderThickness; | 291 kNonClientBorderThickness; |
296 } | 292 } |
297 | 293 |
298 int GlassBrowserFrameView::NonClientTopBorderHeight( | 294 int GlassBrowserFrameView::NonClientTopBorderHeight( |
299 bool restored, | 295 bool restored, |
300 bool ignore_vertical_tabs) const { | 296 bool ignore_vertical_tabs) const { |
301 if (!restored && frame_->GetWindow()->IsFullscreen()) | 297 if (!restored && frame_->IsFullscreen()) |
302 return 0; | 298 return 0; |
303 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass | 299 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass |
304 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border | 300 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border |
305 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). | 301 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()). |
306 if (browser_view_->IsTabStripVisible() && !ignore_vertical_tabs && | 302 if (browser_view_->IsTabStripVisible() && !ignore_vertical_tabs && |
307 browser_view_->UseVerticalTabs()) | 303 browser_view_->UseVerticalTabs()) |
308 return GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYCAPTION); | 304 return GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYCAPTION); |
309 return GetSystemMetrics(SM_CYSIZEFRAME) + | 305 return GetSystemMetrics(SM_CYSIZEFRAME) + |
310 ((!restored && browser_view_->IsMaximized()) ? | 306 ((!restored && browser_view_->IsMaximized()) ? |
311 -kTabstripTopShadowThickness : kNonClientRestoredExtraThickness); | 307 -kTabstripTopShadowThickness : kNonClientRestoredExtraThickness); |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } | 425 } |
430 | 426 |
431 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { | 427 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) { |
432 ui::ThemeProvider* tp = GetThemeProvider(); | 428 ui::ThemeProvider* tp = GetThemeProvider(); |
433 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); | 429 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height()); |
434 | 430 |
435 // The client edges start below the toolbar upper corner images regardless | 431 // The client edges start below the toolbar upper corner images regardless |
436 // of how tall the toolbar itself is. | 432 // of how tall the toolbar itself is. |
437 int client_area_top = browser_view_->UseVerticalTabs() ? | 433 int client_area_top = browser_view_->UseVerticalTabs() ? |
438 client_area_bounds.y() : | 434 client_area_bounds.y() : |
439 (frame_->GetWindow()->client_view()->y() + | 435 (frame_->client_view()->y() + |
440 browser_view_->GetToolbarBounds().y() + | 436 browser_view_->GetToolbarBounds().y() + |
441 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height()); | 437 tp->GetBitmapNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height()); |
442 int client_area_bottom = | 438 int client_area_bottom = |
443 std::max(client_area_top, height() - NonClientBorderThickness()); | 439 std::max(client_area_top, height() - NonClientBorderThickness()); |
444 int client_area_height = client_area_bottom - client_area_top; | 440 int client_area_height = client_area_bottom - client_area_top; |
445 | 441 |
446 // Draw the client edge images. | 442 // Draw the client edge images. |
447 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); | 443 SkBitmap* right = tp->GetBitmapNamed(IDR_CONTENT_RIGHT_SIDE); |
448 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, | 444 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top, |
449 right->width(), client_area_height); | 445 right->width(), client_area_height); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); | 486 SkBitmap otr_avatar_icon = browser_view_->GetOTRAvatarIcon(); |
491 int otr_bottom, otr_restored_y; | 487 int otr_bottom, otr_restored_y; |
492 if (browser_view_->UseVerticalTabs()) { | 488 if (browser_view_->UseVerticalTabs()) { |
493 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing; | 489 otr_bottom = NonClientTopBorderHeight(false, false) - kOTRBottomSpacing; |
494 otr_restored_y = kFrameShadowThickness; | 490 otr_restored_y = kFrameShadowThickness; |
495 } else { | 491 } else { |
496 otr_bottom = GetHorizontalTabStripVerticalOffset(false) + | 492 otr_bottom = GetHorizontalTabStripVerticalOffset(false) + |
497 browser_view_->GetTabStripHeight() - kOTRBottomSpacing; | 493 browser_view_->GetTabStripHeight() - kOTRBottomSpacing; |
498 otr_restored_y = otr_bottom - otr_avatar_icon.height(); | 494 otr_restored_y = otr_bottom - otr_avatar_icon.height(); |
499 } | 495 } |
500 int otr_y = frame_->GetWindow()->IsMaximized() ? | 496 int otr_y = frame_->IsMaximized() ? |
501 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) : | 497 (NonClientTopBorderHeight(false, true) + kTabstripTopShadowThickness) : |
502 otr_restored_y; | 498 otr_restored_y; |
503 otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(), | 499 otr_avatar_bounds_.SetRect(otr_x, otr_y, otr_avatar_icon.width(), |
504 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0); | 500 browser_view_->ShouldShowOffTheRecordAvatar() ? (otr_bottom - otr_y) : 0); |
505 } | 501 } |
506 | 502 |
507 void GlassBrowserFrameView::LayoutClientView() { | 503 void GlassBrowserFrameView::LayoutClientView() { |
508 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); | 504 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
509 } | 505 } |
510 | 506 |
(...skipping 18 matching lines...) Expand all Loading... |
529 | 525 |
530 profile_button_->ClearMaxTextSize(); | 526 profile_button_->ClearMaxTextSize(); |
531 profile_button_->SetVisible(true); | 527 profile_button_->SetVisible(true); |
532 int x_tag = | 528 int x_tag = |
533 // The x position of minimize button in the frame | 529 // The x position of minimize button in the frame |
534 frame_->GetMinimizeButtonOffset() - | 530 frame_->GetMinimizeButtonOffset() - |
535 // - the space between the minimize button and the profile button | 531 // - the space between the minimize button and the profile button |
536 ProfileMenuButton::kProfileTagHorizontalSpacing - | 532 ProfileMenuButton::kProfileTagHorizontalSpacing - |
537 // - the width of the profile button | 533 // - the width of the profile button |
538 profile_button_->GetPreferredSize().width(); | 534 profile_button_->GetPreferredSize().width(); |
539 int y_maximized_offset = frame_->GetWindow()->IsMaximized() ? | 535 int y_maximized_offset = frame_->IsMaximized() ? |
540 kProfileElementMaximizedYOffset : 0; | 536 kProfileElementMaximizedYOffset : 0; |
541 profile_button_->SetBounds( | 537 profile_button_->SetBounds( |
542 x_tag, | 538 x_tag, |
543 kProfileButtonYPosition + y_maximized_offset, | 539 kProfileButtonYPosition + y_maximized_offset, |
544 profile_button_->GetPreferredSize().width(), | 540 profile_button_->GetPreferredSize().width(), |
545 profile_button_->GetPreferredSize().height()); | 541 profile_button_->GetPreferredSize().height()); |
546 | 542 |
547 profile_tag_->SetVisible(true); | 543 profile_tag_->SetVisible(true); |
548 profile_tag_->set_is_signed_in(!profile_name.empty()); | 544 profile_tag_->set_is_signed_in(!profile_name.empty()); |
549 profile_tag_->SetBounds( | 545 profile_tag_->SetBounds( |
(...skipping 13 matching lines...) Expand all Loading... |
563 return gfx::Rect(border_thickness, top_height, | 559 return gfx::Rect(border_thickness, top_height, |
564 std::max(0, width - (2 * border_thickness)), | 560 std::max(0, width - (2 * border_thickness)), |
565 std::max(0, height - top_height - border_thickness)); | 561 std::max(0, height - top_height - border_thickness)); |
566 } | 562 } |
567 | 563 |
568 void GlassBrowserFrameView::StartThrobber() { | 564 void GlassBrowserFrameView::StartThrobber() { |
569 if (!throbber_running_) { | 565 if (!throbber_running_) { |
570 throbber_running_ = true; | 566 throbber_running_ = true; |
571 throbber_frame_ = 0; | 567 throbber_frame_ = 0; |
572 InitThrobberIcons(); | 568 InitThrobberIcons(); |
573 SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON, | 569 SendMessage(frame_->GetNativeWindow(), WM_SETICON, |
574 static_cast<WPARAM>(ICON_SMALL), | 570 static_cast<WPARAM>(ICON_SMALL), |
575 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); | 571 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
576 } | 572 } |
577 } | 573 } |
578 | 574 |
579 void GlassBrowserFrameView::StopThrobber() { | 575 void GlassBrowserFrameView::StopThrobber() { |
580 if (throbber_running_) { | 576 if (throbber_running_) { |
581 throbber_running_ = false; | 577 throbber_running_ = false; |
582 | 578 |
583 HICON frame_icon = NULL; | 579 HICON frame_icon = NULL; |
584 | 580 |
585 // Check if hosted BrowserView has a window icon to use. | 581 // Check if hosted BrowserView has a window icon to use. |
586 if (browser_view_->ShouldShowWindowIcon()) { | 582 if (browser_view_->ShouldShowWindowIcon()) { |
587 SkBitmap icon = browser_view_->GetWindowIcon(); | 583 SkBitmap icon = browser_view_->GetWindowIcon(); |
588 if (!icon.isNull()) | 584 if (!icon.isNull()) |
589 frame_icon = IconUtil::CreateHICONFromSkBitmap(icon); | 585 frame_icon = IconUtil::CreateHICONFromSkBitmap(icon); |
590 } | 586 } |
591 | 587 |
592 // Fallback to class icon. | 588 // Fallback to class icon. |
593 if (!frame_icon) { | 589 if (!frame_icon) { |
594 frame_icon = reinterpret_cast<HICON>(GetClassLongPtr( | 590 frame_icon = reinterpret_cast<HICON>(GetClassLongPtr( |
595 frame_->GetWindow()->GetNativeWindow(), GCLP_HICONSM)); | 591 frame_->GetNativeWindow(), GCLP_HICONSM)); |
596 } | 592 } |
597 | 593 |
598 // This will reset the small icon which we set in the throbber code. | 594 // This will reset the small icon which we set in the throbber code. |
599 // WM_SETICON with NULL icon restores the icon for title bar but not | 595 // WM_SETICON with NULL icon restores the icon for title bar but not |
600 // for taskbar. See http://crbug.com/29996 | 596 // for taskbar. See http://crbug.com/29996 |
601 SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON, | 597 SendMessage(frame_->GetNativeWindow(), WM_SETICON, |
602 static_cast<WPARAM>(ICON_SMALL), | 598 static_cast<WPARAM>(ICON_SMALL), |
603 reinterpret_cast<LPARAM>(frame_icon)); | 599 reinterpret_cast<LPARAM>(frame_icon)); |
604 } | 600 } |
605 } | 601 } |
606 | 602 |
607 void GlassBrowserFrameView::DisplayNextThrobberFrame() { | 603 void GlassBrowserFrameView::DisplayNextThrobberFrame() { |
608 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; | 604 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount; |
609 SendMessage(frame_->GetWindow()->GetNativeWindow(), WM_SETICON, | 605 SendMessage(frame_->GetNativeWindow(), WM_SETICON, |
610 static_cast<WPARAM>(ICON_SMALL), | 606 static_cast<WPARAM>(ICON_SMALL), |
611 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); | 607 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_])); |
612 } | 608 } |
613 | 609 |
614 void GlassBrowserFrameView::Observe(NotificationType type, | 610 void GlassBrowserFrameView::Observe(NotificationType type, |
615 const NotificationSource& source, | 611 const NotificationSource& source, |
616 const NotificationDetails& details) { | 612 const NotificationDetails& details) { |
617 DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); | 613 DCHECK_EQ(NotificationType::PREF_CHANGED, type.value); |
618 std::string* name = Details<std::string>(details).ptr(); | 614 std::string* name = Details<std::string>(details).ptr(); |
619 if (prefs::kGoogleServicesUsername == *name) | 615 if (prefs::kGoogleServicesUsername == *name) |
(...skipping 11 matching lines...) Expand all Loading... |
631 static bool initialized = false; | 627 static bool initialized = false; |
632 if (!initialized) { | 628 if (!initialized) { |
633 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); | 629 ResourceBundle &rb = ResourceBundle::GetSharedInstance(); |
634 for (int i = 0; i < kThrobberIconCount; ++i) { | 630 for (int i = 0; i < kThrobberIconCount; ++i) { |
635 throbber_icons_[i] = rb.LoadThemeIcon(IDI_THROBBER_01 + i); | 631 throbber_icons_[i] = rb.LoadThemeIcon(IDI_THROBBER_01 + i); |
636 DCHECK(throbber_icons_[i]); | 632 DCHECK(throbber_icons_[i]); |
637 } | 633 } |
638 initialized = true; | 634 initialized = true; |
639 } | 635 } |
640 } | 636 } |
OLD | NEW |