| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 DCHECK(vectorIconId != gfx::VectorIconId::VECTOR_ICON_NONE); | 578 DCHECK(vectorIconId != gfx::VectorIconId::VECTOR_ICON_NONE); |
| 579 NSImage* image = NSImageFromImageSkia(gfx::CreateVectorIcon( | 579 NSImage* image = NSImageFromImageSkia(gfx::CreateVectorIcon( |
| 580 vectorIconId, kIconSize, vectorIconColor)); | 580 vectorIconId, kIconSize, vectorIconColor)); |
| 581 | 581 |
| 582 location_icon_decoration_->SetImage(image); | 582 location_icon_decoration_->SetImage(image); |
| 583 ev_bubble_decoration_->SetImage(image); | 583 ev_bubble_decoration_->SetImage(image); |
| 584 | 584 |
| 585 Layout(); | 585 Layout(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 void LocationBarViewMac::OnAddedToWindow() { | 588 void LocationBarViewMac::UpdateColorsToMatchTheme() { |
| 589 if (!ui::MaterialDesignController::IsModeMaterial()) { | 589 if (!ui::MaterialDesignController::IsModeMaterial() || |
| 590 ![[field_ window] inIncognitoMode]) { |
| 590 return; | 591 return; |
| 591 } | 592 } |
| 592 | 593 |
| 593 // Update the location-bar icon. | 594 // Update the location-bar icon. |
| 594 UpdateLocationIcon(); | 595 UpdateLocationIcon(); |
| 595 | 596 |
| 596 // Make sure we're displaying the correct star color for a dark location bar. | 597 // Make sure we're displaying the correct star color for Incognito mode. If |
| 597 if ([[field_ window] inIncognitoModeWithSystemTheme]) { | 598 // the window is in Incognito mode, switching between a theme and no theme |
| 598 star_decoration_->SetStarred(star_decoration_->starred(), true); | 599 // can move the window in and out of dark mode. |
| 599 } | 600 bool inDarkMode = [[field_ window] inIncognitoModeWithSystemTheme]; |
| 601 star_decoration_->SetStarred(star_decoration_->starred(), inDarkMode); |
| 602 |
| 603 // Update the appearance of the text in the Omnibox. |
| 604 omnibox_view_->Update(); |
| 605 } |
| 606 |
| 607 void LocationBarViewMac::OnAddedToWindow() { |
| 608 UpdateColorsToMatchTheme(); |
| 609 } |
| 610 |
| 611 void LocationBarViewMac::OnThemeChanged() { |
| 612 UpdateColorsToMatchTheme(); |
| 600 } | 613 } |
| 601 | 614 |
| 602 void LocationBarViewMac::OnChanged() { | 615 void LocationBarViewMac::OnChanged() { |
| 603 NSImage* image = nil; | 616 NSImage* image = nil; |
| 604 if (ui::MaterialDesignController::IsModeMaterial()) { | 617 if (ui::MaterialDesignController::IsModeMaterial()) { |
| 605 UpdateLocationIcon(); | 618 UpdateLocationIcon(); |
| 606 } else { | 619 } else { |
| 607 const int resource_id = omnibox_view_->GetIcon(); | 620 const int resource_id = omnibox_view_->GetIcon(); |
| 608 image = OmniboxViewMac::ImageForResource(resource_id); | 621 image = OmniboxViewMac::ImageForResource(resource_id); |
| 609 location_icon_decoration_->SetImage(image); | 622 location_icon_decoration_->SetImage(image); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 return zoom_decoration_->UpdateIfNecessary( | 799 return zoom_decoration_->UpdateIfNecessary( |
| 787 ui_zoom::ZoomController::FromWebContents(web_contents), | 800 ui_zoom::ZoomController::FromWebContents(web_contents), |
| 788 default_zoom_changed, | 801 default_zoom_changed, |
| 789 inDarkMode); | 802 inDarkMode); |
| 790 } | 803 } |
| 791 | 804 |
| 792 void LocationBarViewMac::OnDefaultZoomLevelChanged() { | 805 void LocationBarViewMac::OnDefaultZoomLevelChanged() { |
| 793 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) | 806 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) |
| 794 OnDecorationsChanged(); | 807 OnDecorationsChanged(); |
| 795 } | 808 } |
| OLD | NEW |