| 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/opaque_browser_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 window_icon_->set_is_light(true); | 200 window_icon_->set_is_light(true); |
| 201 AddChildView(window_icon_); | 201 AddChildView(window_icon_); |
| 202 window_icon_->Update(); | 202 window_icon_->Update(); |
| 203 } | 203 } |
| 204 | 204 |
| 205 // If multi-profile is enabled set up profile button and login notifications. | 205 // If multi-profile is enabled set up profile button and login notifications. |
| 206 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 206 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
| 207 if (browser_command_line.HasSwitch(switches::kMultiProfiles) && | 207 if (browser_command_line.HasSwitch(switches::kMultiProfiles) && |
| 208 !browser_view_->ShouldShowOffTheRecordAvatar()) { | 208 !browser_view_->ShouldShowOffTheRecordAvatar()) { |
| 209 RegisterLoginNotifications(); | 209 RegisterLoginNotifications(); |
| 210 profile_button_.reset(new ProfileMenuButton(NULL, std::wstring(), | 210 profile_button_.reset(new ProfileMenuButton(std::wstring(), |
| 211 this, browser_view_->browser()->profile())); | 211 browser_view_->browser()->profile())); |
| 212 profile_button_->SetVisible(false); | 212 profile_button_->SetVisible(false); |
| 213 profile_tag_.reset(new ProfileTagView(frame_, profile_button_.get())); | 213 profile_tag_.reset(new ProfileTagView(frame_, profile_button_.get())); |
| 214 profile_tag_->SetVisible(false); | 214 profile_tag_->SetVisible(false); |
| 215 AddChildView(profile_tag_.get()); | 215 AddChildView(profile_tag_.get()); |
| 216 AddChildView(profile_button_.get()); | 216 AddChildView(profile_button_.get()); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { | 220 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { |
| 221 } | 221 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 minimize_button_->SetState(views::CustomButton::BS_NORMAL); | 413 minimize_button_->SetState(views::CustomButton::BS_NORMAL); |
| 414 maximize_button_->SetState(views::CustomButton::BS_NORMAL); | 414 maximize_button_->SetState(views::CustomButton::BS_NORMAL); |
| 415 // The close button isn't affected by this constraint. | 415 // The close button isn't affected by this constraint. |
| 416 } | 416 } |
| 417 | 417 |
| 418 void OpaqueBrowserFrameView::UpdateWindowIcon() { | 418 void OpaqueBrowserFrameView::UpdateWindowIcon() { |
| 419 window_icon_->SchedulePaint(); | 419 window_icon_->SchedulePaint(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 /////////////////////////////////////////////////////////////////////////////// | 422 /////////////////////////////////////////////////////////////////////////////// |
| 423 // OpaqueBrowserFrameView, views::ViewMenuDelegate overrides: | |
| 424 void OpaqueBrowserFrameView::RunMenu(views::View* source, | |
| 425 const gfx::Point &pt) { | |
| 426 profile_button_->RunMenuAt(pt); | |
| 427 } | |
| 428 | |
| 429 /////////////////////////////////////////////////////////////////////////////// | |
| 430 // OpaqueBrowserFrameView, views::View overrides: | 423 // OpaqueBrowserFrameView, views::View overrides: |
| 431 | 424 |
| 432 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { | 425 void OpaqueBrowserFrameView::OnPaint(gfx::Canvas* canvas) { |
| 433 if (frame_->IsFullscreen()) | 426 if (frame_->IsFullscreen()) |
| 434 return; // Nothing is visible, so don't bother to paint. | 427 return; // Nothing is visible, so don't bother to paint. |
| 435 | 428 |
| 436 if (frame_->IsMaximized()) | 429 if (frame_->IsMaximized()) |
| 437 PaintMaximizedFrameBorder(canvas); | 430 PaintMaximizedFrameBorder(canvas); |
| 438 else | 431 else |
| 439 PaintRestoredFrameBorder(canvas); | 432 PaintRestoredFrameBorder(canvas); |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 std::max(0, width - (2 * border_thickness)), | 1212 std::max(0, width - (2 * border_thickness)), |
| 1220 std::max(0, height - GetReservedHeight() - | 1213 std::max(0, height - GetReservedHeight() - |
| 1221 top_height - border_thickness)); | 1214 top_height - border_thickness)); |
| 1222 } | 1215 } |
| 1223 | 1216 |
| 1224 void OpaqueBrowserFrameView::RegisterLoginNotifications() { | 1217 void OpaqueBrowserFrameView::RegisterLoginNotifications() { |
| 1225 PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs(); | 1218 PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs(); |
| 1226 DCHECK(pref_service); | 1219 DCHECK(pref_service); |
| 1227 username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this); | 1220 username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this); |
| 1228 } | 1221 } |
| OLD | NEW |