Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / glass_browser_frame_view.cc
blob472dcad8ad2b10ada9c04b362d26938ab9c0e0a1
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.
5 #include "chrome/browser/ui/views/frame/glass_browser_frame_view.h"
7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/app/chrome_dll_resource.h"
11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/themes/theme_properties.h"
14 #include "chrome/browser/ui/views/avatar_menu_button.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/browser/ui/views/new_avatar_button.h"
17 #include "chrome/browser/ui/views/tabs/tab.h"
18 #include "chrome/browser/ui/views/tabs/tab_strip.h"
19 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
20 #include "chrome/common/pref_names.h"
21 #include "chrome/common/profile_management_switches.h"
22 #include "content/public/browser/notification_service.h"
23 #include "grit/generated_resources.h"
24 #include "grit/theme_resources.h"
25 #include "grit/ui_resources.h"
26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/resource/resource_bundle_win.h"
28 #include "ui/base/theme_provider.h"
29 #include "ui/gfx/canvas.h"
30 #include "ui/gfx/icon_util.h"
31 #include "ui/gfx/image/image.h"
32 #include "ui/gfx/win/dpi.h"
33 #include "ui/views/controls/label.h"
34 #include "ui/views/layout/layout_constants.h"
35 #include "ui/views/win/hwnd_util.h"
36 #include "ui/views/window/client_view.h"
38 HICON GlassBrowserFrameView::throbber_icons_[
39 GlassBrowserFrameView::kThrobberIconCount];
41 namespace {
42 // There are 3 px of client edge drawn inside the outer frame borders.
43 const int kNonClientBorderThickness = 3;
44 // Besides the frame border, there's another 9 px of empty space atop the
45 // window in restored mode, to use to drag the window around.
46 const int kNonClientRestoredExtraThickness = 9;
47 // In the window corners, the resize areas don't actually expand bigger, but the
48 // 16 px at the end of the top and bottom edges triggers diagonal resizing.
49 const int kResizeAreaCornerSize = 16;
50 // The avatar ends 2 px above the bottom of the tabstrip (which, given the
51 // way the tabstrip draws its bottom edge, will appear like a 1 px gap to the
52 // user).
53 const int kAvatarBottomSpacing = 2;
54 // Space between the frame border and the left edge of the avatar.
55 const int kAvatarLeftSpacing = 2;
56 // Space between the right edge of the avatar and the tabstrip.
57 const int kAvatarRightSpacing = -2;
58 // How far the new avatar button is from the left of the minimize button.
59 const int kNewAvatarButtonOffset = 5;
60 // The content left/right images have a shadow built into them.
61 const int kContentEdgeShadowThickness = 2;
62 // The top 3 px of the tabstrip is shadow; in maximized mode we push this off
63 // the top of the screen so the tabs appear flush against the screen edge.
64 const int kTabstripTopShadowThickness = 3;
65 // In restored mode, the New Tab button isn't at the same height as the caption
66 // buttons, but the space will look cluttered if it actually slides under them,
67 // so we stop it when the gap between the two is down to 5 px.
68 const int kNewTabCaptionRestoredSpacing = 5;
69 // In maximized mode, where the New Tab button and the caption buttons are at
70 // similar vertical coordinates, we need to reserve a larger, 16 px gap to avoid
71 // looking too cluttered.
72 const int kNewTabCaptionMaximizedSpacing = 16;
73 // How far to indent the tabstrip from the left side of the screen when there
74 // is no avatar icon.
75 const int kTabStripIndent = -6;
77 } // namespace
79 ///////////////////////////////////////////////////////////////////////////////
80 // GlassBrowserFrameView, public:
82 GlassBrowserFrameView::GlassBrowserFrameView(BrowserFrame* frame,
83 BrowserView* browser_view)
84 : BrowserNonClientFrameView(frame, browser_view),
85 throbber_running_(false),
86 throbber_frame_(0) {
87 if (browser_view->ShouldShowWindowIcon())
88 InitThrobberIcons();
90 if (browser_view->IsRegularOrGuestSession() &&
91 switches::IsNewProfileManagement())
92 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON);
93 else
94 UpdateAvatarInfo();
96 if (!browser_view->IsOffTheRecord()) {
97 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
98 content::NotificationService::AllSources());
102 GlassBrowserFrameView::~GlassBrowserFrameView() {
105 ///////////////////////////////////////////////////////////////////////////////
106 // GlassBrowserFrameView, BrowserNonClientFrameView implementation:
108 gfx::Rect GlassBrowserFrameView::GetBoundsForTabStrip(
109 views::View* tabstrip) const {
110 int minimize_button_offset =
111 std::min(frame()->GetMinimizeButtonOffset(), width());
113 // The new avatar button is optionally displayed to the left of the
114 // minimize button.
115 if (new_avatar_button()) {
116 DCHECK(switches::IsNewProfileManagement());
117 minimize_button_offset -= new_avatar_button()->width();
120 int tabstrip_x = browser_view()->ShouldShowAvatar() ?
121 (avatar_bounds_.right() + kAvatarRightSpacing) :
122 NonClientBorderThickness() + kTabStripIndent;
123 // In RTL languages, we have moved an avatar icon left by the size of window
124 // controls to prevent it from being rendered over them. So, we use its x
125 // position to move this tab strip left when maximized. Also, we can render
126 // a tab strip until the left end of this window without considering the size
127 // of window controls in RTL languages.
128 if (base::i18n::IsRTL()) {
129 if (!browser_view()->ShouldShowAvatar() && frame()->IsMaximized())
130 tabstrip_x += avatar_bounds_.x();
131 else if (browser_view()->IsRegularOrGuestSession() &&
132 switches::IsNewProfileManagement())
133 tabstrip_x = width() - minimize_button_offset;
135 minimize_button_offset = width();
137 int tabstrip_width = minimize_button_offset - tabstrip_x -
138 (frame()->IsMaximized() ?
139 kNewTabCaptionMaximizedSpacing : kNewTabCaptionRestoredSpacing);
140 return gfx::Rect(tabstrip_x, NonClientTopBorderHeight(),
141 std::max(0, tabstrip_width),
142 tabstrip->GetPreferredSize().height());
145 int GlassBrowserFrameView::GetTopInset() const {
146 return GetClientAreaInsets().top();
149 int GlassBrowserFrameView::GetThemeBackgroundXInset() const {
150 return 0;
153 void GlassBrowserFrameView::UpdateThrobber(bool running) {
154 if (throbber_running_) {
155 if (running) {
156 DisplayNextThrobberFrame();
157 } else {
158 StopThrobber();
160 } else if (running) {
161 StartThrobber();
165 gfx::Size GlassBrowserFrameView::GetMinimumSize() {
166 gfx::Size min_size(browser_view()->GetMinimumSize());
168 // Account for the client area insets.
169 gfx::Insets insets = GetClientAreaInsets();
170 min_size.Enlarge(insets.width(), insets.height());
171 // Client area insets do not include the shadow thickness.
172 min_size.Enlarge(2 * kContentEdgeShadowThickness, 0);
174 // Ensure that the minimum width is enough to hold a tab strip with minimum
175 // width at its usual insets.
176 if (browser_view()->IsTabStripVisible()) {
177 TabStrip* tabstrip = browser_view()->tabstrip();
178 int min_tabstrip_width = tabstrip->GetMinimumSize().width();
179 int min_tabstrip_area_width =
180 width() - GetBoundsForTabStrip(tabstrip).width() + min_tabstrip_width;
181 min_size.set_width(std::max(min_tabstrip_area_width, min_size.width()));
184 return min_size;
187 ///////////////////////////////////////////////////////////////////////////////
188 // GlassBrowserFrameView, views::NonClientFrameView implementation:
190 gfx::Rect GlassBrowserFrameView::GetBoundsForClientView() const {
191 return client_view_bounds_;
194 gfx::Rect GlassBrowserFrameView::GetWindowBoundsForClientBounds(
195 const gfx::Rect& client_bounds) const {
196 HWND hwnd = views::HWNDForWidget(frame());
197 if (!browser_view()->IsTabStripVisible() && hwnd) {
198 // If we don't have a tabstrip, we're either a popup or an app window, in
199 // which case we have a standard size non-client area and can just use
200 // AdjustWindowRectEx to obtain it. We check for a non-NULL window handle in
201 // case this gets called before the window is actually created.
202 RECT rect = client_bounds.ToRECT();
203 AdjustWindowRectEx(&rect, GetWindowLong(hwnd, GWL_STYLE), FALSE,
204 GetWindowLong(hwnd, GWL_EXSTYLE));
205 return gfx::Rect(rect);
208 gfx::Insets insets = GetClientAreaInsets();
209 return gfx::Rect(std::max(0, client_bounds.x() - insets.left()),
210 std::max(0, client_bounds.y() - insets.top()),
211 client_bounds.width() + insets.width(),
212 client_bounds.height() + insets.height());
215 int GlassBrowserFrameView::NonClientHitTest(const gfx::Point& point) {
216 // If the browser isn't in normal mode, we haven't customized the frame, so
217 // Windows can figure this out. If the point isn't within our bounds, then
218 // it's in the native portion of the frame, so again Windows can figure it
219 // out.
220 if (!browser_view()->IsBrowserTypeNormal() || !bounds().Contains(point))
221 return HTNOWHERE;
223 // See if the point is within the avatar menu button or within the avatar
224 // label.
225 if (avatar_button() && avatar_button()->GetMirroredBounds().Contains(point))
226 return HTCLIENT;
228 if (new_avatar_button() &&
229 new_avatar_button()->GetMirroredBounds().Contains(point))
230 return HTCLIENT;
232 int frame_component = frame()->client_view()->NonClientHitTest(point);
234 // See if we're in the sysmenu region. We still have to check the tabstrip
235 // first so that clicks in a tab don't get treated as sysmenu clicks.
236 int nonclient_border_thickness = NonClientBorderThickness();
237 if (gfx::Rect(nonclient_border_thickness, GetSystemMetrics(SM_CXSIZEFRAME),
238 GetSystemMetrics(SM_CXSMICON),
239 GetSystemMetrics(SM_CYSMICON)).Contains(point))
240 return (frame_component == HTCLIENT) ? HTCLIENT : HTSYSMENU;
242 if (frame_component != HTNOWHERE)
243 return frame_component;
245 int frame_border_thickness = FrameBorderThickness();
246 int window_component = GetHTComponentForFrame(point, frame_border_thickness,
247 nonclient_border_thickness, frame_border_thickness,
248 kResizeAreaCornerSize - frame_border_thickness,
249 frame()->widget_delegate()->CanResize());
250 // Fall back to the caption if no other component matches.
251 return (window_component == HTNOWHERE) ? HTCAPTION : window_component;
254 ///////////////////////////////////////////////////////////////////////////////
255 // GlassBrowserFrameView, views::View overrides:
257 void GlassBrowserFrameView::OnPaint(gfx::Canvas* canvas) {
258 if (browser_view()->IsToolbarVisible() &&
259 browser_view()->toolbar()->ShouldPaintBackground())
260 PaintToolbarBackground(canvas);
261 if (!frame()->IsMaximized())
262 PaintRestoredClientEdge(canvas);
265 void GlassBrowserFrameView::Layout() {
266 if (browser_view()->IsRegularOrGuestSession() &&
267 switches::IsNewProfileManagement())
268 LayoutNewStyleAvatar();
269 else
270 LayoutAvatar();
272 LayoutClientView();
275 bool GlassBrowserFrameView::HitTestRect(const gfx::Rect& rect) const {
276 bool hit_avatar_button = avatar_button() &&
277 avatar_button()->GetMirroredBounds().Intersects(rect);
278 bool hit_new_avatar_button = new_avatar_button() &&
279 new_avatar_button()->GetMirroredBounds().Intersects(rect);
280 return hit_avatar_button || hit_new_avatar_button ||
281 !frame()->client_view()->bounds().Intersects(rect);
284 ///////////////////////////////////////////////////////////////////////////////
285 // GlassBrowserFrameView, views::ButtonListener overrides:
286 void GlassBrowserFrameView::ButtonPressed(views::Button* sender,
287 const ui::Event& event) {
288 if (sender == new_avatar_button())
289 browser_view()->ShowAvatarBubbleFromAvatarButton();
292 ///////////////////////////////////////////////////////////////////////////////
293 // GlassBrowserFrameView, private:
295 int GlassBrowserFrameView::FrameBorderThickness() const {
296 return (frame()->IsMaximized() || frame()->IsFullscreen()) ?
297 0 : GetSystemMetrics(SM_CXSIZEFRAME);
300 int GlassBrowserFrameView::NonClientBorderThickness() const {
301 if (frame()->IsMaximized() || frame()->IsFullscreen())
302 return 0;
304 return kNonClientBorderThickness;
307 int GlassBrowserFrameView::NonClientTopBorderHeight() const {
308 if (frame()->IsFullscreen())
309 return 0;
311 // We'd like to use FrameBorderThickness() here, but the maximized Aero glass
312 // frame has a 0 frame border around most edges and a CYSIZEFRAME-thick border
313 // at the top (see AeroGlassFrame::OnGetMinMaxInfo()).
314 return gfx::win::GetSystemMetricsInDIP(SM_CYSIZEFRAME) +
315 (!frame()->ShouldLeaveOffsetNearTopBorder() ?
316 -kTabstripTopShadowThickness : kNonClientRestoredExtraThickness);
319 void GlassBrowserFrameView::PaintToolbarBackground(gfx::Canvas* canvas) {
320 ui::ThemeProvider* tp = GetThemeProvider();
322 gfx::Rect toolbar_bounds(browser_view()->GetToolbarBounds());
323 gfx::Point toolbar_origin(toolbar_bounds.origin());
324 View::ConvertPointToTarget(browser_view(), this, &toolbar_origin);
325 toolbar_bounds.set_origin(toolbar_origin);
326 int x = toolbar_bounds.x();
327 int w = toolbar_bounds.width();
328 int left_x = x - kContentEdgeShadowThickness;
330 gfx::ImageSkia* theme_toolbar = tp->GetImageSkiaNamed(IDR_THEME_TOOLBAR);
331 gfx::ImageSkia* toolbar_left = tp->GetImageSkiaNamed(
332 IDR_CONTENT_TOP_LEFT_CORNER);
333 gfx::ImageSkia* toolbar_center = tp->GetImageSkiaNamed(
334 IDR_CONTENT_TOP_CENTER);
336 // Tile the toolbar image starting at the frame edge on the left and where
337 // the tabstrip is on the top.
338 int y = toolbar_bounds.y();
339 int dest_y = browser_view()->IsTabStripVisible()
340 ? y + (kFrameShadowThickness * 2)
341 : y;
342 canvas->TileImageInt(*theme_toolbar,
343 x + GetThemeBackgroundXInset(),
344 dest_y - GetTopInset(), x,
345 dest_y, w, theme_toolbar->height());
347 if (browser_view()->IsTabStripVisible()) {
348 // Draw rounded corners for the tab.
349 gfx::ImageSkia* toolbar_left_mask =
350 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER_MASK);
351 gfx::ImageSkia* toolbar_right_mask =
352 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER_MASK);
354 // We mask out the corners by using the DestinationIn transfer mode,
355 // which keeps the RGB pixels from the destination and the alpha from
356 // the source.
357 SkPaint paint;
358 paint.setXfermodeMode(SkXfermode::kDstIn_Mode);
360 // Mask out the top left corner.
361 canvas->DrawImageInt(*toolbar_left_mask, left_x, y, paint);
363 // Mask out the top right corner.
364 int right_x =
365 x + w + kContentEdgeShadowThickness - toolbar_right_mask->width();
366 canvas->DrawImageInt(*toolbar_right_mask, right_x, y, paint);
368 // Draw left edge.
369 canvas->DrawImageInt(*toolbar_left, left_x, y);
371 // Draw center edge.
372 canvas->TileImageInt(*toolbar_center, left_x + toolbar_left->width(), y,
373 right_x - (left_x + toolbar_left->width()), toolbar_center->height());
375 // Right edge.
376 canvas->DrawImageInt(*tp->GetImageSkiaNamed(IDR_CONTENT_TOP_RIGHT_CORNER),
377 right_x, y);
380 // Draw the content/toolbar separator.
381 canvas->FillRect(
382 gfx::Rect(x + kClientEdgeThickness,
383 toolbar_bounds.bottom() - kClientEdgeThickness,
384 w - (2 * kClientEdgeThickness),
385 kClientEdgeThickness),
386 ThemeProperties::GetDefaultColor(
387 ThemeProperties::COLOR_TOOLBAR_SEPARATOR));
390 void GlassBrowserFrameView::PaintRestoredClientEdge(gfx::Canvas* canvas) {
391 ui::ThemeProvider* tp = GetThemeProvider();
392 gfx::Rect client_area_bounds = CalculateClientAreaBounds(width(), height());
394 // The client edges start below the toolbar upper corner images regardless
395 // of how tall the toolbar itself is.
396 int client_area_top = frame()->client_view()->y() +
397 browser_view()->GetToolbarBounds().y() +
398 tp->GetImageSkiaNamed(IDR_CONTENT_TOP_LEFT_CORNER)->height();
399 int client_area_bottom =
400 std::max(client_area_top, height() - NonClientBorderThickness());
401 int client_area_height = client_area_bottom - client_area_top;
403 // Draw the client edge images.
404 gfx::ImageSkia* right = tp->GetImageSkiaNamed(IDR_CONTENT_RIGHT_SIDE);
405 canvas->TileImageInt(*right, client_area_bounds.right(), client_area_top,
406 right->width(), client_area_height);
407 canvas->DrawImageInt(
408 *tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_RIGHT_CORNER),
409 client_area_bounds.right(), client_area_bottom);
410 gfx::ImageSkia* bottom = tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_CENTER);
411 canvas->TileImageInt(*bottom, client_area_bounds.x(),
412 client_area_bottom, client_area_bounds.width(),
413 bottom->height());
414 gfx::ImageSkia* bottom_left =
415 tp->GetImageSkiaNamed(IDR_CONTENT_BOTTOM_LEFT_CORNER);
416 canvas->DrawImageInt(*bottom_left,
417 client_area_bounds.x() - bottom_left->width(), client_area_bottom);
418 gfx::ImageSkia* left = tp->GetImageSkiaNamed(IDR_CONTENT_LEFT_SIDE);
419 canvas->TileImageInt(*left, client_area_bounds.x() - left->width(),
420 client_area_top, left->width(), client_area_height);
422 // Draw the toolbar color so that the client edges show the right color even
423 // where not covered by the toolbar image. NOTE: We do this after drawing the
424 // images because the images are meant to alpha-blend atop the frame whereas
425 // these rects are meant to be fully opaque, without anything overlaid.
426 SkColor toolbar_color = tp->GetColor(ThemeProperties::COLOR_TOOLBAR);
427 canvas->FillRect(gfx::Rect(client_area_bounds.x() - kClientEdgeThickness,
428 client_area_top, kClientEdgeThickness,
429 client_area_bottom + kClientEdgeThickness - client_area_top),
430 toolbar_color);
431 canvas->FillRect(gfx::Rect(client_area_bounds.x(), client_area_bottom,
432 client_area_bounds.width(), kClientEdgeThickness),
433 toolbar_color);
434 canvas->FillRect(gfx::Rect(client_area_bounds.right(), client_area_top,
435 kClientEdgeThickness,
436 client_area_bottom + kClientEdgeThickness - client_area_top),
437 toolbar_color);
440 void GlassBrowserFrameView::LayoutNewStyleAvatar() {
441 DCHECK(switches::IsNewProfileManagement());
442 if (!new_avatar_button())
443 return;
445 gfx::Size label_size = new_avatar_button()->GetPreferredSize();
446 int button_size_with_offset = kNewAvatarButtonOffset + label_size.width();
448 int button_x = frame()->GetMinimizeButtonOffset() -
449 kNewAvatarButtonOffset - label_size.width();
451 if (base::i18n::IsRTL())
452 button_x = width() - frame()->GetMinimizeButtonOffset() +
453 kNewAvatarButtonOffset;
455 int button_y = frame()->IsMaximized() ? NonClientTopBorderHeight() : 1;
456 new_avatar_button()->SetBounds(
457 button_x,
458 button_y,
459 label_size.width(),
460 button_y + gfx::win::GetSystemMetricsInDIP(SM_CXMENUSIZE));
463 void GlassBrowserFrameView::LayoutAvatar() {
464 // Even though the avatar is used for both incognito and profiles we always
465 // use the incognito icon to layout the avatar button. The profile icon
466 // can be customized so we can't depend on its size to perform layout.
467 gfx::ImageSkia incognito_icon = browser_view()->GetOTRAvatarIcon();
469 int avatar_x = NonClientBorderThickness() + kAvatarLeftSpacing;
470 // Move this avatar icon by the size of window controls to prevent it from
471 // being rendered over them in RTL languages. This code also needs to adjust
472 // the width of a tab strip to avoid decreasing this size twice. (See the
473 // comment in GetBoundsForTabStrip().)
474 if (base::i18n::IsRTL())
475 avatar_x += width() - frame()->GetMinimizeButtonOffset();
477 int avatar_bottom = GetTopInset() +
478 browser_view()->GetTabStripHeight() - kAvatarBottomSpacing;
479 int avatar_restored_y = avatar_bottom - incognito_icon.height();
480 int avatar_y = frame()->IsMaximized() ?
481 (NonClientTopBorderHeight() + kTabstripTopShadowThickness) :
482 avatar_restored_y;
483 avatar_bounds_.SetRect(avatar_x, avatar_y, incognito_icon.width(),
484 browser_view()->ShouldShowAvatar() ? (avatar_bottom - avatar_y) : 0);
485 if (avatar_button())
486 avatar_button()->SetBoundsRect(avatar_bounds_);
489 void GlassBrowserFrameView::LayoutClientView() {
490 client_view_bounds_ = CalculateClientAreaBounds(width(), height());
493 gfx::Insets GlassBrowserFrameView::GetClientAreaInsets() const {
494 if (!browser_view()->IsTabStripVisible())
495 return gfx::Insets();
497 const int top_height = NonClientTopBorderHeight();
498 const int border_thickness = NonClientBorderThickness();
499 return gfx::Insets(top_height,
500 border_thickness,
501 border_thickness,
502 border_thickness);
505 gfx::Rect GlassBrowserFrameView::CalculateClientAreaBounds(int width,
506 int height) const {
507 gfx::Rect bounds(0, 0, width, height);
508 bounds.Inset(GetClientAreaInsets());
509 return bounds;
512 void GlassBrowserFrameView::StartThrobber() {
513 if (!throbber_running_) {
514 throbber_running_ = true;
515 throbber_frame_ = 0;
516 InitThrobberIcons();
517 SendMessage(views::HWNDForWidget(frame()), WM_SETICON,
518 static_cast<WPARAM>(ICON_SMALL),
519 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
523 void GlassBrowserFrameView::StopThrobber() {
524 if (throbber_running_) {
525 throbber_running_ = false;
527 HICON frame_icon = NULL;
529 // Check if hosted BrowserView has a window icon to use.
530 if (browser_view()->ShouldShowWindowIcon()) {
531 gfx::ImageSkia icon = browser_view()->GetWindowIcon();
532 if (!icon.isNull())
533 frame_icon = IconUtil::CreateHICONFromSkBitmap(*icon.bitmap());
536 // Fallback to class icon.
537 if (!frame_icon) {
538 frame_icon = reinterpret_cast<HICON>(GetClassLongPtr(
539 views::HWNDForWidget(frame()), GCLP_HICONSM));
542 // This will reset the small icon which we set in the throbber code.
543 // WM_SETICON with NULL icon restores the icon for title bar but not
544 // for taskbar. See http://crbug.com/29996
545 SendMessage(views::HWNDForWidget(frame()), WM_SETICON,
546 static_cast<WPARAM>(ICON_SMALL),
547 reinterpret_cast<LPARAM>(frame_icon));
551 void GlassBrowserFrameView::DisplayNextThrobberFrame() {
552 throbber_frame_ = (throbber_frame_ + 1) % kThrobberIconCount;
553 SendMessage(views::HWNDForWidget(frame()), WM_SETICON,
554 static_cast<WPARAM>(ICON_SMALL),
555 reinterpret_cast<LPARAM>(throbber_icons_[throbber_frame_]));
558 void GlassBrowserFrameView::Observe(
559 int type,
560 const content::NotificationSource& source,
561 const content::NotificationDetails& details) {
562 switch (type) {
563 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED:
564 if (browser_view()->IsRegularOrGuestSession() &&
565 switches::IsNewProfileManagement())
566 UpdateNewStyleAvatarInfo(this, NewAvatarButton::NATIVE_BUTTON);
567 else
568 UpdateAvatarInfo();
569 break;
570 default:
571 NOTREACHED() << "Got a notification we didn't register for!";
572 break;
576 // static
577 void GlassBrowserFrameView::InitThrobberIcons() {
578 static bool initialized = false;
579 if (!initialized) {
580 for (int i = 0; i < kThrobberIconCount; ++i) {
581 throbber_icons_[i] =
582 ui::LoadThemeIconFromResourcesDataDLL(IDI_THROBBER_01 + i);
583 DCHECK(throbber_icons_[i]);
585 initialized = true;