OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_mac.h" |
6 | 6 |
7 #include <Carbon/Carbon.h> // kVK_Return | 7 #include <Carbon/Carbon.h> // kVK_Return |
8 | 8 |
9 #include "app/clipboard/clipboard.h" | 9 #include "app/clipboard/clipboard.h" |
10 #include "app/gfx/font.h" | 10 #include "app/gfx/font.h" |
11 #include "app/l10n_util_mac.h" | 11 #include "app/l10n_util_mac.h" |
12 #include "app/resource_bundle.h" | 12 #include "app/resource_bundle.h" |
13 #import "base/cocoa_protocols_mac.h" | 13 #import "base/cocoa_protocols_mac.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/sys_string_conversions.h" | 15 #include "base/sys_string_conversions.h" |
16 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 16 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
17 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" | 17 #include "chrome/browser/autocomplete/autocomplete_popup_model.h" |
18 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 18 #include "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
19 #include "chrome/browser/browser_list.h" | |
20 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
21 #include "chrome/browser/cocoa/event_utils.h" | 20 #include "chrome/browser/cocoa/event_utils.h" |
22 #include "chrome/browser/tab_contents/navigation_entry.h" | |
23 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
24 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
25 | 23 |
26 // Focus-handling between |field_| and |model_| is a bit subtle. | 24 // Focus-handling between |field_| and |model_| is a bit subtle. |
27 // Other platforms detect change of focus, which is inconvenient | 25 // Other platforms detect change of focus, which is inconvenient |
28 // without subclassing NSTextField (even with a subclass, the use of a | 26 // without subclassing NSTextField (even with a subclass, the use of a |
29 // field editor may complicate things). | 27 // field editor may complicate things). |
30 // | 28 // |
31 // |model_| doesn't actually do anything when it gains focus, it just | 29 // |model_| doesn't actually do anything when it gains focus, it just |
32 // initializes. Visible activity happens only after the user edits. | 30 // initializes. Visible activity happens only after the user edits. |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 [editor replaceCharactersInRange:selectedRange withString:s]; | 623 [editor replaceCharactersInRange:selectedRange withString:s]; |
626 [editor didChangeText]; | 624 [editor didChangeText]; |
627 } | 625 } |
628 } | 626 } |
629 | 627 |
630 bool AutocompleteEditViewMac::CanPasteAndGo() { | 628 bool AutocompleteEditViewMac::CanPasteAndGo() { |
631 return | 629 return |
632 model_->CanPasteAndGo(GetClipboardText(g_browser_process->clipboard())); | 630 model_->CanPasteAndGo(GetClipboardText(g_browser_process->clipboard())); |
633 } | 631 } |
634 | 632 |
635 void AutocompleteEditViewMac::OnSecurityIconClicked() { | |
636 TabContents* tab = BrowserList::GetLastActive()->GetSelectedTabContents(); | |
637 NavigationEntry* nav_entry = tab->controller().GetActiveEntry(); | |
638 if (!nav_entry) { | |
639 NOTREACHED(); | |
640 return; | |
641 } | |
642 tab->ShowPageInfo(nav_entry->url(), nav_entry->ssl(), true); | |
643 } | |
644 | |
645 int AutocompleteEditViewMac::GetPasteActionStringId() { | 633 int AutocompleteEditViewMac::GetPasteActionStringId() { |
646 DCHECK(CanPasteAndGo()); | 634 DCHECK(CanPasteAndGo()); |
647 | 635 |
648 // Use PASTE_AND_SEARCH as the default fallback (although the DCHECK above | 636 // Use PASTE_AND_SEARCH as the default fallback (although the DCHECK above |
649 // should never trigger). | 637 // should never trigger). |
650 if (!model_->is_paste_and_search()) | 638 if (!model_->is_paste_and_search()) |
651 return IDS_PASTE_AND_GO; | 639 return IDS_PASTE_AND_GO; |
652 else | 640 else |
653 return IDS_PASTE_AND_SEARCH; | 641 return IDS_PASTE_AND_SEARCH; |
654 } | 642 } |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 // TODO(shess): Figure out where the selection belongs. On GTK, | 882 // TODO(shess): Figure out where the selection belongs. On GTK, |
895 // it's set to the start of the text. | 883 // it's set to the start of the text. |
896 } | 884 } |
897 | 885 |
898 // Signal that we've lost focus when the window resigns key. | 886 // Signal that we've lost focus when the window resigns key. |
899 - (void)windowDidResignKey:(NSNotification*)notification { | 887 - (void)windowDidResignKey:(NSNotification*)notification { |
900 edit_view_->OnDidResignKey(); | 888 edit_view_->OnDidResignKey(); |
901 } | 889 } |
902 | 890 |
903 @end | 891 @end |
OLD | NEW |