| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 6 | 6 |
| 7 #include "base/property_bag.h" | 7 #include "base/property_bag.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 #include "grit/app_locale_settings.h" | 23 #include "grit/app_locale_settings.h" |
| 24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 25 #include "net/base/escape.h" | 25 #include "net/base/escape.h" |
| 26 #include "third_party/skia/include/core/SkColor.h" | 26 #include "third_party/skia/include/core/SkColor.h" |
| 27 #include "ui/base/accessibility/accessible_view_state.h" | 27 #include "ui/base/accessibility/accessible_view_state.h" |
| 28 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 28 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| 29 #include "ui/base/dragdrop/drag_drop_types.h" | 29 #include "ui/base/dragdrop/drag_drop_types.h" |
| 30 #include "ui/base/dragdrop/os_exchange_data.h" | 30 #include "ui/base/dragdrop/os_exchange_data.h" |
| 31 #include "ui/base/ime/text_input_type.h" | 31 #include "ui/base/ime/text_input_type.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/models/simple_menu_model.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 34 #include "ui/gfx/font.h" | 35 #include "ui/gfx/font.h" |
| 35 #include "ui/gfx/render_text.h" | 36 #include "ui/gfx/render_text.h" |
| 36 #include "ui/views/border.h" | 37 #include "ui/views/border.h" |
| 37 #include "ui/views/controls/textfield/textfield.h" | 38 #include "ui/views/controls/textfield/textfield.h" |
| 38 #include "ui/views/events/event.h" | 39 #include "ui/views/events/event.h" |
| 39 #include "ui/views/layout/fill_layout.h" | 40 #include "ui/views/layout/fill_layout.h" |
| 40 #include "ui/views/views_delegate.h" | 41 #include "ui/views/views_delegate.h" |
| 41 | 42 |
| 42 #if defined(OS_WIN) | 43 #if defined(OS_WIN) |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 const string16 text = textfield_->text(); | 709 const string16 text = textfield_->text(); |
| 709 GURL url; | 710 GURL url; |
| 710 bool write_url; | 711 bool write_url; |
| 711 model_->AdjustTextForCopy(selection_range.start(), selected_text == text, | 712 model_->AdjustTextForCopy(selection_range.start(), selected_text == text, |
| 712 &selected_text, &url, &write_url); | 713 &selected_text, &url, &write_url); |
| 713 data->SetString(selected_text); | 714 data->SetString(selected_text); |
| 714 if (write_url) | 715 if (write_url) |
| 715 data->SetURL(url, selected_text); | 716 data->SetURL(url, selected_text); |
| 716 } | 717 } |
| 717 | 718 |
| 719 void OmniboxViewViews::UpdateContextMenu(ui::SimpleMenuModel* menu_contents) { |
| 720 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 721 // is using IDS_ for all its command ids. This is because views cannot depend |
| 722 // on IDC_ for now. |
| 723 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 724 IDS_EDIT_SEARCH_ENGINES); |
| 725 } |
| 726 |
| 727 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { |
| 728 return command_updater_->IsCommandEnabled(command_id); |
| 729 } |
| 730 |
| 731 void OmniboxViewViews::ExecuteCommand(int command_id) { |
| 732 command_updater_->ExecuteCommand(command_id); |
| 733 } |
| 734 |
| 718 #if defined(OS_CHROMEOS) | 735 #if defined(OS_CHROMEOS) |
| 719 void OmniboxViewViews::CandidateWindowOpened( | 736 void OmniboxViewViews::CandidateWindowOpened( |
| 720 chromeos::input_method::InputMethodManager* manager) { | 737 chromeos::input_method::InputMethodManager* manager) { |
| 721 ime_candidate_window_open_ = true; | 738 ime_candidate_window_open_ = true; |
| 722 ClosePopup(); | 739 ClosePopup(); |
| 723 } | 740 } |
| 724 | 741 |
| 725 void OmniboxViewViews::CandidateWindowClosed( | 742 void OmniboxViewViews::CandidateWindowClosed( |
| 726 chromeos::input_method::InputMethodManager* manager) { | 743 chromeos::input_method::InputMethodManager* manager) { |
| 727 ime_candidate_window_open_ = false; | 744 ime_candidate_window_open_ = false; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, | 827 OmniboxViewViews* omnibox_view = new OmniboxViewViews(controller, |
| 811 toolbar_model, | 828 toolbar_model, |
| 812 profile, | 829 profile, |
| 813 command_updater, | 830 command_updater, |
| 814 popup_window_mode, | 831 popup_window_mode, |
| 815 location_bar); | 832 location_bar); |
| 816 omnibox_view->Init(); | 833 omnibox_view->Init(); |
| 817 return omnibox_view; | 834 return omnibox_view; |
| 818 } | 835 } |
| 819 #endif | 836 #endif |
| OLD | NEW |