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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 native_view = client->GetFocusedWindow(); | 411 native_view = client->GetFocusedWindow(); |
411 } | 412 } |
412 #endif | 413 #endif |
413 model()->OnWillKillFocus(native_view); | 414 model()->OnWillKillFocus(native_view); |
414 // Close the popup. | 415 // Close the popup. |
415 CloseOmniboxPopup(); | 416 CloseOmniboxPopup(); |
416 | 417 |
417 // Tell the model to reset itself. | 418 // Tell the model to reset itself. |
418 model()->OnKillFocus(); | 419 model()->OnKillFocus(); |
419 | 420 |
420 // If user input is not in progress, re-enable the origin chip and URL | 421 // If user input is not in progress and the website settings popup is not |
421 // replacement. This addresses the case where the URL was shown by a call | 422 // being shown, re-enable the origin chip and URL replacement. This addresses |
422 // to ShowURL(). If the Omnibox achieved focus by other means, the calls to | 423 // the case where the URL was shown by a call to ShowURL(). If the Omnibox |
423 // set_url_replacement_enabled, UpdatePermanentText and RevertAll are not | 424 // achieved focus by other means, the calls to set_url_replacement_enabled, |
424 // required (a call to OnChanged would be sufficient) but do no harm. | 425 // UpdatePermanentText and RevertAll are not required (a call to OnChanged |
426 // would be sufficient) but do no harm. | |
425 if (chrome::ShouldDisplayOriginChipV2() && | 427 if (chrome::ShouldDisplayOriginChipV2() && |
428 !WebsiteSettingsPopupView::IsPopupShowing() && | |
Peter Kasting
2014/03/12 21:11:27
Adding this worries me because I'm concerned the o
Justin Donnelly
2014/03/14 15:27:51
The way this behaves (tested in Linux, CrOS and Wi
Peter Kasting
2014/03/18 01:23:13
What if we just left this line out? If you've hid
Justin Donnelly
2014/03/18 15:54:48
Yeah, I initially tried this. It's not horrible,
| |
426 !model()->user_input_in_progress()) { | 429 !model()->user_input_in_progress()) { |
427 controller()->GetToolbarModel()->set_origin_chip_enabled(true); | 430 controller()->GetToolbarModel()->set_origin_chip_enabled(true); |
428 controller()->GetToolbarModel()->set_url_replacement_enabled(true); | 431 controller()->GetToolbarModel()->set_url_replacement_enabled(true); |
429 model()->UpdatePermanentText(); | 432 model()->UpdatePermanentText(); |
430 RevertAll(); | 433 RevertAll(); |
431 } | 434 } |
432 | 435 |
433 // Make sure the beginning of the text is visible. | 436 // Make sure the beginning of the text is visible. |
434 SelectRange(gfx::Range(0)); | 437 SelectRange(gfx::Range(0)); |
435 } | 438 } |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1019 const base::string16 text(GetClipboardText()); | 1022 const base::string16 text(GetClipboardText()); |
1020 if (!text.empty()) { | 1023 if (!text.empty()) { |
1021 // Record this paste, so we can do different behavior. | 1024 // Record this paste, so we can do different behavior. |
1022 model()->OnPaste(); | 1025 model()->OnPaste(); |
1023 // Force a Paste operation to trigger the text_changed code in | 1026 // Force a Paste operation to trigger the text_changed code in |
1024 // OnAfterPossibleChange(), even if identical contents are pasted. | 1027 // OnAfterPossibleChange(), even if identical contents are pasted. |
1025 text_before_change_.clear(); | 1028 text_before_change_.clear(); |
1026 InsertOrReplaceText(text); | 1029 InsertOrReplaceText(text); |
1027 } | 1030 } |
1028 } | 1031 } |
OLD | NEW |