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 #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 22 matching lines...) Expand all Loading... |
33 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" | 33 #import "chrome/browser/ui/cocoa/first_run_bubble_controller.h" |
34 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 34 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
35 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 35 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
36 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" | 36 #import "chrome/browser/ui/cocoa/location_bar/content_setting_decoration.h" |
37 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" | 37 #import "chrome/browser/ui/cocoa/location_bar/ev_bubble_decoration.h" |
38 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" | 38 #import "chrome/browser/ui/cocoa/location_bar/keyword_hint_decoration.h" |
39 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" | 39 #import "chrome/browser/ui/cocoa/location_bar/location_icon_decoration.h" |
40 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" | 40 #import "chrome/browser/ui/cocoa/location_bar/manage_passwords_decoration.h" |
41 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" | 41 #import "chrome/browser/ui/cocoa/location_bar/page_action_decoration.h" |
42 #import "chrome/browser/ui/cocoa/location_bar/save_credit_card_decoration.h" | 42 #import "chrome/browser/ui/cocoa/location_bar/save_credit_card_decoration.h" |
| 43 #import "chrome/browser/ui/cocoa/location_bar/secure_verbose_bubble_decoration.h
" |
43 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" | 44 #import "chrome/browser/ui/cocoa/location_bar/selected_keyword_decoration.h" |
44 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" | 45 #import "chrome/browser/ui/cocoa/location_bar/star_decoration.h" |
45 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" | 46 #import "chrome/browser/ui/cocoa/location_bar/translate_decoration.h" |
46 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" | 47 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
47 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" | 48 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" |
48 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 49 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
49 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 50 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
50 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" | 51 #include "chrome/browser/ui/content_settings/content_setting_image_model.h" |
51 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" | 52 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" |
52 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 53 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
53 #include "chrome/common/chrome_switches.h" | 54 #include "chrome/common/chrome_switches.h" |
54 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
55 #include "components/bookmarks/common/bookmark_pref_names.h" | 56 #include "components/bookmarks/common/bookmark_pref_names.h" |
56 #import "components/omnibox/browser/omnibox_popup_model.h" | 57 #import "components/omnibox/browser/omnibox_popup_model.h" |
57 #include "components/prefs/pref_service.h" | 58 #include "components/prefs/pref_service.h" |
58 #include "components/search_engines/template_url.h" | 59 #include "components/search_engines/template_url.h" |
59 #include "components/search_engines/template_url_service.h" | 60 #include "components/search_engines/template_url_service.h" |
60 #include "components/security_state/security_state_model.h" | |
61 #include "components/translate/core/browser/language_state.h" | 61 #include "components/translate/core/browser/language_state.h" |
62 #include "components/zoom/zoom_controller.h" | 62 #include "components/zoom/zoom_controller.h" |
63 #include "components/zoom/zoom_event_manager.h" | 63 #include "components/zoom/zoom_event_manager.h" |
64 #include "content/public/browser/web_contents.h" | 64 #include "content/public/browser/web_contents.h" |
65 #include "extensions/browser/extension_system.h" | 65 #include "extensions/browser/extension_system.h" |
66 #include "extensions/common/extension.h" | 66 #include "extensions/common/extension.h" |
67 #include "grit/components_scaled_resources.h" | 67 #include "grit/components_scaled_resources.h" |
68 #include "grit/theme_resources.h" | 68 #include "grit/theme_resources.h" |
69 #include "skia/ext/skia_utils_mac.h" | 69 #include "skia/ext/skia_utils_mac.h" |
70 #import "ui/base/cocoa/cocoa_base_utils.h" | 70 #import "ui/base/cocoa/cocoa_base_utils.h" |
71 #include "ui/base/l10n/l10n_util_mac.h" | 71 #include "ui/base/l10n/l10n_util_mac.h" |
72 #include "ui/base/material_design/material_design_controller.h" | 72 #include "ui/base/material_design/material_design_controller.h" |
73 #include "ui/gfx/color_palette.h" | 73 #include "ui/gfx/color_palette.h" |
74 #include "ui/gfx/color_utils.h" | 74 #include "ui/gfx/color_utils.h" |
| 75 #include "ui/gfx/geometry/cubic_bezier.h" |
75 #include "ui/gfx/image/image.h" | 76 #include "ui/gfx/image/image.h" |
76 #include "ui/gfx/image/image_skia_util_mac.h" | 77 #include "ui/gfx/image/image_skia_util_mac.h" |
77 #include "ui/gfx/paint_vector_icon.h" | 78 #include "ui/gfx/paint_vector_icon.h" |
78 #include "ui/gfx/vector_icons_public.h" | 79 #include "ui/gfx/vector_icons_public.h" |
79 | 80 |
80 using content::WebContents; | 81 using content::WebContents; |
81 | 82 |
82 namespace { | 83 namespace { |
83 | 84 |
84 // Vertical space between the bottom edge of the location_bar and the first run | 85 // Vertical space between the bottom edge of the location_bar and the first run |
(...skipping 14 matching lines...) Expand all Loading... |
99 LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, | 100 LocationBarViewMac::LocationBarViewMac(AutocompleteTextField* field, |
100 CommandUpdater* command_updater, | 101 CommandUpdater* command_updater, |
101 Profile* profile, | 102 Profile* profile, |
102 Browser* browser) | 103 Browser* browser) |
103 : LocationBar(profile), | 104 : LocationBar(profile), |
104 ChromeOmniboxEditController(command_updater), | 105 ChromeOmniboxEditController(command_updater), |
105 omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)), | 106 omnibox_view_(new OmniboxViewMac(this, profile, command_updater, field)), |
106 field_(field), | 107 field_(field), |
107 location_icon_decoration_(new LocationIconDecoration(this)), | 108 location_icon_decoration_(new LocationIconDecoration(this)), |
108 selected_keyword_decoration_(new SelectedKeywordDecoration()), | 109 selected_keyword_decoration_(new SelectedKeywordDecoration()), |
| 110 secure_verbose_bubble_decoration_( |
| 111 new SecureVerboseBubbleDecoration(location_icon_decoration_.get(), |
| 112 this)), |
109 ev_bubble_decoration_( | 113 ev_bubble_decoration_( |
110 new EVBubbleDecoration(location_icon_decoration_.get())), | 114 new EVBubbleDecoration(location_icon_decoration_.get())), |
111 save_credit_card_decoration_( | 115 save_credit_card_decoration_( |
112 new SaveCreditCardDecoration(command_updater)), | 116 new SaveCreditCardDecoration(command_updater)), |
113 star_decoration_(new StarDecoration(command_updater)), | 117 star_decoration_(new StarDecoration(command_updater)), |
114 translate_decoration_(new TranslateDecoration(command_updater)), | 118 translate_decoration_(new TranslateDecoration(command_updater)), |
115 zoom_decoration_(new ZoomDecoration(this)), | 119 zoom_decoration_(new ZoomDecoration(this)), |
116 keyword_hint_decoration_(new KeywordHintDecoration()), | 120 keyword_hint_decoration_(new KeywordHintDecoration()), |
117 manage_passwords_decoration_( | 121 manage_passwords_decoration_( |
118 new ManagePasswordsDecoration(command_updater, this)), | 122 new ManagePasswordsDecoration(command_updater, this)), |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 | 389 |
386 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const { | 390 NSPoint LocationBarViewMac::GetTranslateBubblePoint() const { |
387 return [field_ bubblePointForDecoration:translate_decoration_.get()]; | 391 return [field_ bubblePointForDecoration:translate_decoration_.get()]; |
388 } | 392 } |
389 | 393 |
390 NSPoint LocationBarViewMac::GetManagePasswordsBubblePoint() const { | 394 NSPoint LocationBarViewMac::GetManagePasswordsBubblePoint() const { |
391 return [field_ bubblePointForDecoration:manage_passwords_decoration_.get()]; | 395 return [field_ bubblePointForDecoration:manage_passwords_decoration_.get()]; |
392 } | 396 } |
393 | 397 |
394 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { | 398 NSPoint LocationBarViewMac::GetPageInfoBubblePoint() const { |
395 if (ev_bubble_decoration_->IsVisible()) { | 399 if (secure_verbose_bubble_decoration_->IsVisible()) { |
| 400 return [field_ |
| 401 bubblePointForDecoration:secure_verbose_bubble_decoration_.get()]; |
| 402 } else if (ev_bubble_decoration_->IsVisible()) { |
396 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; | 403 return [field_ bubblePointForDecoration:ev_bubble_decoration_.get()]; |
397 } else { | 404 } else { |
398 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; | 405 return [field_ bubblePointForDecoration:location_icon_decoration_.get()]; |
399 } | 406 } |
400 } | 407 } |
401 | 408 |
402 void LocationBarViewMac::OnDecorationsChanged() { | 409 void LocationBarViewMac::OnDecorationsChanged() { |
403 // TODO(shess): The field-editor frame and cursor rects should not | 410 // TODO(shess): The field-editor frame and cursor rects should not |
404 // change, here. | 411 // change, here. |
405 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 412 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
406 for (const auto& decoration : decorations) | 413 for (const auto& decoration : decorations) |
407 UpdateAccessibilityViewPosition(decoration); | 414 UpdateAccessibilityViewPosition(decoration); |
408 [field_ updateMouseTracking]; | 415 [field_ updateMouseTracking]; |
409 [field_ resetFieldEditorFrameIfNeeded]; | 416 [field_ resetFieldEditorFrameIfNeeded]; |
410 [field_ setNeedsDisplay:YES]; | 417 [field_ setNeedsDisplay:YES]; |
411 } | 418 } |
412 | 419 |
413 // TODO(shess): This function should over time grow to closely match | 420 // TODO(shess): This function should over time grow to closely match |
414 // the views Layout() function. | 421 // the views Layout() function. |
415 void LocationBarViewMac::Layout() { | 422 void LocationBarViewMac::Layout() { |
416 AutocompleteTextFieldCell* cell = [field_ cell]; | 423 AutocompleteTextFieldCell* cell = [field_ cell]; |
417 | 424 |
418 // Reset the left-hand decorations. | 425 // Reset the left-hand decorations. |
419 // TODO(shess): Shortly, this code will live somewhere else, like in | 426 // TODO(shess): Shortly, this code will live somewhere else, like in |
420 // the constructor. I am still wrestling with how best to deal with | 427 // the constructor. I am still wrestling with how best to deal with |
421 // right-hand decorations, which are not a static set. | 428 // right-hand decorations, which are not a static set. |
422 [cell clearDecorations]; | 429 [cell clearDecorations]; |
423 [cell addLeftDecoration:location_icon_decoration_.get()]; | 430 [cell addLeftDecoration:location_icon_decoration_.get()]; |
424 [cell addLeftDecoration:selected_keyword_decoration_.get()]; | 431 [cell addLeftDecoration:selected_keyword_decoration_.get()]; |
| 432 [cell addLeftDecoration:secure_verbose_bubble_decoration_.get()]; |
425 [cell addLeftDecoration:ev_bubble_decoration_.get()]; | 433 [cell addLeftDecoration:ev_bubble_decoration_.get()]; |
426 [cell addRightDecoration:star_decoration_.get()]; | 434 [cell addRightDecoration:star_decoration_.get()]; |
427 [cell addRightDecoration:translate_decoration_.get()]; | 435 [cell addRightDecoration:translate_decoration_.get()]; |
428 [cell addRightDecoration:zoom_decoration_.get()]; | 436 [cell addRightDecoration:zoom_decoration_.get()]; |
429 [cell addRightDecoration:save_credit_card_decoration_.get()]; | 437 [cell addRightDecoration:save_credit_card_decoration_.get()]; |
430 [cell addRightDecoration:manage_passwords_decoration_.get()]; | 438 [cell addRightDecoration:manage_passwords_decoration_.get()]; |
431 | 439 |
432 // Note that display order is right to left. | 440 // Note that display order is right to left. |
433 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 441 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { |
434 [cell addRightDecoration:page_action_decorations_[i]]; | 442 [cell addRightDecoration:page_action_decorations_[i]]; |
435 } | 443 } |
436 | 444 |
437 for (ScopedVector<ContentSettingDecoration>::iterator i = | 445 for (ScopedVector<ContentSettingDecoration>::iterator i = |
438 content_setting_decorations_.begin(); | 446 content_setting_decorations_.begin(); |
439 i != content_setting_decorations_.end(); ++i) { | 447 i != content_setting_decorations_.end(); ++i) { |
440 [cell addRightDecoration:*i]; | 448 [cell addRightDecoration:*i]; |
441 } | 449 } |
442 | 450 |
443 [cell addRightDecoration:keyword_hint_decoration_.get()]; | 451 [cell addRightDecoration:keyword_hint_decoration_.get()]; |
444 | 452 |
445 // By default only the location icon is visible. | 453 // By default only the location icon is visible. |
446 location_icon_decoration_->SetVisible(true); | 454 location_icon_decoration_->SetVisible(true); |
447 selected_keyword_decoration_->SetVisible(false); | 455 selected_keyword_decoration_->SetVisible(false); |
| 456 secure_verbose_bubble_decoration_->SetVisible(false); |
448 ev_bubble_decoration_->SetVisible(false); | 457 ev_bubble_decoration_->SetVisible(false); |
449 keyword_hint_decoration_->SetVisible(false); | 458 keyword_hint_decoration_->SetVisible(false); |
450 | 459 |
451 // Get the keyword to use for keyword-search and hinting. | 460 // Get the keyword to use for keyword-search and hinting. |
452 const base::string16 keyword = omnibox_view_->model()->keyword(); | 461 const base::string16 keyword = omnibox_view_->model()->keyword(); |
453 base::string16 short_name; | 462 base::string16 short_name; |
454 bool is_extension_keyword = false; | 463 bool is_extension_keyword = false; |
455 if (!keyword.empty()) { | 464 if (!keyword.empty()) { |
456 short_name = TemplateURLServiceFactory::GetForProfile(profile())-> | 465 short_name = TemplateURLServiceFactory::GetForProfile(profile())-> |
457 GetKeywordShortName(keyword, &is_extension_keyword); | 466 GetKeywordShortName(keyword, &is_extension_keyword); |
458 } | 467 } |
459 | 468 |
460 const bool is_keyword_hint = omnibox_view_->model()->is_keyword_hint(); | 469 const bool is_keyword_hint = omnibox_view_->model()->is_keyword_hint(); |
461 if (!keyword.empty() && !is_keyword_hint) { | 470 if (!keyword.empty() && !is_keyword_hint) { |
462 // Switch from location icon to keyword mode. | 471 // Switch from location icon to keyword mode. |
463 location_icon_decoration_->SetVisible(false); | 472 location_icon_decoration_->SetVisible(false); |
464 selected_keyword_decoration_->SetVisible(true); | 473 selected_keyword_decoration_->SetVisible(true); |
465 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword); | 474 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword); |
466 // Note: the first time through this code path the | 475 // Note: the first time through this code path the |
467 // |selected_keyword_decoration_| has no image set because under Material | 476 // |selected_keyword_decoration_| has no image set because under Material |
468 // Design we need to set its color, which we cannot do until we know the | 477 // Design we need to set its color, which we cannot do until we know the |
469 // theme (by being installed in a browser window). | 478 // theme (by being installed in a browser window). |
470 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword)); | 479 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword)); |
| 480 } else if (!keyword.empty() && is_keyword_hint) { |
| 481 keyword_hint_decoration_->SetKeyword(short_name, is_extension_keyword); |
| 482 keyword_hint_decoration_->SetVisible(true); |
471 } else if (ShouldShowEVBubble()) { | 483 } else if (ShouldShowEVBubble()) { |
472 // Switch from location icon to show the EV bubble instead. | 484 // Switch from location icon to show the EV bubble instead. |
473 location_icon_decoration_->SetVisible(false); | 485 location_icon_decoration_->SetVisible(false); |
474 ev_bubble_decoration_->SetVisible(true); | 486 ev_bubble_decoration_->SetVisible(true); |
475 | 487 |
476 base::string16 label(GetToolbarModel()->GetEVCertName()); | 488 base::string16 label(GetToolbarModel()->GetEVCertName()); |
477 ev_bubble_decoration_->SetFullLabel(base::SysUTF16ToNSString(label)); | 489 ev_bubble_decoration_->SetFullLabel(base::SysUTF16ToNSString(label)); |
478 } else if (!keyword.empty() && is_keyword_hint) { | 490 } else if (ShouldShowSecureVerbose()) { |
479 keyword_hint_decoration_->SetKeyword(short_name, | 491 location_icon_decoration_->SetVisible(false); |
480 is_extension_keyword); | 492 secure_verbose_bubble_decoration_->SetVisible(true); |
481 keyword_hint_decoration_->SetVisible(true); | 493 |
| 494 base::string16 label(GetToolbarModel()->GetSecureVerboseText()); |
| 495 secure_verbose_bubble_decoration_->SetFullLabel( |
| 496 base::SysUTF16ToNSString(label)); |
482 } | 497 } |
483 | 498 |
484 // These need to change anytime the layout changes. | 499 // These need to change anytime the layout changes. |
485 // TODO(shess): Anytime the field editor might have changed, the | 500 // TODO(shess): Anytime the field editor might have changed, the |
486 // cursor rects almost certainly should have changed. The tooltips | 501 // cursor rects almost certainly should have changed. The tooltips |
487 // might change even when the rects don't change. | 502 // might change even when the rects don't change. |
488 OnDecorationsChanged(); | 503 OnDecorationsChanged(); |
489 } | 504 } |
490 | 505 |
491 void LocationBarViewMac::RedrawDecoration(LocationBarDecoration* decoration) { | 506 void LocationBarViewMac::RedrawDecoration(LocationBarDecoration* decoration) { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 omnibox_view_->OnTabChanged(contents); | 574 omnibox_view_->OnTabChanged(contents); |
560 else | 575 else |
561 omnibox_view_->Update(); | 576 omnibox_view_->Update(); |
562 OnChanged(); | 577 OnChanged(); |
563 } | 578 } |
564 | 579 |
565 void LocationBarViewMac::UpdateWithoutTabRestore() { | 580 void LocationBarViewMac::UpdateWithoutTabRestore() { |
566 Update(nullptr); | 581 Update(nullptr); |
567 } | 582 } |
568 | 583 |
| 584 // TODO(spqchan): Animate the secure verbose chip. crbug.com/622529 |
569 void LocationBarViewMac::UpdateLocationIcon() { | 585 void LocationBarViewMac::UpdateLocationIcon() { |
570 bool in_dark_mode = IsLocationBarDark(); | 586 SkColor vector_icon_color = GetLocationBarIconColor(); |
571 | 587 gfx::VectorIconId vector_icon_id = |
572 SkColor vector_icon_color = gfx::kPlaceholderColor; | 588 ShouldShowEVBubble() ? gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID |
573 gfx::VectorIconId vector_icon_id = gfx::VectorIconId::VECTOR_ICON_NONE; | 589 : omnibox_view_->GetVectorIcon(); |
574 if (ShouldShowEVBubble()) { | |
575 vector_icon_id = gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID; | |
576 vector_icon_color = gfx::kGoogleGreen700; | |
577 } else { | |
578 vector_icon_id = omnibox_view_->GetVectorIcon(); | |
579 security_state::SecurityStateModel::SecurityLevel security_level = | |
580 GetToolbarModel()->GetSecurityLevel(false); | |
581 if (security_level == security_state::SecurityStateModel::NONE) { | |
582 vector_icon_color = gfx::kChromeIconGrey; | |
583 } else { | |
584 NSColor* sRGBColor = | |
585 OmniboxViewMac::GetSecureTextColor(security_level, in_dark_mode); | |
586 NSColor* deviceColor = | |
587 [sRGBColor colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; | |
588 vector_icon_color = skia::NSDeviceColorToSkColor(deviceColor); | |
589 } | |
590 } | |
591 | |
592 // If the theme is dark, then the color should always be | |
593 // kMaterialDarkVectorIconColor. | |
594 if (in_dark_mode) | |
595 vector_icon_color = kMaterialDarkVectorIconColor; | |
596 | 590 |
597 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE); | 591 DCHECK(vector_icon_id != gfx::VectorIconId::VECTOR_ICON_NONE); |
598 NSImage* image = NSImageFromImageSkiaWithColorSpace( | 592 NSImage* image = NSImageFromImageSkiaWithColorSpace( |
599 gfx::CreateVectorIcon(vector_icon_id, kDefaultIconSize, | 593 gfx::CreateVectorIcon(vector_icon_id, kDefaultIconSize, |
600 vector_icon_color), | 594 vector_icon_color), |
601 base::mac::GetSRGBColorSpace()); | 595 base::mac::GetSRGBColorSpace()); |
602 location_icon_decoration_->SetImage(image); | 596 location_icon_decoration_->SetImage(image); |
603 ev_bubble_decoration_->SetImage(image); | 597 ev_bubble_decoration_->SetImage(image); |
| 598 secure_verbose_bubble_decoration_->SetImage(image); |
| 599 secure_verbose_bubble_decoration_->SetLabelColor(vector_icon_color); |
| 600 |
604 Layout(); | 601 Layout(); |
| 602 |
| 603 if (ShouldShowSecureVerbose()) |
| 604 secure_verbose_bubble_decoration_->StartAnimation(); |
605 } | 605 } |
606 | 606 |
607 void LocationBarViewMac::UpdateColorsToMatchTheme() { | 607 void LocationBarViewMac::UpdateColorsToMatchTheme() { |
608 if (!ui::MaterialDesignController::IsModeMaterial() || | 608 if (!ui::MaterialDesignController::IsModeMaterial() || |
609 ![[field_ window] inIncognitoMode]) { | 609 ![[field_ window] inIncognitoMode]) { |
610 return; | 610 return; |
611 } | 611 } |
612 | 612 |
613 // Update the location-bar icon. | 613 // Update the location-bar icon. |
614 UpdateLocationIcon(); | 614 UpdateLocationIcon(); |
(...skipping 14 matching lines...) Expand all Loading... |
629 | 629 |
630 void LocationBarViewMac::OnThemeChanged() { | 630 void LocationBarViewMac::OnThemeChanged() { |
631 UpdateColorsToMatchTheme(); | 631 UpdateColorsToMatchTheme(); |
632 } | 632 } |
633 | 633 |
634 void LocationBarViewMac::OnChanged() { | 634 void LocationBarViewMac::OnChanged() { |
635 if (!ui::MaterialDesignController::IsModeMaterial()) { | 635 if (!ui::MaterialDesignController::IsModeMaterial()) { |
636 const int resource_id = omnibox_view_->GetIcon(); | 636 const int resource_id = omnibox_view_->GetIcon(); |
637 NSImage* image = OmniboxViewMac::ImageForResource(resource_id); | 637 NSImage* image = OmniboxViewMac::ImageForResource(resource_id); |
638 location_icon_decoration_->SetImage(image); | 638 location_icon_decoration_->SetImage(image); |
639 ev_bubble_decoration_->SetImage(image); | 639 secure_verbose_bubble_decoration_->SetImage(image); |
640 Layout(); | 640 Layout(); |
641 return; | 641 return; |
642 } | 642 } |
643 UpdateLocationIcon(); | 643 UpdateLocationIcon(); |
644 } | 644 } |
645 | 645 |
646 void LocationBarViewMac::ShowURL() { | 646 void LocationBarViewMac::ShowURL() { |
647 omnibox_view_->ShowURL(); | 647 omnibox_view_->ShowURL(); |
648 } | 648 } |
649 | 649 |
650 ToolbarModel* LocationBarViewMac::GetToolbarModel() { | 650 ToolbarModel* LocationBarViewMac::GetToolbarModel() { |
651 return browser_->toolbar_model(); | 651 return browser_->toolbar_model(); |
652 } | 652 } |
653 | 653 |
654 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const { | 654 const ToolbarModel* LocationBarViewMac::GetToolbarModel() const { |
655 return browser_->toolbar_model(); | 655 return browser_->toolbar_model(); |
656 } | 656 } |
657 | 657 |
658 WebContents* LocationBarViewMac::GetWebContents() { | 658 WebContents* LocationBarViewMac::GetWebContents() { |
659 return browser_->tab_strip_model()->GetActiveWebContents(); | 659 return browser_->tab_strip_model()->GetActiveWebContents(); |
660 } | 660 } |
661 | 661 |
662 bool LocationBarViewMac::ShouldShowEVBubble() const { | 662 bool LocationBarViewMac::ShouldShowEVBubble() const { |
663 return (GetToolbarModel()->GetSecurityLevel(false) == | 663 return (GetToolbarModel()->GetSecurityLevel(false) == |
664 security_state::SecurityStateModel::EV_SECURE); | 664 security_state::SecurityStateModel::EV_SECURE); |
665 } | 665 } |
666 | 666 |
| 667 bool LocationBarViewMac::ShouldShowSecureVerbose() const { |
| 668 return ui::MaterialDesignController::IsModeMaterial() && |
| 669 !omnibox_view_->IsEditingOrEmpty() && |
| 670 !omnibox_view_->model()->is_keyword_hint() && !ShouldShowEVBubble() && |
| 671 GetToolbarModel()->GetSecurityLevel(false) != |
| 672 security_state::SecurityStateModel::NONE; |
| 673 } |
| 674 |
667 bool LocationBarViewMac::IsLocationBarDark() const { | 675 bool LocationBarViewMac::IsLocationBarDark() const { |
668 return [[field_ window] inIncognitoModeWithSystemTheme]; | 676 return [[field_ window] inIncognitoModeWithSystemTheme]; |
669 } | 677 } |
670 | 678 |
671 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { | 679 NSImage* LocationBarViewMac::GetKeywordImage(const base::string16& keyword) { |
672 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( | 680 const TemplateURL* template_url = TemplateURLServiceFactory::GetForProfile( |
673 profile())->GetTemplateURLForKeyword(keyword); | 681 profile())->GetTemplateURLForKeyword(keyword); |
674 if (template_url && | 682 if (template_url && |
675 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { | 683 (template_url->GetType() == TemplateURL::OMNIBOX_API_EXTENSION)) { |
676 return extensions::OmniboxAPI::Get(profile())-> | 684 return extensions::OmniboxAPI::Get(profile())-> |
677 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); | 685 GetOmniboxIcon(template_url->GetExtensionId()).AsNSImage(); |
678 } | 686 } |
679 | 687 |
680 if (ui::MaterialDesignController::IsModeMaterial()) { | 688 if (ui::MaterialDesignController::IsModeMaterial()) { |
681 SkColor icon_color = IsLocationBarDark() ? kMaterialDarkVectorIconColor | 689 SkColor icon_color = IsLocationBarDark() ? kMaterialDarkVectorIconColor |
682 : gfx::kGoogleBlue700; | 690 : gfx::kGoogleBlue700; |
683 return NSImageFromImageSkiaWithColorSpace( | 691 return NSImageFromImageSkiaWithColorSpace( |
684 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH, | 692 gfx::CreateVectorIcon(gfx::VectorIconId::OMNIBOX_SEARCH, |
685 kDefaultIconSize, icon_color), | 693 kDefaultIconSize, icon_color), |
686 base::mac::GetSRGBColorSpace()); | 694 base::mac::GetSRGBColorSpace()); |
687 } | 695 } |
688 | 696 |
689 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); | 697 return OmniboxViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); |
690 } | 698 } |
691 | 699 |
| 700 SkColor LocationBarViewMac::GetLocationBarIconColor() const { |
| 701 bool in_dark_mode = IsLocationBarDark(); |
| 702 if (in_dark_mode) |
| 703 return kMaterialDarkVectorIconColor; |
| 704 |
| 705 if (ShouldShowEVBubble()) |
| 706 return gfx::kGoogleGreen700; |
| 707 |
| 708 security_state::SecurityStateModel::SecurityLevel security_level = |
| 709 GetToolbarModel()->GetSecurityLevel(false); |
| 710 |
| 711 if (security_level == security_state::SecurityStateModel::NONE) |
| 712 return gfx::kChromeIconGrey; |
| 713 |
| 714 NSColor* sRGBColor = |
| 715 OmniboxViewMac::GetSecureTextColor(security_level, in_dark_mode); |
| 716 NSColor* deviceColor = |
| 717 [sRGBColor colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; |
| 718 return skia::NSDeviceColorToSkColor(deviceColor); |
| 719 } |
| 720 |
692 void LocationBarViewMac::PostNotification(NSString* notification) { | 721 void LocationBarViewMac::PostNotification(NSString* notification) { |
693 [[NSNotificationCenter defaultCenter] postNotificationName:notification | 722 [[NSNotificationCenter defaultCenter] postNotificationName:notification |
694 object:[NSValue valueWithPointer:this]]; | 723 object:[NSValue valueWithPointer:this]]; |
695 } | 724 } |
696 | 725 |
697 PageActionDecoration* LocationBarViewMac::GetPageActionDecoration( | 726 PageActionDecoration* LocationBarViewMac::GetPageActionDecoration( |
698 ExtensionAction* page_action) { | 727 ExtensionAction* page_action) { |
699 DCHECK(page_action); | 728 DCHECK(page_action); |
700 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { | 729 for (size_t i = 0; i < page_action_decorations_.size(); ++i) { |
701 if (page_action_decorations_[i]->GetPageAction() == page_action) | 730 if (page_action_decorations_[i]->GetPageAction() == page_action) |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 [decoration->GetAccessibilityView() setFrame:r]; | 861 [decoration->GetAccessibilityView() setFrame:r]; |
833 [decoration->GetAccessibilityView() setNeedsDisplayInRect:r]; | 862 [decoration->GetAccessibilityView() setNeedsDisplayInRect:r]; |
834 } | 863 } |
835 | 864 |
836 std::vector<LocationBarDecoration*> LocationBarViewMac::GetDecorations() { | 865 std::vector<LocationBarDecoration*> LocationBarViewMac::GetDecorations() { |
837 std::vector<LocationBarDecoration*> decorations; | 866 std::vector<LocationBarDecoration*> decorations; |
838 // TODO(ellyjones): content setting decorations aren't included right now, nor | 867 // TODO(ellyjones): content setting decorations aren't included right now, nor |
839 // are page actions and the keyword hint. | 868 // are page actions and the keyword hint. |
840 decorations.push_back(location_icon_decoration_.get()); | 869 decorations.push_back(location_icon_decoration_.get()); |
841 decorations.push_back(selected_keyword_decoration_.get()); | 870 decorations.push_back(selected_keyword_decoration_.get()); |
| 871 decorations.push_back(secure_verbose_bubble_decoration_.get()); |
842 decorations.push_back(ev_bubble_decoration_.get()); | 872 decorations.push_back(ev_bubble_decoration_.get()); |
843 decorations.push_back(save_credit_card_decoration_.get()); | 873 decorations.push_back(save_credit_card_decoration_.get()); |
844 decorations.push_back(star_decoration_.get()); | 874 decorations.push_back(star_decoration_.get()); |
845 decorations.push_back(translate_decoration_.get()); | 875 decorations.push_back(translate_decoration_.get()); |
846 decorations.push_back(zoom_decoration_.get()); | 876 decorations.push_back(zoom_decoration_.get()); |
847 decorations.push_back(manage_passwords_decoration_.get()); | 877 decorations.push_back(manage_passwords_decoration_.get()); |
848 return decorations; | 878 return decorations; |
849 } | 879 } |
850 | 880 |
851 void LocationBarViewMac::OnDefaultZoomLevelChanged() { | 881 void LocationBarViewMac::OnDefaultZoomLevelChanged() { |
852 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) | 882 if (UpdateZoomDecoration(/*default_zoom_changed=*/true)) |
853 OnDecorationsChanged(); | 883 OnDecorationsChanged(); |
854 } | 884 } |
855 | 885 |
856 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { | 886 std::vector<NSView*> LocationBarViewMac::GetDecorationAccessibilityViews() { |
857 std::vector<LocationBarDecoration*> decorations = GetDecorations(); | 887 std::vector<LocationBarDecoration*> decorations = GetDecorations(); |
858 std::vector<NSView*> views; | 888 std::vector<NSView*> views; |
859 for (const auto& decoration : decorations) | 889 for (const auto& decoration : decorations) |
860 views.push_back(decoration->GetAccessibilityView()); | 890 views.push_back(decoration->GetAccessibilityView()); |
861 return views; | 891 return views; |
862 } | 892 } |
OLD | NEW |