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 // This file defines helper functions shared by the various implementations | 5 // This file defines helper functions shared by the various implementations |
6 // of OmniboxView. | 6 // of OmniboxView. |
7 | 7 |
8 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 8 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return StripJavascriptSchemas(base::UTF8ToUTF16(url.spec())); | 81 return StripJavascriptSchemas(base::UTF8ToUTF16(url.spec())); |
82 } | 82 } |
83 | 83 |
84 return base::string16(); | 84 return base::string16(); |
85 } | 85 } |
86 | 86 |
87 OmniboxView::~OmniboxView() { | 87 OmniboxView::~OmniboxView() { |
88 } | 88 } |
89 | 89 |
90 void OmniboxView::HandleOriginChipMouseRelease() { | 90 void OmniboxView::HandleOriginChipMouseRelease() { |
91 // HIDE_ON_MOUSE_RELEASE only hides if there isn't any current text in the | 91 // Only hide if there isn't any current text in the Omnibox (e.g. search |
92 // Omnibox (e.g. search terms). | 92 // terms). |
93 if ((chrome::GetOriginChipV2Condition() == | 93 if (controller()->GetToolbarModel()->GetText().empty()) |
94 chrome::ORIGIN_CHIP_V2_HIDE_ON_MOUSE_RELEASE) && | |
95 controller()->GetToolbarModel()->GetText().empty()) { | |
96 controller()->HideOriginChip(); | 94 controller()->HideOriginChip(); |
97 } | |
98 } | 95 } |
99 | 96 |
100 void OmniboxView::OnDidKillFocus() { | 97 void OmniboxView::OnDidKillFocus() { |
101 if (chrome::ShouldDisplayOriginChipV2() && | 98 if (chrome::ShouldDisplayOriginChip() && !model()->user_input_in_progress()) |
102 !model()->user_input_in_progress()) { | |
103 controller()->ShowOriginChip(); | 99 controller()->ShowOriginChip(); |
104 } | |
105 } | 100 } |
106 | 101 |
107 void OmniboxView::OpenMatch(const AutocompleteMatch& match, | 102 void OmniboxView::OpenMatch(const AutocompleteMatch& match, |
108 WindowOpenDisposition disposition, | 103 WindowOpenDisposition disposition, |
109 const GURL& alternate_nav_url, | 104 const GURL& alternate_nav_url, |
110 const base::string16& pasted_text, | 105 const base::string16& pasted_text, |
111 size_t selected_line) { | 106 size_t selected_line) { |
112 // Invalid URLs such as chrome://history can end up here. | 107 // Invalid URLs such as chrome://history can end up here. |
113 if (!match.destination_url.is_valid() || !model_) | 108 if (!match.destination_url.is_valid() || !model_) |
114 return; | 109 return; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 // |profile| can be NULL in tests. | 217 // |profile| can be NULL in tests. |
223 if (profile) | 218 if (profile) |
224 model_.reset(new OmniboxEditModel(this, controller, profile)); | 219 model_.reset(new OmniboxEditModel(this, controller, profile)); |
225 } | 220 } |
226 | 221 |
227 void OmniboxView::TextChanged() { | 222 void OmniboxView::TextChanged() { |
228 EmphasizeURLComponents(); | 223 EmphasizeURLComponents(); |
229 if (model_.get()) | 224 if (model_.get()) |
230 model_->OnChanged(); | 225 model_->OnChanged(); |
231 } | 226 } |
OLD | NEW |