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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/property_bag.h" | 8 #include "base/property_bag.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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
856 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 856 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
857 IDS_EDIT_SEARCH_ENGINES); | 857 IDS_EDIT_SEARCH_ENGINES); |
858 | 858 |
859 int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); | 859 int paste_position = menu_contents->GetIndexOfCommandId(IDS_APP_PASTE); |
860 if (paste_position >= 0) | 860 if (paste_position >= 0) |
861 menu_contents->InsertItemWithStringIdAt( | 861 menu_contents->InsertItemWithStringIdAt( |
862 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 862 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
863 } | 863 } |
864 | 864 |
865 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { | 865 bool OmniboxViewViews::IsCommandIdEnabled(int command_id) const { |
866 if (command_id == IDS_PASTE_AND_GO) | 866 return (command_id == IDS_PASTE_AND_GO) ? |
867 return !popup_window_mode_ && model_->CanPasteAndGo(GetClipboardText()); | 867 model_->CanPasteAndGo(GetClipboardText()) : |
868 | 868 command_updater_->IsCommandEnabled(command_id); |
869 return command_updater_->IsCommandEnabled(command_id); | |
870 } | 869 } |
871 | 870 |
872 void OmniboxViewViews::ExecuteCommand(int command_id) { | 871 void OmniboxViewViews::ExecuteCommand(int command_id) { |
873 if (command_id == IDS_PASTE_AND_GO) { | 872 if (command_id == IDS_PASTE_AND_GO) { |
874 model_->PasteAndGo(); | 873 model_->PasteAndGo(GetClipboardText()); |
875 return; | 874 return; |
876 } | 875 } |
877 | 876 |
878 command_updater_->ExecuteCommand(command_id); | 877 command_updater_->ExecuteCommand(command_id); |
879 } | 878 } |
880 | 879 |
881 #if defined(OS_CHROMEOS) | 880 #if defined(OS_CHROMEOS) |
882 void OmniboxViewViews::CandidateWindowOpened( | 881 void OmniboxViewViews::CandidateWindowOpened( |
883 chromeos::input_method::InputMethodManager* manager) { | 882 chromeos::input_method::InputMethodManager* manager) { |
884 ime_candidate_window_open_ = true; | 883 ime_candidate_window_open_ = true; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 const ui::Range& range) { | 943 const ui::Range& range) { |
945 if (text != GetText()) | 944 if (text != GetText()) |
946 textfield_->SetText(text); | 945 textfield_->SetText(text); |
947 textfield_->SelectRange(range); | 946 textfield_->SelectRange(range); |
948 } | 947 } |
949 | 948 |
950 string16 OmniboxViewViews::GetSelectedText() const { | 949 string16 OmniboxViewViews::GetSelectedText() const { |
951 // TODO(oshima): Support instant, IME. | 950 // TODO(oshima): Support instant, IME. |
952 return textfield_->GetSelectedText(); | 951 return textfield_->GetSelectedText(); |
953 } | 952 } |
OLD | NEW |