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

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

Issue 1019023002: MacViews: Implement non-client frame view (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@wrench-menu
Patch Set: Use Yosemite colors Created 5 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 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 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.h" 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
6 6
7 #include "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/avatar_menu.h" 8 #include "chrome/browser/profiles/avatar_menu.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
11 #include "chrome/browser/profiles/profile_info_cache.h" 11 #include "chrome/browser/profiles/profile_info_cache.h"
12 #include "chrome/browser/profiles/profile_manager.h" 12 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/profiles/profiles_state.h" 13 #include "chrome/browser/profiles/profiles_state.h"
14 #include "chrome/browser/themes/theme_properties.h"
14 #include "chrome/browser/ui/view_ids.h" 15 #include "chrome/browser/ui/view_ids.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" 17 #include "chrome/browser/ui/views/frame/taskbar_decorator.h"
17 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" 18 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
18 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 19 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
20 #include "chrome/browser/ui/views/tabs/tab_strip.h"
21 #include "chrome/browser/ui/views/theme_image_mapper.h"
19 #include "components/signin/core/common/profile_management_switches.h" 22 #include "components/signin/core/common/profile_management_switches.h"
20 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
21 #include "third_party/skia/include/core/SkColor.h" 24 #include "third_party/skia/include/core/SkColor.h"
22 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
23 #include "ui/base/theme_provider.h" 26 #include "ui/base/theme_provider.h"
24 #include "ui/gfx/image/image.h" 27 #include "ui/gfx/image/image.h"
28 #include "ui/resources/grit/ui_resources.h"
25 #include "ui/views/background.h" 29 #include "ui/views/background.h"
26 30
27 #if defined(ENABLE_SUPERVISED_USERS) 31 #if defined(ENABLE_SUPERVISED_USERS)
28 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h" 32 #include "chrome/browser/ui/views/profiles/supervised_user_avatar_label.h"
29 #endif 33 #endif
30 34
31 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, 35 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame,
32 BrowserView* browser_view) 36 BrowserView* browser_view)
33 : frame_(frame), 37 : frame_(frame),
34 browser_view_(browser_view), 38 browser_view_(browser_view),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 93 }
90 } 94 }
91 95
92 #if defined(ENABLE_SUPERVISED_USERS) 96 #if defined(ENABLE_SUPERVISED_USERS)
93 void BrowserNonClientFrameView::OnThemeChanged() { 97 void BrowserNonClientFrameView::OnThemeChanged() {
94 if (supervised_user_avatar_label_) 98 if (supervised_user_avatar_label_)
95 supervised_user_avatar_label_->UpdateLabelStyle(); 99 supervised_user_avatar_label_->UpdateLabelStyle();
96 } 100 }
97 #endif 101 #endif
98 102
103 bool BrowserNonClientFrameView::ShouldPaintAsThemed() const {
104 return browser_view_->IsBrowserTypeNormal();
105 }
106
107 SkColor BrowserNonClientFrameView::GetFrameColor() const {
108 const bool incognito = browser_view_->IsOffTheRecord();
109 ThemeProperties::OverwritableByUserThemeProperty color_id;
110 if (ShouldPaintAsActive()) {
111 color_id = incognito ? ThemeProperties::COLOR_FRAME_INCOGNITO
112 : ThemeProperties::COLOR_FRAME;
113 } else {
114 color_id = incognito ? ThemeProperties::COLOR_FRAME_INCOGNITO_INACTIVE
115 : ThemeProperties::COLOR_FRAME_INACTIVE;
116 }
117 return ShouldPaintAsThemed() ? GetThemeProvider()->GetColor(color_id)
118 : ThemeProperties::GetDefaultColor(color_id);
119 }
120
121 gfx::ImageSkia* BrowserNonClientFrameView::GetFrameImage() const {
122 const bool incognito = browser_view_->IsOffTheRecord();
123 int resource_id;
124 if (browser_view_->IsBrowserTypeNormal()) {
125 if (ShouldPaintAsActive()) {
126 resource_id = incognito ? IDR_THEME_FRAME_INCOGNITO : IDR_THEME_FRAME;
127 } else {
128 resource_id = incognito ? IDR_THEME_FRAME_INCOGNITO_INACTIVE
129 : IDR_THEME_FRAME_INACTIVE;
130 }
131 return GetThemeProvider()->GetImageSkiaNamed(resource_id);
132 }
133
134 if (ShouldPaintAsActive()) {
135 resource_id = incognito ? IDR_THEME_FRAME_INCOGNITO : IDR_FRAME;
136 } else {
137 resource_id = incognito ? IDR_THEME_FRAME_INCOGNITO_INACTIVE
138 : IDR_THEME_FRAME_INACTIVE;
139 }
140
141 if (ShouldPaintAsThemed()) {
142 // On Linux, we want to use theme images provided by the system theme when
143 // enabled, even if we are an app or popup window.
144 return GetThemeProvider()->GetImageSkiaNamed(resource_id);
145 }
146
147 // Otherwise, never theme app and popup windows.
148 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
149 return rb.GetImageSkiaNamed(
150 chrome::MapThemeImage(chrome::GetHostDesktopTypeForNativeWindow(
151 browser_view_->GetNativeWindow()),
152 resource_id));
153 }
154
155 gfx::ImageSkia* BrowserNonClientFrameView::GetFrameOverlayImage() const {
156 ui::ThemeProvider* tp = GetThemeProvider();
157 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) &&
158 browser_view_->IsBrowserTypeNormal() &&
159 !browser_view_->IsOffTheRecord()) {
160 return tp->GetImageSkiaNamed(ShouldPaintAsActive() ?
161 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE);
162 }
163 return nullptr;
164 }
165
166 int BrowserNonClientFrameView::GetTopAreaHeight() const {
167 gfx::ImageSkia* frame_image = GetFrameImage();
168 int top_area_height = frame_image->height();
169 if (browser_view_->IsTabStripVisible()) {
170 top_area_height = std::max(top_area_height,
171 GetBoundsForTabStrip(browser_view_->tabstrip()).bottom());
172 }
173 return top_area_height;
174 }
175
99 void BrowserNonClientFrameView::UpdateAvatar() { 176 void BrowserNonClientFrameView::UpdateAvatar() {
100 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu()) 177 if (browser_view()->IsRegularOrGuestSession() && switches::IsNewAvatarMenu())
101 UpdateNewStyleAvatar(); 178 UpdateNewStyleAvatar();
102 else 179 else
103 UpdateAvatarInfo(); 180 UpdateAvatarInfo();
104 } 181 }
105 182
106 void BrowserNonClientFrameView::UpdateAvatarInfo() { 183 void BrowserNonClientFrameView::UpdateAvatarInfo() {
107 if (browser_view_->ShouldShowAvatar()) { 184 if (browser_view_->ShouldShowAvatar()) {
108 if (!avatar_button_) { 185 if (!avatar_button_) {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 const ProfileInfoCache& cache = 314 const ProfileInfoCache& cache =
238 g_browser_process->profile_manager()->GetProfileInfoCache(); 315 g_browser_process->profile_manager()->GetProfileInfoCache();
239 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; 316 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1;
240 } 317 }
241 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), 318 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(),
242 show_decoration 319 show_decoration
243 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) 320 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar)
244 : nullptr); 321 : nullptr);
245 } 322 }
246 } 323 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698