| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/location_bar/location_bar_view_mac.h" | 5 #import "chrome/browser/cocoa/location_bar/location_bar_view_mac.h" |
| 6 | 6 |
| 7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/nsimage_cache_mac.h" | 10 #include "base/nsimage_cache_mac.h" |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 if (!tab_button_image_) { | 386 if (!tab_button_image_) { |
| 387 SkBitmap* skiaBitmap = ResourceBundle::GetSharedInstance(). | 387 SkBitmap* skiaBitmap = ResourceBundle::GetSharedInstance(). |
| 388 GetBitmapNamed(IDR_LOCATION_BAR_KEYWORD_HINT_TAB); | 388 GetBitmapNamed(IDR_LOCATION_BAR_KEYWORD_HINT_TAB); |
| 389 if (skiaBitmap) { | 389 if (skiaBitmap) { |
| 390 tab_button_image_.reset([gfx::SkBitmapToNSImage(*skiaBitmap) retain]); | 390 tab_button_image_.reset([gfx::SkBitmapToNSImage(*skiaBitmap) retain]); |
| 391 } | 391 } |
| 392 } | 392 } |
| 393 return tab_button_image_; | 393 return tab_button_image_; |
| 394 } | 394 } |
| 395 | 395 |
| 396 NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) { |
| 397 const TemplateURL* template_url = |
| 398 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); |
| 399 if (template_url && template_url->IsExtensionKeyword()) { |
| 400 const SkBitmap& bitmap = profile_->GetExtensionsService()-> |
| 401 GetOmniboxIcon(template_url->GetExtensionId()); |
| 402 return gfx::SkBitmapToNSImage(bitmap); |
| 403 } |
| 404 |
| 405 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); |
| 406 } |
| 407 |
| 396 void LocationBarViewMac::Observe(NotificationType type, | 408 void LocationBarViewMac::Observe(NotificationType type, |
| 397 const NotificationSource& source, | 409 const NotificationSource& source, |
| 398 const NotificationDetails& details) { | 410 const NotificationDetails& details) { |
| 399 switch (type.value) { | 411 switch (type.value) { |
| 400 case NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: { | 412 case NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED: { |
| 401 TabContents* contents = GetTabContents(); | 413 TabContents* contents = GetTabContents(); |
| 402 if (Details<TabContents>(contents) != details) | 414 if (Details<TabContents>(contents) != details) |
| 403 return; | 415 return; |
| 404 | 416 |
| 405 [field_ updateCursorAndToolTipRects]; | 417 [field_ updateCursorAndToolTipRects]; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 short_name = profile_->GetTemplateURLModel()-> | 885 short_name = profile_->GetTemplateURLModel()-> |
| 874 GetKeywordShortName(keyword, &is_extension_keyword); | 886 GetKeywordShortName(keyword, &is_extension_keyword); |
| 875 } | 887 } |
| 876 | 888 |
| 877 const bool is_keyword_hint = edit_view_->model()->is_keyword_hint(); | 889 const bool is_keyword_hint = edit_view_->model()->is_keyword_hint(); |
| 878 | 890 |
| 879 if (!keyword.empty() && !is_keyword_hint) { | 891 if (!keyword.empty() && !is_keyword_hint) { |
| 880 // Switch from location icon to keyword mode. | 892 // Switch from location icon to keyword mode. |
| 881 location_icon_decoration_->SetVisible(false); | 893 location_icon_decoration_->SetVisible(false); |
| 882 selected_keyword_decoration_->SetVisible(true); | 894 selected_keyword_decoration_->SetVisible(true); |
| 883 | |
| 884 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword); | 895 selected_keyword_decoration_->SetKeyword(short_name, is_extension_keyword); |
| 896 selected_keyword_decoration_->SetImage(GetKeywordImage(keyword)); |
| 885 | 897 |
| 886 // TODO(shess): This goes away once the hints are decorations. | 898 // TODO(shess): This goes away once the hints are decorations. |
| 887 [cell clearHint]; | 899 [cell clearHint]; |
| 888 } else if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) { | 900 } else if (toolbar_model_->GetSecurityLevel() == ToolbarModel::EV_SECURE) { |
| 889 // Switch from location icon to show the EV bubble instead. | 901 // Switch from location icon to show the EV bubble instead. |
| 890 location_icon_decoration_->SetVisible(false); | 902 location_icon_decoration_->SetVisible(false); |
| 891 ev_bubble_decoration_->SetVisible(true); | 903 ev_bubble_decoration_->SetVisible(true); |
| 892 | 904 |
| 893 std::wstring label(toolbar_model_->GetEVCertName()); | 905 std::wstring label(toolbar_model_->GetEVCertName()); |
| 894 ev_bubble_decoration_->SetLabel(base::SysWideToNSString(label)); | 906 ev_bubble_decoration_->SetLabel(base::SysWideToNSString(label)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 928 | 940 |
| 929 // These need to change anytime the layout changes. | 941 // These need to change anytime the layout changes. |
| 930 // TODO(shess): Anytime the field editor might have changed, the | 942 // TODO(shess): Anytime the field editor might have changed, the |
| 931 // cursor rects almost certainly should have changed. The tooltips | 943 // cursor rects almost certainly should have changed. The tooltips |
| 932 // might change even when the rects don't change. | 944 // might change even when the rects don't change. |
| 933 [field_ resetFieldEditorFrameIfNeeded]; | 945 [field_ resetFieldEditorFrameIfNeeded]; |
| 934 [field_ updateCursorAndToolTipRects]; | 946 [field_ updateCursorAndToolTipRects]; |
| 935 | 947 |
| 936 [field_ setNeedsDisplay:YES]; | 948 [field_ setNeedsDisplay:YES]; |
| 937 } | 949 } |
| OLD | NEW |