Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Unified Diff: ui/base/accelerators/menu_label_accelerator_util_linux.cc

Issue 851853002: It is time. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Trying to reup because the last upload failed. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/accelerators/menu_label_accelerator_util_linux.cc
diff --git a/ui/base/accelerators/menu_label_accelerator_util_linux.cc b/ui/base/accelerators/menu_label_accelerator_util_linux.cc
deleted file mode 100644
index 0a00f82e09476c0d5d49a1942f4873bce78653df..0000000000000000000000000000000000000000
--- a/ui/base/accelerators/menu_label_accelerator_util_linux.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/base/accelerators/menu_label_accelerator_util_linux.h"
-
-#include "base/strings/string_util.h"
-
-namespace {
-
-// Common implementation of ConvertAcceleratorsFromWindowsStyle() and
-// RemoveWindowsStyleAccelerators().
-// Replaces all ampersands (as used in our grd files to indicate mnemonics)
-// to |target|, except ampersands appearing in pairs which are replaced by
-// a single ampersand. Any underscores get replaced with two underscores as
-// is needed by GTK.
-std::string ConvertAmpersandsTo(const std::string& label,
- const std::string& target) {
- std::string ret;
- ret.reserve(label.length() * 2);
- for (size_t i = 0; i < label.length(); ++i) {
- if ('_' == label[i]) {
- ret.push_back('_');
- ret.push_back('_');
- } else if ('&' == label[i]) {
- if (i + 1 < label.length() && '&' == label[i + 1]) {
- ret.push_back('&');
- ++i;
- } else {
- ret.append(target);
- }
- } else {
- ret.push_back(label[i]);
- }
- }
-
- return ret;
-}
-
-} // namespace
-
-namespace ui {
-
-std::string ConvertAcceleratorsFromWindowsStyle(const std::string& label) {
- return ConvertAmpersandsTo(label, "_");
-}
-
-std::string RemoveWindowsStyleAccelerators(const std::string& label) {
- return ConvertAmpersandsTo(label, std::string());
-}
-
-// Replaces all ampersands in |label| with two ampersands. This effectively
-// escapes strings for later processing by ConvertAmpersandsTo(), so that
-// ConvertAmpersandsTo(EscapeWindowsStyleAccelerators(x), *) is |x| with
-// underscores doubled, making the string that appears to the user just |x|.
-std::string EscapeWindowsStyleAccelerators(const std::string& label) {
- std::string ret;
- base::ReplaceChars(label, "&", "&&", &ret);
- return ret;
-}
-
-} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698