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