| 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" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/browser/autocomplete/autocomplete_input.h" | 13 #include "chrome/browser/autocomplete/autocomplete_input.h" |
| 14 #include "chrome/browser/autocomplete/autocomplete_match.h" | 14 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 15 #include "chrome/browser/bookmarks/bookmark_node_data.h" | 15 #include "chrome/browser/bookmarks/bookmark_node_data.h" |
| 16 #include "chrome/browser/command_updater.h" | 16 #include "chrome/browser/command_updater.h" |
| 17 #include "chrome/browser/search/search.h" | 17 #include "chrome/browser/search/search.h" |
| 18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" | 18 #include "chrome/browser/ui/omnibox/omnibox_edit_controller.h" |
| 19 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 19 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
| 20 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" | 20 #include "chrome/browser/ui/omnibox/omnibox_popup_model.h" |
| 21 #include "chrome/browser/ui/view_ids.h" | 21 #include "chrome/browser/ui/view_ids.h" |
| 22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
| 23 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" | 23 #include "chrome/browser/ui/views/omnibox/omnibox_popup_contents_view.h" |
| 24 #include "chrome/browser/ui/views/website_settings/website_settings_popup_view.h
" |
| 24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 25 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 26 #include "extensions/common/constants.h" | 27 #include "extensions/common/constants.h" |
| 27 #include "grit/app_locale_settings.h" | 28 #include "grit/app_locale_settings.h" |
| 28 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 29 #include "grit/ui_strings.h" | 30 #include "grit/ui_strings.h" |
| 30 #include "net/base/escape.h" | 31 #include "net/base/escape.h" |
| 31 #include "third_party/skia/include/core/SkColor.h" | 32 #include "third_party/skia/include/core/SkColor.h" |
| 32 #include "ui/accessibility/ax_view_state.h" | 33 #include "ui/accessibility/ax_view_state.h" |
| 33 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 34 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 native_view = client->GetFocusedWindow(); | 400 native_view = client->GetFocusedWindow(); |
| 400 } | 401 } |
| 401 #endif | 402 #endif |
| 402 model()->OnWillKillFocus(native_view); | 403 model()->OnWillKillFocus(native_view); |
| 403 // Close the popup. | 404 // Close the popup. |
| 404 CloseOmniboxPopup(); | 405 CloseOmniboxPopup(); |
| 405 | 406 |
| 406 // Tell the model to reset itself. | 407 // Tell the model to reset itself. |
| 407 model()->OnKillFocus(); | 408 model()->OnKillFocus(); |
| 408 | 409 |
| 409 OnDidKillFocus(); | 410 // Ignore loss of focus if we lost focus because the website settings popup |
| 411 // is open. When the popup is destroyed, focus will return to the Omnibox. |
| 412 if (!WebsiteSettingsPopupView::IsPopupShowing()) |
| 413 OnDidKillFocus(); |
| 410 | 414 |
| 411 // Make sure the beginning of the text is visible. | 415 // Make sure the beginning of the text is visible. |
| 412 SelectRange(gfx::Range(0)); | 416 SelectRange(gfx::Range(0)); |
| 413 } | 417 } |
| 414 | 418 |
| 415 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { | 419 base::string16 OmniboxViewViews::GetSelectionClipboardText() const { |
| 416 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); | 420 return SanitizeTextForPaste(Textfield::GetSelectionClipboardText()); |
| 417 } | 421 } |
| 418 | 422 |
| 419 //////////////////////////////////////////////////////////////////////////////// | 423 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 const base::string16 text(GetClipboardText()); | 1001 const base::string16 text(GetClipboardText()); |
| 998 if (!text.empty()) { | 1002 if (!text.empty()) { |
| 999 // Record this paste, so we can do different behavior. | 1003 // Record this paste, so we can do different behavior. |
| 1000 model()->OnPaste(); | 1004 model()->OnPaste(); |
| 1001 // Force a Paste operation to trigger the text_changed code in | 1005 // Force a Paste operation to trigger the text_changed code in |
| 1002 // OnAfterPossibleChange(), even if identical contents are pasted. | 1006 // OnAfterPossibleChange(), even if identical contents are pasted. |
| 1003 text_before_change_.clear(); | 1007 text_before_change_.clear(); |
| 1004 InsertOrReplaceText(text); | 1008 InsertOrReplaceText(text); |
| 1005 } | 1009 } |
| 1006 } | 1010 } |
| OLD | NEW |