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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.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 11 matching lines...) Expand all Loading... |
22 #include "content/public/browser/navigation_controller.h" | 22 #include "content/public/browser/navigation_controller.h" |
23 #include "content/public/browser/navigation_entry.h" | 23 #include "content/public/browser/navigation_entry.h" |
24 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
27 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
28 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 28 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
30 #include "ui/base/resource/resource_bundle.h" | 30 #include "ui/base/resource/resource_bundle.h" |
31 #include "ui/base/window_open_disposition.h" | 31 #include "ui/base/window_open_disposition.h" |
32 #include "ui/gfx/favicon_size.h" | |
33 #include "ui/gfx/text_elider.h" | 32 #include "ui/gfx/text_elider.h" |
34 | 33 |
35 using base::UserMetricsAction; | 34 using base::UserMetricsAction; |
36 using content::NavigationController; | 35 using content::NavigationController; |
37 using content::NavigationEntry; | 36 using content::NavigationEntry; |
38 using content::WebContents; | 37 using content::WebContents; |
39 | 38 |
40 const int BackForwardMenuModel::kMaxHistoryItems = 12; | 39 const int BackForwardMenuModel::kMaxHistoryItems = 12; |
41 const int BackForwardMenuModel::kMaxChapterStops = 5; | 40 const int BackForwardMenuModel::kMaxChapterStops = 5; |
42 static const int kMaxWidth = 700; | 41 static const int kMaxWidth = 700; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 requested_favicons_.end()) { | 247 requested_favicons_.end()) { |
249 return; | 248 return; |
250 } | 249 } |
251 requested_favicons_.insert(entry->GetUniqueID()); | 250 requested_favicons_.insert(entry->GetUniqueID()); |
252 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( | 251 FaviconService* favicon_service = FaviconServiceFactory::GetForProfile( |
253 browser_->profile(), Profile::EXPLICIT_ACCESS); | 252 browser_->profile(), Profile::EXPLICIT_ACCESS); |
254 if (!favicon_service) | 253 if (!favicon_service) |
255 return; | 254 return; |
256 | 255 |
257 favicon_service->GetFaviconImageForPageURL( | 256 favicon_service->GetFaviconImageForPageURL( |
258 FaviconService::FaviconForPageURLParams( | 257 entry->GetURL(), |
259 entry->GetURL(), favicon_base::FAVICON, gfx::kFaviconSize), | |
260 base::Bind(&BackForwardMenuModel::OnFavIconDataAvailable, | 258 base::Bind(&BackForwardMenuModel::OnFavIconDataAvailable, |
261 base::Unretained(this), | 259 base::Unretained(this), |
262 entry->GetUniqueID()), | 260 entry->GetUniqueID()), |
263 &cancelable_task_tracker_); | 261 &cancelable_task_tracker_); |
264 } | 262 } |
265 | 263 |
266 void BackForwardMenuModel::OnFavIconDataAvailable( | 264 void BackForwardMenuModel::OnFavIconDataAvailable( |
267 int navigation_entry_unique_id, | 265 int navigation_entry_unique_id, |
268 const favicon_base::FaviconImageResult& image_result) { | 266 const favicon_base::FaviconImageResult& image_result) { |
269 if (!image_result.image.IsEmpty()) { | 267 if (!image_result.image.IsEmpty()) { |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 metric_string += "ForwardMenu_"; | 472 metric_string += "ForwardMenu_"; |
475 else | 473 else |
476 metric_string += "BackMenu_"; | 474 metric_string += "BackMenu_"; |
477 metric_string += action; | 475 metric_string += action; |
478 if (index != -1) { | 476 if (index != -1) { |
479 // +1 is for historical reasons (indices used to start at 1). | 477 // +1 is for historical reasons (indices used to start at 1). |
480 metric_string += base::IntToString(index + 1); | 478 metric_string += base::IntToString(index + 1); |
481 } | 479 } |
482 return metric_string; | 480 return metric_string; |
483 } | 481 } |
OLD | NEW |