Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.cc

Issue 2832823002: Update avatar button to MD (Closed)
Patch Set: Rebased on CL 2833363002 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_non_client_frame_view_mus.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_mus.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/profiles/profiles_state.h" 9 #include "chrome/browser/profiles/profiles_state.h"
10 #include "chrome/browser/themes/theme_properties.h" 10 #include "chrome/browser/themes/theme_properties.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 163
164 int BrowserNonClientFrameViewMus::GetThemeBackgroundXInset() const { 164 int BrowserNonClientFrameViewMus::GetThemeBackgroundXInset() const {
165 return 5; 165 return 5;
166 } 166 }
167 167
168 void BrowserNonClientFrameViewMus::UpdateThrobber(bool running) { 168 void BrowserNonClientFrameViewMus::UpdateThrobber(bool running) {
169 if (window_icon_) 169 if (window_icon_)
170 window_icon_->Update(); 170 window_icon_->Update();
171 } 171 }
172 172
173 views::View* BrowserNonClientFrameViewMus::GetProfileSwitcherView() const { 173 views::MenuButton* BrowserNonClientFrameViewMus::GetProfileSwitcherButton()
174 const {
174 #if defined(FRAME_AVATAR_BUTTON) 175 #if defined(FRAME_AVATAR_BUTTON)
175 return profile_switcher_.view(); 176 return profile_switcher_.button();
176 #else 177 #else
177 return nullptr; 178 return nullptr;
178 #endif 179 #endif
179 } 180 }
180 181
181 void BrowserNonClientFrameViewMus::UpdateClientArea() { 182 void BrowserNonClientFrameViewMus::UpdateClientArea() {
182 std::vector<gfx::Rect> additional_client_area; 183 std::vector<gfx::Rect> additional_client_area;
183 int top_container_offset = 0; 184 int top_container_offset = 0;
184 ImmersiveModeController* immersive_mode_controller = 185 ImmersiveModeController* immersive_mode_controller =
185 browser_view()->immersive_mode_controller(); 186 browser_view()->immersive_mode_controller();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 gfx::Rect BrowserNonClientFrameViewMus::GetWindowBoundsForClientBounds( 244 gfx::Rect BrowserNonClientFrameViewMus::GetWindowBoundsForClientBounds(
244 const gfx::Rect& client_bounds) const { 245 const gfx::Rect& client_bounds) const {
245 return client_bounds; 246 return client_bounds;
246 } 247 }
247 248
248 int BrowserNonClientFrameViewMus::NonClientHitTest(const gfx::Point& point) { 249 int BrowserNonClientFrameViewMus::NonClientHitTest(const gfx::Point& point) {
249 // TODO(sky): figure out how this interaction should work. 250 // TODO(sky): figure out how this interaction should work.
250 int hit_test = HTCLIENT; 251 int hit_test = HTCLIENT;
251 252
252 #if defined(FRAME_AVATAR_BUTTON) 253 #if defined(FRAME_AVATAR_BUTTON)
253 if (hit_test == HTCAPTION && profile_switcher_.view() && 254 if (hit_test == HTCAPTION && GetProfileSwitcherButton() &&
254 ConvertedHitTest(this, profile_switcher_.view(), point)) { 255 ConvertedHitTest(this, GetProfileSwitcherButton(), point)) {
Peter Kasting 2017/04/26 02:09:53 Nit: Use a temp to capture the return value of Cam
emx 2017/04/27 16:30:58 Done.
255 return HTCLIENT; 256 return HTCLIENT;
256 } 257 }
257 #endif 258 #endif
258 259
259 // When the window is restored we want a large click target above the tabs 260 // When the window is restored we want a large click target above the tabs
260 // to drag the window, so redirect clicks in the tab's shadow to caption. 261 // to drag the window, so redirect clicks in the tab's shadow to caption.
261 if (hit_test == HTCLIENT && 262 if (hit_test == HTCLIENT &&
262 !(frame()->IsMaximized() || frame()->IsFullscreen())) { 263 !(frame()->IsMaximized() || frame()->IsFullscreen())) {
263 // Convert point to client coordinates. 264 // Convert point to client coordinates.
264 gfx::Point client_point(point); 265 gfx::Point client_point(point);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 PaintToolbarBackground(canvas); 299 PaintToolbarBackground(canvas);
299 else if (!UsePackagedAppHeaderStyle()) 300 else if (!UsePackagedAppHeaderStyle())
300 PaintContentEdge(canvas); 301 PaintContentEdge(canvas);
301 } 302 }
302 303
303 void BrowserNonClientFrameViewMus::Layout() { 304 void BrowserNonClientFrameViewMus::Layout() {
304 if (profile_indicator_icon()) 305 if (profile_indicator_icon())
305 LayoutIncognitoButton(); 306 LayoutIncognitoButton();
306 307
307 #if defined(FRAME_AVATAR_BUTTON) 308 #if defined(FRAME_AVATAR_BUTTON)
308 if (profile_switcher_.view()) 309 if (GetProfileSwitcherButton())
309 LayoutProfileSwitcher(); 310 LayoutProfileSwitcher();
310 #endif 311 #endif
311 312
312 BrowserNonClientFrameView::Layout(); 313 BrowserNonClientFrameView::Layout();
313 314
314 UpdateClientArea(); 315 UpdateClientArea();
315 } 316 }
316 317
317 const char* BrowserNonClientFrameViewMus::GetClassName() const { 318 const char* BrowserNonClientFrameViewMus::GetClassName() const {
318 return kViewClassName; 319 return kViewClassName;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 return avatar_right + kAvatarIconPadding + 402 return avatar_right + kAvatarIconPadding +
402 frame_values().normal_insets.left(); 403 frame_values().normal_insets.left();
403 } 404 }
404 405
405 int BrowserNonClientFrameViewMus::GetTabStripRightInset() const { 406 int BrowserNonClientFrameViewMus::GetTabStripRightInset() const {
406 const int frame_right_insets = frame_values().normal_insets.right() + 407 const int frame_right_insets = frame_values().normal_insets.right() +
407 frame_values().max_title_bar_button_width; 408 frame_values().max_title_bar_button_width;
408 int right_inset = kTabstripRightSpacing + frame_right_insets; 409 int right_inset = kTabstripRightSpacing + frame_right_insets;
409 410
410 #if defined(FRAME_AVATAR_BUTTON) 411 #if defined(FRAME_AVATAR_BUTTON)
411 if (profile_switcher_.view()) { 412 if (GetProfileSwitcherButton()) {
412 right_inset += kAvatarButtonOffset + 413 right_inset += kAvatarButtonOffset +
413 profile_switcher_.view()->GetPreferredSize().width(); 414 GetProfileSwitcherButton()->GetPreferredSize().width();
414 } 415 }
415 #endif 416 #endif
416 417
417 return right_inset; 418 return right_inset;
418 } 419 }
419 420
420 bool BrowserNonClientFrameViewMus::UsePackagedAppHeaderStyle() const { 421 bool BrowserNonClientFrameViewMus::UsePackagedAppHeaderStyle() const {
421 // Use for non tabbed trusted source windows, e.g. Settings, as well as apps. 422 // Use for non tabbed trusted source windows, e.g. Settings, as well as apps.
422 const Browser* const browser = browser_view()->browser(); 423 const Browser* const browser = browser_view()->browser();
423 return (!browser->is_type_tabbed() && browser->is_trusted_source()) || 424 return (!browser->is_type_tabbed() && browser->is_trusted_source()) ||
(...skipping 13 matching lines...) Expand all
437 int avatar_height = incognito_icon.height(); 438 int avatar_height = incognito_icon.height();
438 439
439 gfx::Rect avatar_bounds(kAvatarIconPadding, avatar_y, incognito_icon.width(), 440 gfx::Rect avatar_bounds(kAvatarIconPadding, avatar_y, incognito_icon.width(),
440 avatar_height); 441 avatar_height);
441 profile_indicator_icon()->SetBoundsRect(avatar_bounds); 442 profile_indicator_icon()->SetBoundsRect(avatar_bounds);
442 profile_indicator_icon()->SetVisible(true); 443 profile_indicator_icon()->SetVisible(true);
443 } 444 }
444 445
445 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() { 446 void BrowserNonClientFrameViewMus::LayoutProfileSwitcher() {
446 #if defined(FRAME_AVATAR_BUTTON) 447 #if defined(FRAME_AVATAR_BUTTON)
447 gfx::Size button_size = profile_switcher_.view()->GetPreferredSize(); 448 gfx::Size button_size = GetProfileSwitcherButton()->GetPreferredSize();
448 int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset; 449 int button_x = width() - GetTabStripRightInset() + kAvatarButtonOffset;
449 profile_switcher_.view()->SetBounds(button_x, 0, button_size.width(), 450 GetProfileSwitcherButton()->SetBounds(button_x, 0, button_size.width(),
450 button_size.height()); 451 button_size.height());
451 #endif 452 #endif
452 } 453 }
453 454
454 bool BrowserNonClientFrameViewMus::ShouldPaint() const { 455 bool BrowserNonClientFrameViewMus::ShouldPaint() const {
455 if (!frame()->IsFullscreen()) 456 if (!frame()->IsFullscreen())
456 return true; 457 return true;
457 458
458 // We need to paint when the top-of-window views are revealed in immersive 459 // We need to paint when the top-of-window views are revealed in immersive
459 // fullscreen. 460 // fullscreen.
460 ImmersiveModeController* immersive_mode_controller = 461 ImmersiveModeController* immersive_mode_controller =
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 // TODO: move ash_layout_constants to ash/public/cpp. 518 // TODO: move ash_layout_constants to ash/public/cpp.
518 const bool restored = !frame()->IsMaximized() && !frame()->IsFullscreen(); 519 const bool restored = !frame()->IsMaximized() && !frame()->IsFullscreen();
519 return GetAshLayoutSize(restored 520 return GetAshLayoutSize(restored
520 ? AshLayoutSize::BROWSER_RESTORED_CAPTION_BUTTON 521 ? AshLayoutSize::BROWSER_RESTORED_CAPTION_BUTTON
521 : AshLayoutSize::BROWSER_MAXIMIZED_CAPTION_BUTTON) 522 : AshLayoutSize::BROWSER_MAXIMIZED_CAPTION_BUTTON)
522 .height(); 523 .height();
523 #else 524 #else
524 return views::WindowManagerFrameValues::instance().normal_insets.top(); 525 return views::WindowManagerFrameValues::instance().normal_insets.top();
525 #endif 526 #endif
526 } 527 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698