| 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/toolbar/back_forward_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/favicon/favicon_service_factory.h" | 13 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 14 #include "chrome/browser/profiles/profile.h" | |
| 15 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 16 #include "chrome/browser/ui/browser_commands.h" | 15 #include "chrome/browser/ui/browser_commands.h" |
| 17 #include "chrome/browser/ui/browser_navigator_params.h" | 16 #include "chrome/browser/ui/browser_navigator_params.h" |
| 18 #include "chrome/browser/ui/singleton_tabs.h" | 17 #include "chrome/browser/ui/singleton_tabs.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/common/pref_names.h" | |
| 21 #include "chrome/common/url_constants.h" | 19 #include "chrome/common/url_constants.h" |
| 22 #include "components/favicon_base/favicon_types.h" | 20 #include "components/favicon_base/favicon_types.h" |
| 23 #include "components/prefs/pref_service.h" | |
| 24 #include "components/strings/grit/components_strings.h" | 21 #include "components/strings/grit/components_strings.h" |
| 25 #include "content/public/browser/favicon_status.h" | 22 #include "content/public/browser/favicon_status.h" |
| 26 #include "content/public/browser/navigation_controller.h" | 23 #include "content/public/browser/navigation_controller.h" |
| 27 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
| 28 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
| 29 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 30 #include "grit/components_scaled_resources.h" | 27 #include "grit/components_scaled_resources.h" |
| 31 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 28 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 32 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 33 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (index == GetItemCount() - 1) | 94 if (index == GetItemCount() - 1) |
| 98 return l10n_util::GetStringUTF16(IDS_HISTORY_SHOWFULLHISTORY_LINK); | 95 return l10n_util::GetStringUTF16(IDS_HISTORY_SHOWFULLHISTORY_LINK); |
| 99 | 96 |
| 100 // Return an empty string for a separator. | 97 // Return an empty string for a separator. |
| 101 if (IsSeparator(index)) | 98 if (IsSeparator(index)) |
| 102 return base::string16(); | 99 return base::string16(); |
| 103 | 100 |
| 104 // Return the entry title, escaping any '&' characters and eliding it if it's | 101 // Return the entry title, escaping any '&' characters and eliding it if it's |
| 105 // super long. | 102 // super long. |
| 106 NavigationEntry* entry = GetNavigationEntry(index); | 103 NavigationEntry* entry = GetNavigationEntry(index); |
| 107 Profile* profile = | 104 base::string16 menu_text(entry->GetTitleForDisplay()); |
| 108 Profile::FromBrowserContext(GetWebContents()->GetBrowserContext()); | |
| 109 base::string16 menu_text(entry->GetTitleForDisplay( | |
| 110 profile->GetPrefs()->GetString(prefs::kAcceptLanguages))); | |
| 111 menu_text = | 105 menu_text = |
| 112 gfx::ElideText(menu_text, gfx::FontList(), kMaxWidth, gfx::ELIDE_TAIL); | 106 gfx::ElideText(menu_text, gfx::FontList(), kMaxWidth, gfx::ELIDE_TAIL); |
| 113 | 107 |
| 114 #if !defined(OS_MACOSX) | 108 #if !defined(OS_MACOSX) |
| 115 for (size_t i = menu_text.find('&'); i != base::string16::npos; | 109 for (size_t i = menu_text.find('&'); i != base::string16::npos; |
| 116 i = menu_text.find('&', i + 2)) { | 110 i = menu_text.find('&', i + 2)) { |
| 117 menu_text.insert(i, 1, '&'); | 111 menu_text.insert(i, 1, '&'); |
| 118 } | 112 } |
| 119 #endif | 113 #endif |
| 120 | 114 |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 metric_string += "ForwardMenu_"; | 470 metric_string += "ForwardMenu_"; |
| 477 else | 471 else |
| 478 metric_string += "BackMenu_"; | 472 metric_string += "BackMenu_"; |
| 479 metric_string += action; | 473 metric_string += action; |
| 480 if (index != -1) { | 474 if (index != -1) { |
| 481 // +1 is for historical reasons (indices used to start at 1). | 475 // +1 is for historical reasons (indices used to start at 1). |
| 482 metric_string += base::IntToString(index + 1); | 476 metric_string += base::IntToString(index + 1); |
| 483 } | 477 } |
| 484 return metric_string; | 478 return metric_string; |
| 485 } | 479 } |
| OLD | NEW |