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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.mm

Issue 1955083003: [Material Design] Update Website Setting Icons in Omnibox on OSX (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: patch for shrike's review Created 4 years, 7 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 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 #import "base/mac/mac_util.h" 9 #import "base/mac/mac_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 WebContents* web_contents = GetWebContents(); 200 WebContents* web_contents = GetWebContents();
201 if (!web_contents) 201 if (!web_contents)
202 return; 202 return;
203 203
204 // |controller| may be nullptr due to lazy initialization. 204 // |controller| may be nullptr due to lazy initialization.
205 autofill::SaveCardBubbleControllerImpl* controller = 205 autofill::SaveCardBubbleControllerImpl* controller =
206 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents); 206 autofill::SaveCardBubbleControllerImpl::FromWebContents(web_contents);
207 bool enabled = controller && controller->IsIconVisible(); 207 bool enabled = controller && controller->IsIconVisible();
208 command_updater()->UpdateCommandEnabled(IDC_SAVE_CREDIT_CARD_FOR_PAGE, 208 command_updater()->UpdateCommandEnabled(IDC_SAVE_CREDIT_CARD_FOR_PAGE,
209 enabled); 209 enabled);
210 bool in_dark_mode = [[field_ window] inIncognitoModeWithSystemTheme]; 210 save_credit_card_decoration_->SetIcon(IsLocationBarDark());
211 save_credit_card_decoration_->SetIcon(in_dark_mode);
212 save_credit_card_decoration_->SetVisible(enabled); 211 save_credit_card_decoration_->SetVisible(enabled);
213 OnDecorationsChanged(); 212 OnDecorationsChanged();
214 } 213 }
215 214
216 void LocationBarViewMac::UpdatePageActions() { 215 void LocationBarViewMac::UpdatePageActions() {
217 RefreshPageActionDecorations(); 216 RefreshPageActionDecorations();
218 Layout(); 217 Layout();
219 218
220 [field_ updateMouseTracking]; 219 [field_ updateMouseTracking];
221 [field_ setNeedsDisplay:YES]; 220 [field_ setNeedsDisplay:YES];
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 } 336 }
338 337
339 bool LocationBarViewMac::IsEditable() { 338 bool LocationBarViewMac::IsEditable() {
340 return [field_ isEditable] ? true : false; 339 return [field_ isEditable] ? true : false;
341 } 340 }
342 341
343 void LocationBarViewMac::SetStarred(bool starred) { 342 void LocationBarViewMac::SetStarred(bool starred) {
344 if (star_decoration_->starred() == starred) 343 if (star_decoration_->starred() == starred)
345 return; 344 return;
346 345
347 star_decoration_->SetStarred(starred, 346 star_decoration_->SetStarred(starred, IsLocationBarDark());
348 [[field_ window] inIncognitoModeWithSystemTheme]);
349 UpdateBookmarkStarVisibility(); 347 UpdateBookmarkStarVisibility();
350 OnDecorationsChanged(); 348 OnDecorationsChanged();
351 } 349 }
352 350
353 void LocationBarViewMac::SetTranslateIconLit(bool on) { 351 void LocationBarViewMac::SetTranslateIconLit(bool on) {
354 bool in_dark_mode = [[field_ window] inIncognitoModeWithSystemTheme]; 352 translate_decoration_->SetLit(on, IsLocationBarDark());
355 translate_decoration_->SetLit(on, in_dark_mode);
356 OnDecorationsChanged(); 353 OnDecorationsChanged();
357 } 354 }
358 355
359 void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) { 356 void LocationBarViewMac::ZoomChangedForActiveTab(bool can_show_bubble) {
360 bool changed = UpdateZoomDecoration(/*default_zoom_changed=*/false); 357 bool changed = UpdateZoomDecoration(/*default_zoom_changed=*/false);
361 if (changed) 358 if (changed)
362 OnDecorationsChanged(); 359 OnDecorationsChanged();
363 360
364 if (can_show_bubble && zoom_decoration_->IsVisible()) 361 if (can_show_bubble && zoom_decoration_->IsVisible())
365 zoom_decoration_->ShowBubble(YES); 362 zoom_decoration_->ShowBubble(YES);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 else 553 else
557 omnibox_view_->Update(); 554 omnibox_view_->Update();
558 OnChanged(); 555 OnChanged();
559 } 556 }
560 557
561 void LocationBarViewMac::UpdateWithoutTabRestore() { 558 void LocationBarViewMac::UpdateWithoutTabRestore() {
562 Update(nullptr); 559 Update(nullptr);
563 } 560 }
564 561
565 void LocationBarViewMac::UpdateLocationIcon() { 562 void LocationBarViewMac::UpdateLocationIcon() {
566 bool in_dark_mode = [[field_ window] inIncognitoModeWithSystemTheme]; 563 bool in_dark_mode = IsLocationBarDark();
567 564
568 SkColor vector_icon_color = gfx::kPlaceholderColor; 565 SkColor vector_icon_color = gfx::kPlaceholderColor;
569 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; 566 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE;
570 int icon_size = kDefaultIconSize; 567 int icon_size = kDefaultIconSize;
571 if (ShouldShowEVBubble()) { 568 if (ShouldShowEVBubble()) {
572 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_IN_CHIP; 569 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_IN_CHIP;
573 vector_icon_color = gfx::kGoogleGreen700; 570 vector_icon_color = gfx::kGoogleGreen700;
574 icon_size = kMaterialSmallIconSize; 571 icon_size = kMaterialSmallIconSize;
575 } else { 572 } else {
576 vector_icon_id = omnibox_view_->GetVectorIcon(in_dark_mode); 573 vector_icon_id = omnibox_view_->GetVectorIcon(in_dark_mode);
(...skipping 19 matching lines...) Expand all
596 ![[field_ window] inIncognitoMode]) { 593 ![[field_ window] inIncognitoMode]) {
597 return; 594 return;
598 } 595 }
599 596
600 // Update the location-bar icon. 597 // Update the location-bar icon.
601 UpdateLocationIcon(); 598 UpdateLocationIcon();
602 599
603 // Make sure we're displaying the correct star color for Incognito mode. If 600 // Make sure we're displaying the correct star color for Incognito mode. If
604 // the window is in Incognito mode, switching between a theme and no theme 601 // the window is in Incognito mode, switching between a theme and no theme
605 // can move the window in and out of dark mode. 602 // can move the window in and out of dark mode.
606 bool in_dark_mode = [[field_ window] inIncognitoModeWithSystemTheme]; 603 star_decoration_->SetStarred(star_decoration_->starred(),
607 star_decoration_->SetStarred(star_decoration_->starred(), in_dark_mode); 604 IsLocationBarDark());
608 605
609 // Update the appearance of the text in the Omnibox. 606 // Update the appearance of the text in the Omnibox.
610 omnibox_view_->Update(); 607 omnibox_view_->Update();
611 } 608 }
612 609
613 void LocationBarViewMac::OnAddedToWindow() { 610 void LocationBarViewMac::OnAddedToWindow() {
614 UpdateColorsToMatchTheme(); 611 UpdateColorsToMatchTheme();
615 } 612 }
616 613
617 void LocationBarViewMac::OnThemeChanged() { 614 void LocationBarViewMac::OnThemeChanged() {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 646
650 WebContents* LocationBarViewMac::GetWebContents() { 647 WebContents* LocationBarViewMac::GetWebContents() {
651 return browser_->tab_strip_model()->GetActiveWebContents(); 648 return browser_->tab_strip_model()->GetActiveWebContents();
652 } 649 }
653 650
654 bool LocationBarViewMac::ShouldShowEVBubble() const { 651 bool LocationBarViewMac::ShouldShowEVBubble() const {
655 return (GetToolbarModel()->GetSecurityLevel(false) == 652 return (GetToolbarModel()->GetSecurityLevel(false) ==
656 security_state::SecurityStateModel::EV_SECURE); 653 security_state::SecurityStateModel::EV_SECURE);
657 } 654 }
658 655
656 bool LocationBarViewMac::IsLocationBarDark() const {
657 return [[field_ window] inIncognitoModeWithSystemTheme];
658 }
659
659 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { 660 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) {
660 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( 661 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile(
661 profile())->GetTemplateURLForKeyword(keyword); 662 profile())->GetTemplateURLForKeyword(keyword);
662 if (template_url && 663 if (template_url &&
663 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { 664 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) {
664 return extensions::OmniboxAPI::Get(profile())-> 665 return extensions::OmniboxAPI::Get(profile())->
665 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); 666 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage();
666 } 667 }
667 668
668 return ui::MaterialDesignController::IsModeMaterial() 669 return ui::MaterialDesignController::IsModeMaterial()
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 return; 789 return;
789 790
790 WebContents* web_contents = GetWebContents(); 791 WebContents* web_contents = GetWebContents();
791 if (!web_contents) 792 if (!web_contents)
792 return; 793 return;
793 translate::LanguageState& language_state = 794 translate::LanguageState& language_state =
794 ChromeTranslateClient::FromWebContents(web_contents)->GetLanguageState(); 795 ChromeTranslateClient::FromWebContents(web_contents)->GetLanguageState();
795 bool enabled = language_state.translate_enabled(); 796 bool enabled = language_state.translate_enabled();
796 command_updater()->UpdateCommandEnabled(IDC_TRANSLATE_PAGE, enabled); 797 command_updater()->UpdateCommandEnabled(IDC_TRANSLATE_PAGE, enabled);
797 translate_decoration_->SetVisible(enabled); 798 translate_decoration_->SetVisible(enabled);
798 bool in_dark_mode = [[field_ window] inIncognitoModeWithSystemTheme];
799 translate_decoration_->SetLit(language_state.IsPageTranslated(), 799 translate_decoration_->SetLit(language_state.IsPageTranslated(),
800 in_dark_mode); 800 IsLocationBarDark());
801 } 801 }
802 802
803 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) { 803 bool LocationBarViewMac::UpdateZoomDecoration(bool default_zoom_changed) {
804 WebContents* web_contents = GetWebContents(); 804 WebContents* web_contents = GetWebContents();
805 if (!web_contents) 805 if (!web_contents)
806 return false; 806 return false;
807 807
808 bool in_dark_mode = [[field_ window] inIncognitoModeWithSystemTheme];
809 return zoom_decoration_->UpdateIfNecessary( 808 return zoom_decoration_->UpdateIfNecessary(
810 ui_zoom::ZoomController::FromWebContents(web_contents), 809 ui_zoom::ZoomController::FromWebContents(web_contents),
811 default_zoom_changed, 810 default_zoom_changed, IsLocationBarDark());
812 in_dark_mode);
813 } 811 }
814 812
815 void LocationBarViewMac::OnDefaultZoomLevelChanged() { 813 void LocationBarViewMac::OnDefaultZoomLevelChanged() {
816 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) 814 if (UpdateZoomDecoration(/*default_zoom_changed=*/true))
817 OnDecorationsChanged(); 815 OnDecorationsChanged();
818 } 816 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698