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

Side by Side Diff: chrome/browser/ui/bookmarks/bookmark_utils.cc

Issue 12340111: Introduce //components/user_prefs, use to eliminate c/b/prefs dependency in Autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge of LKGR Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "chrome/browser/bookmarks/bookmark_model.h" 11 #include "chrome/browser/bookmarks/bookmark_model.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #include "chrome/browser/bookmarks/bookmark_utils.h" 13 #include "chrome/browser/bookmarks/bookmark_utils.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_navigator.h" 16 #include "chrome/browser/ui/browser_navigator.h"
17 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
18 #include "chrome/browser/ui/simple_message_box.h" 18 #include "chrome/browser/ui/simple_message_box.h"
19 #include "chrome/browser/ui/tabs/tab_strip_model.h" 19 #include "chrome/browser/ui/tabs/tab_strip_model.h"
20 #include "chrome/common/pref_names.h" 20 #include "chrome/common/pref_names.h"
21 #include "components/user_prefs/user_prefs.h"
21 #include "content/public/browser/web_contents.h" 22 #include "content/public/browser/web_contents.h"
22 #include "grit/chromium_strings.h" 23 #include "grit/chromium_strings.h"
23 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
24 #include "net/base/net_util.h" 25 #include "net/base/net_util.h"
25 #include "ui/base/l10n/l10n_util.h" 26 #include "ui/base/l10n/l10n_util.h"
26 27
27 namespace chrome { 28 namespace chrome {
28 29
29 int num_bookmark_urls_before_prompting = 15; 30 int num_bookmark_urls_before_prompting = 15;
30 31
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } 234 }
234 235
235 void GetURLAndTitleToBookmark(content::WebContents* web_contents, 236 void GetURLAndTitleToBookmark(content::WebContents* web_contents,
236 GURL* url, 237 GURL* url,
237 string16* title) { 238 string16* title) {
238 *url = web_contents->GetURL(); 239 *url = web_contents->GetURL();
239 *title = web_contents->GetTitle(); 240 *title = web_contents->GetTitle();
240 } 241 }
241 242
242 void ToggleBookmarkBarWhenVisible(content::BrowserContext* browser_context) { 243 void ToggleBookmarkBarWhenVisible(content::BrowserContext* browser_context) {
243 PrefService* prefs = PrefServiceFromBrowserContext(browser_context); 244 PrefService* prefs = components::UserPrefs::Get(browser_context);
244 const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar); 245 const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar);
245 246
246 // The user changed when the bookmark bar is shown, update the preferences. 247 // The user changed when the bookmark bar is shown, update the preferences.
247 prefs->SetBoolean(prefs::kShowBookmarkBar, always_show); 248 prefs->SetBoolean(prefs::kShowBookmarkBar, always_show);
248 } 249 }
249 250
250 string16 FormatBookmarkURLForDisplay(const GURL& url, 251 string16 FormatBookmarkURLForDisplay(const GURL& url,
251 const PrefService* prefs) { 252 const PrefService* prefs) {
252 std::string languages; 253 std::string languages;
253 if (prefs) 254 if (prefs)
254 languages = prefs->GetString(prefs::kAcceptLanguages); 255 languages = prefs->GetString(prefs::kAcceptLanguages);
255 256
256 // Because this gets re-parsed by FixupURL(), it's safe to omit the scheme 257 // Because this gets re-parsed by FixupURL(), it's safe to omit the scheme
257 // and trailing slash, and unescape most characters. However, it's 258 // and trailing slash, and unescape most characters. However, it's
258 // important not to drop any username/password, or unescape anything that 259 // important not to drop any username/password, or unescape anything that
259 // changes the URL's meaning. 260 // changes the URL's meaning.
260 return net::FormatUrl( 261 return net::FormatUrl(
261 url, languages, 262 url, languages,
262 net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword, 263 net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword,
263 net::UnescapeRule::SPACES, NULL, NULL, NULL); 264 net::UnescapeRule::SPACES, NULL, NULL, NULL);
264 } 265 }
265 266
266 } // namespace chrome 267 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698