| 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_win.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <locale> | 8 #include <locale> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 2566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2577 void OmniboxViewWin::BuildContextMenu() { | 2577 void OmniboxViewWin::BuildContextMenu() { |
| 2578 if (context_menu_contents_.get()) | 2578 if (context_menu_contents_.get()) |
| 2579 return; | 2579 return; |
| 2580 | 2580 |
| 2581 context_menu_contents_.reset(new ui::SimpleMenuModel(this)); | 2581 context_menu_contents_.reset(new ui::SimpleMenuModel(this)); |
| 2582 // Set up context menu. | 2582 // Set up context menu. |
| 2583 if (popup_window_mode_) { | 2583 if (popup_window_mode_) { |
| 2584 context_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY); | 2584 context_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY); |
| 2585 } else { | 2585 } else { |
| 2586 context_menu_contents_->AddItemWithStringId(IDS_UNDO, IDS_UNDO); | 2586 context_menu_contents_->AddItemWithStringId(IDS_UNDO, IDS_UNDO); |
| 2587 context_menu_contents_->AddSeparator(); | 2587 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 2588 context_menu_contents_->AddItemWithStringId(IDC_CUT, IDS_CUT); | 2588 context_menu_contents_->AddItemWithStringId(IDC_CUT, IDS_CUT); |
| 2589 context_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY); | 2589 context_menu_contents_->AddItemWithStringId(IDC_COPY, IDS_COPY); |
| 2590 context_menu_contents_->AddItemWithStringId(IDC_PASTE, IDS_PASTE); | 2590 context_menu_contents_->AddItemWithStringId(IDC_PASTE, IDS_PASTE); |
| 2591 // GetContextualLabel() will override this next label with the | 2591 // GetContextualLabel() will override this next label with the |
| 2592 // IDS_PASTE_AND_SEARCH label as needed. | 2592 // IDS_PASTE_AND_SEARCH label as needed. |
| 2593 context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, | 2593 context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, |
| 2594 IDS_PASTE_AND_GO); | 2594 IDS_PASTE_AND_GO); |
| 2595 context_menu_contents_->AddSeparator(); | 2595 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 2596 context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); | 2596 context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); |
| 2597 context_menu_contents_->AddSeparator(); | 2597 context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR); |
| 2598 context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, | 2598 context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, |
| 2599 IDS_EDIT_SEARCH_ENGINES); | 2599 IDS_EDIT_SEARCH_ENGINES); |
| 2600 } | 2600 } |
| 2601 } | 2601 } |
| 2602 | 2602 |
| 2603 void OmniboxViewWin::SelectAllIfNecessary(MouseButton button, | 2603 void OmniboxViewWin::SelectAllIfNecessary(MouseButton button, |
| 2604 const CPoint& point) { | 2604 const CPoint& point) { |
| 2605 // When the user has clicked and released to give us focus, select all. | 2605 // When the user has clicked and released to give us focus, select all. |
| 2606 if (tracking_click_[button] && | 2606 if (tracking_click_[button] && |
| 2607 !IsDrag(click_point_[button], point)) { | 2607 !IsDrag(click_point_[button], point)) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2631 return (rect.left - client_rect.left) + (client_rect.right - rect.right); | 2631 return (rect.left - client_rect.left) + (client_rect.right - rect.right); |
| 2632 } | 2632 } |
| 2633 | 2633 |
| 2634 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { | 2634 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { |
| 2635 // Use font_.GetStringWidth() instead of | 2635 // Use font_.GetStringWidth() instead of |
| 2636 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is | 2636 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is |
| 2637 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, | 2637 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, |
| 2638 // PosFromChar(i) might return 0 when i is greater than 1. | 2638 // PosFromChar(i) might return 0 when i is greater than 1. |
| 2639 return font_.GetStringWidth(text) + GetHorizontalMargin(); | 2639 return font_.GetStringWidth(text) + GetHorizontalMargin(); |
| 2640 } | 2640 } |
| OLD | NEW |