| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "ui/base/ime/text_input_type.h" | 37 #include "ui/base/ime/text_input_type.h" |
| 38 #include "ui/base/l10n/l10n_util.h" | 38 #include "ui/base/l10n/l10n_util.h" |
| 39 #include "ui/base/models/simple_menu_model.h" | 39 #include "ui/base/models/simple_menu_model.h" |
| 40 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
| 41 #include "ui/events/event.h" | 41 #include "ui/events/event.h" |
| 42 #include "ui/gfx/canvas.h" | 42 #include "ui/gfx/canvas.h" |
| 43 #include "ui/gfx/font_list.h" | 43 #include "ui/gfx/font_list.h" |
| 44 #include "ui/gfx/selection_model.h" | 44 #include "ui/gfx/selection_model.h" |
| 45 #include "ui/views/border.h" | 45 #include "ui/views/border.h" |
| 46 #include "ui/views/button_drag_utils.h" | 46 #include "ui/views/button_drag_utils.h" |
| 47 #include "ui/views/controls/textfield/native_textfield_views.h" | |
| 48 #include "ui/views/controls/textfield/textfield.h" | 47 #include "ui/views/controls/textfield/textfield.h" |
| 49 #include "ui/views/ime/input_method.h" | 48 #include "ui/views/ime/input_method.h" |
| 50 #include "ui/views/layout/fill_layout.h" | 49 #include "ui/views/layout/fill_layout.h" |
| 51 #include "ui/views/views_delegate.h" | 50 #include "ui/views/views_delegate.h" |
| 52 #include "ui/views/widget/widget.h" | 51 #include "ui/views/widget/widget.h" |
| 53 #include "url/gurl.h" | 52 #include "url/gurl.h" |
| 54 | 53 |
| 55 #if defined(OS_WIN) | 54 #if defined(OS_WIN) |
| 56 #include "chrome/browser/browser_process.h" | 55 #include "chrome/browser/browser_process.h" |
| 57 #endif | 56 #endif |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 ToolbarModel::NONE, LocationBarView::BACKGROUND)); | 168 ToolbarModel::NONE, LocationBarView::BACKGROUND)); |
| 170 | 169 |
| 171 if (popup_window_mode_) | 170 if (popup_window_mode_) |
| 172 SetReadOnly(true); | 171 SetReadOnly(true); |
| 173 | 172 |
| 174 if (chrome::ShouldDisplayOriginChip()) | 173 if (chrome::ShouldDisplayOriginChip()) |
| 175 set_placeholder_text(l10n_util::GetStringUTF16(IDS_OMNIBOX_EMPTY_HINT)); | 174 set_placeholder_text(l10n_util::GetStringUTF16(IDS_OMNIBOX_EMPTY_HINT)); |
| 176 | 175 |
| 177 // Initialize the popup view using the same font. | 176 // Initialize the popup view using the same font. |
| 178 popup_view_.reset(OmniboxPopupContentsView::Create( | 177 popup_view_.reset(OmniboxPopupContentsView::Create( |
| 179 font_list(), this, model(), location_bar_view_)); | 178 GetFontList(), this, model(), location_bar_view_)); |
| 180 | 179 |
| 181 #if defined(OS_CHROMEOS) | 180 #if defined(OS_CHROMEOS) |
| 182 chromeos::input_method::InputMethodManager::Get()-> | 181 chromeos::input_method::InputMethodManager::Get()-> |
| 183 AddCandidateWindowObserver(this); | 182 AddCandidateWindowObserver(this); |
| 184 #endif | 183 #endif |
| 185 } | 184 } |
| 186 | 185 |
| 187 //////////////////////////////////////////////////////////////////////////////// | 186 //////////////////////////////////////////////////////////////////////////////// |
| 188 // OmniboxViewViews, views::Textfield implementation: | 187 // OmniboxViewViews, views::Textfield implementation: |
| 189 | 188 |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 | 666 |
| 668 base::string16 OmniboxViewViews::GetGrayTextAutocompletion() const { | 667 base::string16 OmniboxViewViews::GetGrayTextAutocompletion() const { |
| 669 #if defined(OS_WIN) || defined(USE_AURA) | 668 #if defined(OS_WIN) || defined(USE_AURA) |
| 670 return location_bar_view_->GetGrayTextAutocompletion(); | 669 return location_bar_view_->GetGrayTextAutocompletion(); |
| 671 #else | 670 #else |
| 672 return base::string16(); | 671 return base::string16(); |
| 673 #endif | 672 #endif |
| 674 } | 673 } |
| 675 | 674 |
| 676 int OmniboxViewViews::GetTextWidth() const { | 675 int OmniboxViewViews::GetTextWidth() const { |
| 677 return textfield_view_->GetWidthNeededForText(); | 676 // Returns the width necessary to display the current text, including any |
| 677 // necessary space for the cursor or border/margin. |
| 678 return GetRenderText()->GetContentWidth() + GetInsets().width(); |
| 678 } | 679 } |
| 679 | 680 |
| 680 int OmniboxViewViews::GetWidth() const { | 681 int OmniboxViewViews::GetWidth() const { |
| 681 return location_bar_view_->width(); | 682 return location_bar_view_->width(); |
| 682 } | 683 } |
| 683 | 684 |
| 684 bool OmniboxViewViews::IsImeComposing() const { | 685 bool OmniboxViewViews::IsImeComposing() const { |
| 685 return IsIMEComposing(); | 686 return IsIMEComposing(); |
| 686 } | 687 } |
| 687 | 688 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 const base::string16 text(GetClipboardText()); | 976 const base::string16 text(GetClipboardText()); |
| 976 if (!text.empty()) { | 977 if (!text.empty()) { |
| 977 // Record this paste, so we can do different behavior. | 978 // Record this paste, so we can do different behavior. |
| 978 model()->OnPaste(); | 979 model()->OnPaste(); |
| 979 // Force a Paste operation to trigger the text_changed code in | 980 // Force a Paste operation to trigger the text_changed code in |
| 980 // OnAfterPossibleChange(), even if identical contents are pasted. | 981 // OnAfterPossibleChange(), even if identical contents are pasted. |
| 981 text_before_change_.clear(); | 982 text_before_change_.clear(); |
| 982 InsertOrReplaceText(text); | 983 InsertOrReplaceText(text); |
| 983 } | 984 } |
| 984 } | 985 } |
| OLD | NEW |