Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: ui/views/controls/textfield/textfield.cc

Issue 2790773002: Cleanup MenuRunner API (Closed)
Patch Set: Rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/controls/scrollbar/base_scroll_bar.cc ('k') | ui/views/examples/menu_example.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 GetInputMethod()->CancelComposition(this); 1044 GetInputMethod()->CancelComposition(this);
1045 } 1045 }
1046 1046
1047 //////////////////////////////////////////////////////////////////////////////// 1047 ////////////////////////////////////////////////////////////////////////////////
1048 // Textfield, ContextMenuController overrides: 1048 // Textfield, ContextMenuController overrides:
1049 1049
1050 void Textfield::ShowContextMenuForView(View* source, 1050 void Textfield::ShowContextMenuForView(View* source,
1051 const gfx::Point& point, 1051 const gfx::Point& point,
1052 ui::MenuSourceType source_type) { 1052 ui::MenuSourceType source_type) {
1053 UpdateContextMenu(); 1053 UpdateContextMenu();
1054 ignore_result(context_menu_runner_->RunMenuAt(GetWidget(), 1054 context_menu_runner_->RunMenuAt(GetWidget(), NULL,
1055 NULL, 1055 gfx::Rect(point, gfx::Size()),
1056 gfx::Rect(point, gfx::Size()), 1056 MENU_ANCHOR_TOPLEFT, source_type);
1057 MENU_ANCHOR_TOPLEFT,
1058 source_type));
1059 } 1057 }
1060 1058
1061 //////////////////////////////////////////////////////////////////////////////// 1059 ////////////////////////////////////////////////////////////////////////////////
1062 // Textfield, DragController overrides: 1060 // Textfield, DragController overrides:
1063 1061
1064 void Textfield::WriteDragDataForView(View* sender, 1062 void Textfield::WriteDragDataForView(View* sender,
1065 const gfx::Point& press_pt, 1063 const gfx::Point& press_pt,
1066 OSExchangeData* data) { 1064 OSExchangeData* data) {
1067 const base::string16& selected_text(GetSelectedText()); 1065 const base::string16& selected_text(GetSelectedText());
1068 data->SetString(selected_text); 1066 data->SetString(selected_text);
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE); 2029 context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE);
2032 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); 2030 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR);
2033 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL, 2031 context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL,
2034 IDS_APP_SELECT_ALL); 2032 IDS_APP_SELECT_ALL);
2035 2033
2036 // If the controller adds menu commands, also override ExecuteCommand() and 2034 // If the controller adds menu commands, also override ExecuteCommand() and
2037 // IsCommandIdEnabled() as appropriate, for the commands added. 2035 // IsCommandIdEnabled() as appropriate, for the commands added.
2038 if (controller_) 2036 if (controller_)
2039 controller_->UpdateContextMenu(context_menu_contents_.get()); 2037 controller_->UpdateContextMenu(context_menu_contents_.get());
2040 } 2038 }
2041 context_menu_runner_.reset(new MenuRunner(context_menu_contents_.get(), 2039 context_menu_runner_.reset(
2042 MenuRunner::HAS_MNEMONICS | 2040 new MenuRunner(context_menu_contents_.get(),
2043 MenuRunner::CONTEXT_MENU | 2041 MenuRunner::HAS_MNEMONICS | MenuRunner::CONTEXT_MENU));
2044 MenuRunner::ASYNC));
2045 } 2042 }
2046 2043
2047 bool Textfield::ImeEditingAllowed() const { 2044 bool Textfield::ImeEditingAllowed() const {
2048 // Disallow input method editing of password fields. 2045 // Disallow input method editing of password fields.
2049 ui::TextInputType t = GetTextInputType(); 2046 ui::TextInputType t = GetTextInputType();
2050 return (t != ui::TEXT_INPUT_TYPE_NONE && t != ui::TEXT_INPUT_TYPE_PASSWORD); 2047 return (t != ui::TEXT_INPUT_TYPE_NONE && t != ui::TEXT_INPUT_TYPE_PASSWORD);
2051 } 2048 }
2052 2049
2053 void Textfield::RevealPasswordChar(int index) { 2050 void Textfield::RevealPasswordChar(int index) {
2054 GetRenderText()->SetObscuredRevealIndex(index); 2051 GetRenderText()->SetObscuredRevealIndex(index);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 cursor_blink_timer_.Stop(); 2094 cursor_blink_timer_.Stop();
2098 } 2095 }
2099 2096
2100 void Textfield::OnCursorBlinkTimerFired() { 2097 void Textfield::OnCursorBlinkTimerFired() {
2101 DCHECK(ShouldBlinkCursor()); 2098 DCHECK(ShouldBlinkCursor());
2102 cursor_view_.SetVisible(!cursor_view_.visible()); 2099 cursor_view_.SetVisible(!cursor_view_.visible());
2103 UpdateCursorViewPosition(); 2100 UpdateCursorViewPosition();
2104 } 2101 }
2105 2102
2106 } // namespace views 2103 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/base_scroll_bar.cc ('k') | ui/views/examples/menu_example.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698