| 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/bookmarks/bookmark_utils.h" | 5 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); | 119 PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); |
| 120 const bool always_show = | 120 const bool always_show = |
| 121 !prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar); | 121 !prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar); |
| 122 | 122 |
| 123 // The user changed when the bookmark bar is shown, update the preferences. | 123 // The user changed when the bookmark bar is shown, update the preferences. |
| 124 prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, always_show); | 124 prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, always_show); |
| 125 } | 125 } |
| 126 | 126 |
| 127 base::string16 FormatBookmarkURLForDisplay(const GURL& url) { | 127 base::string16 FormatBookmarkURLForDisplay(const GURL& url) { |
| 128 // Because this gets re-parsed by FixupURL(), it's safe to omit the scheme | 128 // Because this gets re-parsed by FixupURL(), it's safe to omit the scheme |
| 129 // and trailing slash, and unescape most characters. However, it's | 129 // and trailing slash, and unescape most characters. However, it's |
| 130 // important not to drop any username/password, or unescape anything that | 130 // important not to drop any username/password, or unescape anything that |
| 131 // changes the URL's meaning. | 131 // changes the URL's meaning. |
| 132 return url_formatter::FormatUrl( | 132 url_formatter::FormatUrlTypes format_types = |
| 133 url, url_formatter::kFormatUrlOmitAll & | 133 url_formatter::kFormatUrlOmitAll & |
| 134 ~url_formatter::kFormatUrlOmitUsernamePassword, | 134 ~url_formatter::kFormatUrlOmitUsernamePassword; |
| 135 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr); | 135 |
| 136 // If username is present, we must not omit the scheme because FixupURL() will |
| 137 // subsequently interpret the username as a scheme. crbug.com/639126 |
| 138 if (url.has_username()) |
| 139 format_types &= ~url_formatter::kFormatUrlOmitHTTP; |
| 140 |
| 141 return url_formatter::FormatUrl(url, format_types, net::UnescapeRule::SPACES, |
| 142 nullptr, nullptr, nullptr); |
| 136 } | 143 } |
| 137 | 144 |
| 138 bool IsAppsShortcutEnabled(Profile* profile) { | 145 bool IsAppsShortcutEnabled(Profile* profile) { |
| 139 // Legacy supervised users can not have apps installed currently so there's no | 146 // Legacy supervised users can not have apps installed currently so there's no |
| 140 // need to show the apps shortcut. | 147 // need to show the apps shortcut. |
| 141 if (profile->IsLegacySupervised()) | 148 if (profile->IsLegacySupervised()) |
| 142 return false; | 149 return false; |
| 143 | 150 |
| 144 #if defined(USE_ASH) | 151 #if defined(USE_ASH) |
| 145 // Don't show the apps shortcut in ash since the app launcher is enabled. | 152 // Don't show the apps shortcut in ash since the app launcher is enabled. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 #if defined(OS_WIN) | 314 #if defined(OS_WIN) |
| 308 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( | 315 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
| 309 IDR_BOOKMARK_BAR_FOLDER_MANAGED); | 316 IDR_BOOKMARK_BAR_FOLDER_MANAGED); |
| 310 #else | 317 #else |
| 311 return GetFolderIcon(gfx::VectorIconId::FOLDER_MANAGED, text_color); | 318 return GetFolderIcon(gfx::VectorIconId::FOLDER_MANAGED, text_color); |
| 312 #endif | 319 #endif |
| 313 } | 320 } |
| 314 #endif | 321 #endif |
| 315 | 322 |
| 316 } // namespace chrome | 323 } // namespace chrome |
| OLD | NEW |