OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" | 7 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "chrome/browser/event_disposition.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
14 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
15 #include "content/browser/tab_contents/navigation_controller.h" | 16 #include "content/browser/tab_contents/navigation_controller.h" |
16 #include "content/browser/tab_contents/navigation_entry.h" | 17 #include "content/browser/tab_contents/navigation_entry.h" |
17 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
18 #include "content/browser/user_metrics.h" | 19 #include "content/browser/user_metrics.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 147 } |
147 | 148 |
148 ui::MenuModel* BackForwardMenuModel::GetSubmenuModelAt(int index) const { | 149 ui::MenuModel* BackForwardMenuModel::GetSubmenuModelAt(int index) const { |
149 return NULL; | 150 return NULL; |
150 } | 151 } |
151 | 152 |
152 void BackForwardMenuModel::HighlightChangedTo(int index) { | 153 void BackForwardMenuModel::HighlightChangedTo(int index) { |
153 } | 154 } |
154 | 155 |
155 void BackForwardMenuModel::ActivatedAt(int index) { | 156 void BackForwardMenuModel::ActivatedAt(int index) { |
156 ActivatedAtWithDisposition(index, CURRENT_TAB); | 157 ActivatedAtWithFlags(index, 0); |
157 } | 158 } |
158 | 159 |
159 void BackForwardMenuModel::ActivatedAtWithDisposition( | 160 void BackForwardMenuModel::ActivatedAtWithFlags(int index, int flags) { |
160 int index, int disposition) { | |
161 DCHECK(!IsSeparator(index)); | 161 DCHECK(!IsSeparator(index)); |
162 | 162 |
163 // Execute the command for the last item: "Show Full History". | 163 // Execute the command for the last item: "Show Full History". |
164 if (index == GetItemCount() - 1) { | 164 if (index == GetItemCount() - 1) { |
165 UserMetrics::RecordComputedAction(BuildActionName("ShowFullHistory", -1)); | 165 UserMetrics::RecordComputedAction(BuildActionName("ShowFullHistory", -1)); |
166 browser_->ShowSingletonTab(GURL(chrome::kChromeUIHistoryURL)); | 166 browser_->ShowSingletonTab(GURL(chrome::kChromeUIHistoryURL)); |
167 return; | 167 return; |
168 } | 168 } |
169 | 169 |
170 // Log whether it was a history or chapter click. | 170 // Log whether it was a history or chapter click. |
171 if (index < GetHistoryItemCount()) { | 171 if (index < GetHistoryItemCount()) { |
172 UserMetrics::RecordComputedAction( | 172 UserMetrics::RecordComputedAction( |
173 BuildActionName("HistoryClick", index)); | 173 BuildActionName("HistoryClick", index)); |
174 } else { | 174 } else { |
175 UserMetrics::RecordComputedAction( | 175 UserMetrics::RecordComputedAction( |
176 BuildActionName("ChapterClick", index - GetHistoryItemCount() - 1)); | 176 BuildActionName("ChapterClick", index - GetHistoryItemCount() - 1)); |
177 } | 177 } |
178 | 178 |
179 int controller_index = MenuIndexToNavEntryIndex(index); | 179 int controller_index = MenuIndexToNavEntryIndex(index); |
180 if (!browser_->NavigateToIndexWithDisposition( | 180 WindowOpenDisposition disposition = browser::DispositionFromEventFlags(flags); |
181 controller_index, static_cast<WindowOpenDisposition>(disposition))) { | 181 if (!browser_->NavigateToIndexWithDisposition(controller_index, disposition)) |
182 NOTREACHED(); | 182 NOTREACHED(); |
183 } | |
184 } | 183 } |
185 | 184 |
186 void BackForwardMenuModel::MenuWillShow() { | 185 void BackForwardMenuModel::MenuWillShow() { |
187 UserMetrics::RecordComputedAction(BuildActionName("Popup", -1)); | 186 UserMetrics::RecordComputedAction(BuildActionName("Popup", -1)); |
188 requested_favicons_.clear(); | 187 requested_favicons_.clear(); |
189 load_consumer_.CancelAllRequests(); | 188 load_consumer_.CancelAllRequests(); |
190 } | 189 } |
191 | 190 |
192 bool BackForwardMenuModel::IsSeparator(int index) const { | 191 bool BackForwardMenuModel::IsSeparator(int index) const { |
193 int history_items = GetHistoryItemCount(); | 192 int history_items = GetHistoryItemCount(); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 metric_string += "ForwardMenu_"; | 446 metric_string += "ForwardMenu_"; |
448 else | 447 else |
449 metric_string += "BackMenu_"; | 448 metric_string += "BackMenu_"; |
450 metric_string += action; | 449 metric_string += action; |
451 if (index != -1) { | 450 if (index != -1) { |
452 // +1 is for historical reasons (indices used to start at 1). | 451 // +1 is for historical reasons (indices used to start at 1). |
453 metric_string += base::IntToString(index + 1); | 452 metric_string += base::IntToString(index + 1); |
454 } | 453 } |
455 return metric_string; | 454 return metric_string; |
456 } | 455 } |
OLD | NEW |