| 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 "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" |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 | 290 |
| 291 void GetURLAndTitleToBookmark(content::WebContents* web_contents, | 291 void GetURLAndTitleToBookmark(content::WebContents* web_contents, |
| 292 GURL* url, | 292 GURL* url, |
| 293 base::string16* title) { | 293 base::string16* title) { |
| 294 *url = GetURLToBookmark(web_contents); | 294 *url = GetURLToBookmark(web_contents); |
| 295 *title = web_contents->GetTitle(); | 295 *title = web_contents->GetTitle(); |
| 296 } | 296 } |
| 297 | 297 |
| 298 void ToggleBookmarkBarWhenVisible(content::BrowserContext* browser_context) { | 298 void ToggleBookmarkBarWhenVisible(content::BrowserContext* browser_context) { |
| 299 PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); | 299 PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); |
| 300 const bool always_show = !prefs->GetBoolean(prefs::kShowBookmarkBar); | 300 const bool always_show = |
| 301 !prefs->GetBoolean(bookmarks::prefs::kShowBookmarkBar); |
| 301 | 302 |
| 302 // The user changed when the bookmark bar is shown, update the preferences. | 303 // The user changed when the bookmark bar is shown, update the preferences. |
| 303 prefs->SetBoolean(prefs::kShowBookmarkBar, always_show); | 304 prefs->SetBoolean(bookmarks::prefs::kShowBookmarkBar, always_show); |
| 304 } | 305 } |
| 305 | 306 |
| 306 base::string16 FormatBookmarkURLForDisplay(const GURL& url, | 307 base::string16 FormatBookmarkURLForDisplay(const GURL& url, |
| 307 const PrefService* prefs) { | 308 const PrefService* prefs) { |
| 308 std::string languages; | 309 std::string languages; |
| 309 if (prefs) | 310 if (prefs) |
| 310 languages = prefs->GetString(prefs::kAcceptLanguages); | 311 languages = prefs->GetString(prefs::kAcceptLanguages); |
| 311 | 312 |
| 312 // Because this gets re-parsed by FixupURL(), it's safe to omit the scheme | 313 // Because this gets re-parsed by FixupURL(), it's safe to omit the scheme |
| 313 // and trailing slash, and unescape most characters. However, it's | 314 // and trailing slash, and unescape most characters. However, it's |
| (...skipping 16 matching lines...) Expand all Loading... |
| 330 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) | 331 if (host_desktop_type == chrome::HOST_DESKTOP_TYPE_ASH) |
| 331 return false; | 332 return false; |
| 332 | 333 |
| 333 return chrome::IsInstantExtendedAPIEnabled() && !profile->IsOffTheRecord(); | 334 return chrome::IsInstantExtendedAPIEnabled() && !profile->IsOffTheRecord(); |
| 334 } | 335 } |
| 335 | 336 |
| 336 bool ShouldShowAppsShortcutInBookmarkBar( | 337 bool ShouldShowAppsShortcutInBookmarkBar( |
| 337 Profile* profile, | 338 Profile* profile, |
| 338 chrome::HostDesktopType host_desktop_type) { | 339 chrome::HostDesktopType host_desktop_type) { |
| 339 return IsAppsShortcutEnabled(profile, host_desktop_type) && | 340 return IsAppsShortcutEnabled(profile, host_desktop_type) && |
| 340 profile->GetPrefs()->GetBoolean(prefs::kShowAppsShortcutInBookmarkBar); | 341 profile->GetPrefs()->GetBoolean( |
| 342 bookmarks::prefs::kShowAppsShortcutInBookmarkBar); |
| 341 } | 343 } |
| 342 | 344 |
| 343 bool ShouldRemoveBookmarkThisPageUI(Profile* profile) { | 345 bool ShouldRemoveBookmarkThisPageUI(Profile* profile) { |
| 344 return GetBookmarkShortcutDisposition(profile) == | 346 return GetBookmarkShortcutDisposition(profile) == |
| 345 BOOKMARK_SHORTCUT_DISPOSITION_REMOVED; | 347 BOOKMARK_SHORTCUT_DISPOSITION_REMOVED; |
| 346 } | 348 } |
| 347 | 349 |
| 348 bool ShouldRemoveBookmarkOpenPagesUI(Profile* profile) { | 350 bool ShouldRemoveBookmarkOpenPagesUI(Profile* profile) { |
| 349 extensions::ExtensionRegistry* registry = | 351 extensions::ExtensionRegistry* registry = |
| 350 extensions::ExtensionRegistry::Get(profile); | 352 extensions::ExtensionRegistry::Get(profile); |
| 351 if (!registry) | 353 if (!registry) |
| 352 return false; | 354 return false; |
| 353 | 355 |
| 354 const extensions::ExtensionSet& extension_set = | 356 const extensions::ExtensionSet& extension_set = |
| 355 registry->enabled_extensions(); | 357 registry->enabled_extensions(); |
| 356 | 358 |
| 357 for (extensions::ExtensionSet::const_iterator i = extension_set.begin(); | 359 for (extensions::ExtensionSet::const_iterator i = extension_set.begin(); |
| 358 i != extension_set.end(); | 360 i != extension_set.end(); |
| 359 ++i) { | 361 ++i) { |
| 360 if (extensions::CommandService::RemovesBookmarkOpenPagesShortcut(i->get())) | 362 if (extensions::CommandService::RemovesBookmarkOpenPagesShortcut(i->get())) |
| 361 return true; | 363 return true; |
| 362 } | 364 } |
| 363 | 365 |
| 364 return false; | 366 return false; |
| 365 } | 367 } |
| 366 | 368 |
| 367 } // namespace chrome | 369 } // namespace chrome |
| OLD | NEW |