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/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 "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/nsimage_cache_mac.h" | 9 #include "base/nsimage_cache_mac.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "base/sys_string_conversions.h" | 12 #include "base/sys_string_conversions.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 14 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/browser/alternate_nav_url_fetcher.h" | 15 #include "chrome/browser/alternate_nav_url_fetcher.h" |
16 #import "chrome/browser/app_controller_mac.h" | 16 #import "chrome/browser/app_controller_mac.h" |
17 #import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" | 17 #import "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
18 #import "chrome/browser/autocomplete/autocomplete_popup_model.h" | 18 #import "chrome/browser/autocomplete/autocomplete_popup_model.h" |
19 #include "chrome/browser/browser_list.h" | 19 #include "chrome/browser/browser_list.h" |
20 #include "chrome/browser/command_updater.h" | 20 #include "chrome/browser/command_updater.h" |
21 #include "chrome/browser/content_setting_image_model.h" | 21 #include "chrome/browser/content_setting_image_model.h" |
22 #include "chrome/browser/content_setting_bubble_model.h" | 22 #include "chrome/browser/content_setting_bubble_model.h" |
23 #include "chrome/browser/defaults.h" | 23 #include "chrome/browser/defaults.h" |
24 #include "chrome/browser/extensions/extension_browser_event_router.h" | 24 #include "chrome/browser/extensions/extension_browser_event_router.h" |
25 #include "chrome/browser/extensions/extensions_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
26 #include "chrome/browser/extensions/extension_tabs_module.h" | 26 #include "chrome/browser/extensions/extension_tabs_module.h" |
27 #include "chrome/browser/instant/instant_controller.h" | 27 #include "chrome/browser/instant/instant_controller.h" |
28 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/search_engines/template_url.h" | 29 #include "chrome/browser/search_engines/template_url.h" |
30 #include "chrome/browser/search_engines/template_url_model.h" | 30 #include "chrome/browser/search_engines/template_url_model.h" |
31 #include "chrome/browser/tab_contents/navigation_entry.h" | 31 #include "chrome/browser/tab_contents/navigation_entry.h" |
32 #include "chrome/browser/tab_contents/tab_contents.h" | 32 #include "chrome/browser/tab_contents/tab_contents.h" |
33 #import "chrome/browser/ui/cocoa/content_setting_bubble_cocoa.h" | 33 #import "chrome/browser/ui/cocoa/content_setting_bubble_cocoa.h" |
34 #include "chrome/browser/ui/cocoa/event_utils.h" | 34 #include "chrome/browser/ui/cocoa/event_utils.h" |
35 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" | 35 #import "chrome/browser/ui/cocoa/extensions/extension_action_context_menu.h" |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 const NSPoint point = | 521 const NSPoint point = |
522 location_icon_decoration_->GetBubblePointInFrame(frame); | 522 location_icon_decoration_->GetBubblePointInFrame(frame); |
523 return [field_ convertPoint:point toView:nil]; | 523 return [field_ convertPoint:point toView:nil]; |
524 } | 524 } |
525 } | 525 } |
526 | 526 |
527 NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) { | 527 NSImage* LocationBarViewMac::GetKeywordImage(const std::wstring& keyword) { |
528 const TemplateURL* template_url = | 528 const TemplateURL* template_url = |
529 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); | 529 profile_->GetTemplateURLModel()->GetTemplateURLForKeyword(keyword); |
530 if (template_url && template_url->IsExtensionKeyword()) { | 530 if (template_url && template_url->IsExtensionKeyword()) { |
531 const SkBitmap& bitmap = profile_->GetExtensionsService()-> | 531 const SkBitmap& bitmap = profile_->GetExtensionService()-> |
532 GetOmniboxIcon(template_url->GetExtensionId()); | 532 GetOmniboxIcon(template_url->GetExtensionId()); |
533 return gfx::SkBitmapToNSImage(bitmap); | 533 return gfx::SkBitmapToNSImage(bitmap); |
534 } | 534 } |
535 | 535 |
536 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); | 536 return AutocompleteEditViewMac::ImageForResource(IDR_OMNIBOX_SEARCH); |
537 } | 537 } |
538 | 538 |
539 void LocationBarViewMac::Observe(NotificationType type, | 539 void LocationBarViewMac::Observe(NotificationType type, |
540 const NotificationSource& source, | 540 const NotificationSource& source, |
541 const NotificationDetails& details) { | 541 const NotificationDetails& details) { |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 | 580 |
581 page_action_decorations_.reset(); | 581 page_action_decorations_.reset(); |
582 } | 582 } |
583 | 583 |
584 void LocationBarViewMac::RefreshPageActionDecorations() { | 584 void LocationBarViewMac::RefreshPageActionDecorations() { |
585 if (!IsEditable()) { | 585 if (!IsEditable()) { |
586 DeletePageActionDecorations(); | 586 DeletePageActionDecorations(); |
587 return; | 587 return; |
588 } | 588 } |
589 | 589 |
590 ExtensionsService* service = profile_->GetExtensionsService(); | 590 ExtensionService* service = profile_->GetExtensionService(); |
591 if (!service) | 591 if (!service) |
592 return; | 592 return; |
593 | 593 |
594 std::vector<ExtensionAction*> page_actions; | 594 std::vector<ExtensionAction*> page_actions; |
595 for (size_t i = 0; i < service->extensions()->size(); ++i) { | 595 for (size_t i = 0; i < service->extensions()->size(); ++i) { |
596 if (service->extensions()->at(i)->page_action()) | 596 if (service->extensions()->at(i)->page_action()) |
597 page_actions.push_back(service->extensions()->at(i)->page_action()); | 597 page_actions.push_back(service->extensions()->at(i)->page_action()); |
598 } | 598 } |
599 | 599 |
600 // On startup we sometimes haven't loaded any extensions. This makes sure | 600 // On startup we sometimes haven't loaded any extensions. This makes sure |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 684 |
685 // These need to change anytime the layout changes. | 685 // These need to change anytime the layout changes. |
686 // TODO(shess): Anytime the field editor might have changed, the | 686 // TODO(shess): Anytime the field editor might have changed, the |
687 // cursor rects almost certainly should have changed. The tooltips | 687 // cursor rects almost certainly should have changed. The tooltips |
688 // might change even when the rects don't change. | 688 // might change even when the rects don't change. |
689 [field_ resetFieldEditorFrameIfNeeded]; | 689 [field_ resetFieldEditorFrameIfNeeded]; |
690 [field_ updateCursorAndToolTipRects]; | 690 [field_ updateCursorAndToolTipRects]; |
691 | 691 |
692 [field_ setNeedsDisplay:YES]; | 692 [field_ setNeedsDisplay:YES]; |
693 } | 693 } |
OLD | NEW |