| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "mash/quick_launch/quick_launch.h" | 5 #include "mash/quick_launch/quick_launch.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 UpdateEntries(); | 89 UpdateEntries(); |
| 90 } | 90 } |
| 91 return false; | 91 return false; |
| 92 } | 92 } |
| 93 void ContentsChanged(views::Textfield* sender, | 93 void ContentsChanged(views::Textfield* sender, |
| 94 const base::string16& new_contents) override { | 94 const base::string16& new_contents) override { |
| 95 // Don't keep making a suggestion if the user didn't like what we offered. | 95 // Don't keep making a suggestion if the user didn't like what we offered. |
| 96 if (suggestion_rejected_) | 96 if (suggestion_rejected_) |
| 97 return; | 97 return; |
| 98 | 98 |
| 99 if (new_contents.empty()) |
| 100 return; |
| 101 |
| 99 // TODO(beng): it'd be nice if we persisted some history/scoring here. | 102 // TODO(beng): it'd be nice if we persisted some history/scoring here. |
| 100 for (const auto& name : app_names_) { | 103 for (const auto& name : app_names_) { |
| 101 if (base::StartsWith(name, new_contents, | 104 if (base::StartsWith(name, new_contents, |
| 102 base::CompareCase::INSENSITIVE_ASCII)) { | 105 base::CompareCase::INSENSITIVE_ASCII)) { |
| 103 base::string16 suffix = name; | 106 base::string16 suffix = name; |
| 104 base::ReplaceSubstringsAfterOffset(&suffix, 0, new_contents, | 107 base::ReplaceSubstringsAfterOffset(&suffix, 0, new_contents, |
| 105 base::string16()); | 108 base::string16()); |
| 106 gfx::Range range(static_cast<uint32_t>(new_contents.size()), | 109 gfx::Range range(static_cast<uint32_t>(new_contents.size()), |
| 107 static_cast<uint32_t>(name.size())); | 110 static_cast<uint32_t>(name.size())); |
| 108 prompt_->SetText(name); | 111 prompt_->SetText(name); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 windows_.push_back(window); | 203 windows_.push_back(window); |
| 201 } | 204 } |
| 202 | 205 |
| 203 void QuickLaunch::Create(const service_manager::Identity& remote_identity, | 206 void QuickLaunch::Create(const service_manager::Identity& remote_identity, |
| 204 mojom::LaunchableRequest request) { | 207 mojom::LaunchableRequest request) { |
| 205 bindings_.AddBinding(this, std::move(request)); | 208 bindings_.AddBinding(this, std::move(request)); |
| 206 } | 209 } |
| 207 | 210 |
| 208 } // namespace quick_launch | 211 } // namespace quick_launch |
| 209 } // namespace mash | 212 } // namespace mash |
| OLD | NEW |