| OLD | NEW |
| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/avatar_menu.h" | 9 #include "chrome/browser/profiles/avatar_menu.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 202 |
| 203 // Changing the activation state may change the toolbar top separator color | 203 // Changing the activation state may change the toolbar top separator color |
| 204 // that's used as the stroke around tabs/the new tab button. | 204 // that's used as the stroke around tabs/the new tab button. |
| 205 browser_view_->tabstrip()->SchedulePaint(); | 205 browser_view_->tabstrip()->SchedulePaint(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 // Changing the activation state may change the visible frame color. | 208 // Changing the activation state may change the visible frame color. |
| 209 SchedulePaint(); | 209 SchedulePaint(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 bool BrowserNonClientFrameView::DoesIntersectRect(const views::View* target, | |
| 213 const gfx::Rect& rect) const { | |
| 214 DCHECK_EQ(target, this); | |
| 215 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { | |
| 216 // |rect| is outside the frame's bounds. | |
| 217 return false; | |
| 218 } | |
| 219 | |
| 220 // If the rect is outside the bounds of the client area, claim it. | |
| 221 gfx::RectF rect_in_client_view_coords_f(rect); | |
| 222 View::ConvertRectToTarget(this, frame()->client_view(), | |
| 223 &rect_in_client_view_coords_f); | |
| 224 gfx::Rect rect_in_client_view_coords = | |
| 225 gfx::ToEnclosingRect(rect_in_client_view_coords_f); | |
| 226 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) | |
| 227 return true; | |
| 228 | |
| 229 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in | |
| 230 // a non-tab portion. | |
| 231 TabStrip* tabstrip = browser_view()->tabstrip(); | |
| 232 if (!tabstrip || !browser_view()->IsTabStripVisible()) | |
| 233 return false; | |
| 234 | |
| 235 gfx::RectF rect_in_tabstrip_coords_f(rect); | |
| 236 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); | |
| 237 gfx::Rect rect_in_tabstrip_coords = | |
| 238 gfx::ToEnclosingRect(rect_in_tabstrip_coords_f); | |
| 239 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { | |
| 240 // |rect| is below the tabstrip. | |
| 241 return false; | |
| 242 } | |
| 243 | |
| 244 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { | |
| 245 // Claim |rect| if it is in a non-tab portion of the tabstrip. | |
| 246 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); | |
| 247 } | |
| 248 | |
| 249 // We claim |rect| because it is above the bottom of the tabstrip, but | |
| 250 // not in the tabstrip itself. In particular, the avatar label/button is left | |
| 251 // of the tabstrip and the window controls are right of the tabstrip. | |
| 252 return true; | |
| 253 } | |
| 254 | |
| 255 void BrowserNonClientFrameView::OnProfileAdded( | 212 void BrowserNonClientFrameView::OnProfileAdded( |
| 256 const base::FilePath& profile_path) { | 213 const base::FilePath& profile_path) { |
| 257 OnProfileAvatarChanged(profile_path); | 214 OnProfileAvatarChanged(profile_path); |
| 258 } | 215 } |
| 259 | 216 |
| 260 void BrowserNonClientFrameView::OnProfileWasRemoved( | 217 void BrowserNonClientFrameView::OnProfileWasRemoved( |
| 261 const base::FilePath& profile_path, | 218 const base::FilePath& profile_path, |
| 262 const base::string16& profile_name) { | 219 const base::string16& profile_name) { |
| 263 OnProfileAvatarChanged(profile_path); | 220 OnProfileAvatarChanged(profile_path); |
| 264 } | 221 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 // safety. See crbug.com/313800. | 255 // safety. See crbug.com/313800. |
| 299 gfx::Image decoration; | 256 gfx::Image decoration; |
| 300 AvatarMenu::GetImageForMenuButton( | 257 AvatarMenu::GetImageForMenuButton( |
| 301 browser_view()->browser()->profile()->GetPath(), &decoration); | 258 browser_view()->browser()->profile()->GetPath(), &decoration); |
| 302 // This can happen if the user deletes the current profile. | 259 // This can happen if the user deletes the current profile. |
| 303 if (decoration.IsEmpty()) | 260 if (decoration.IsEmpty()) |
| 304 return; | 261 return; |
| 305 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), &decoration); | 262 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), &decoration); |
| 306 #endif | 263 #endif |
| 307 } | 264 } |
| OLD | NEW |