OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" | 5 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" |
6 | 6 |
7 #import <QuartzCore/QuartzCore.h> | 7 #import <QuartzCore/QuartzCore.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/user_metrics.h" | 10 #include "base/metrics/user_metrics.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 @interface ToolsPopupController ()<ToolsPopupTableDelegate> { | 39 @interface ToolsPopupController ()<ToolsPopupTableDelegate> { |
40 ToolsMenuViewController* _toolsMenuViewController; | 40 ToolsMenuViewController* _toolsMenuViewController; |
41 // Container view of the menu items table. | 41 // Container view of the menu items table. |
42 UIView* _toolsTableViewContainer; | 42 UIView* _toolsTableViewContainer; |
43 } | 43 } |
44 @end | 44 @end |
45 | 45 |
46 @implementation ToolsPopupController | 46 @implementation ToolsPopupController |
47 @synthesize isCurrentPageBookmarked = _isCurrentPageBookmarked; | 47 @synthesize isCurrentPageBookmarked = _isCurrentPageBookmarked; |
48 | 48 |
49 - (instancetype)initWithConfiguration:(ToolsMenuConfiguration*)configuration { | 49 - (instancetype)initWithConfiguration:(ToolsMenuConfiguration*)configuration |
| 50 dispatcher:(id<BrowserCommands>)dispatcher { |
50 DCHECK(configuration.displayView); | 51 DCHECK(configuration.displayView); |
51 self = [super initWithParentView:configuration.displayView]; | 52 self = [super initWithParentView:configuration.displayView]; |
52 if (self) { | 53 if (self) { |
| 54 // Set superclass dispatcher property. |
| 55 self.dispatcher = dispatcher; |
53 _toolsMenuViewController = [[ToolsMenuViewController alloc] init]; | 56 _toolsMenuViewController = [[ToolsMenuViewController alloc] init]; |
| 57 _toolsMenuViewController.dispatcher = self.dispatcher; |
| 58 |
54 _toolsTableViewContainer = [_toolsMenuViewController view]; | 59 _toolsTableViewContainer = [_toolsMenuViewController view]; |
55 [_toolsTableViewContainer layer].cornerRadius = 2; | 60 [_toolsTableViewContainer layer].cornerRadius = 2; |
56 [_toolsTableViewContainer layer].masksToBounds = YES; | 61 [_toolsTableViewContainer layer].masksToBounds = YES; |
57 [_toolsMenuViewController initializeMenuWithConfiguration:configuration]; | 62 [_toolsMenuViewController initializeMenuWithConfiguration:configuration]; |
58 | 63 |
59 UIEdgeInsets popupInsets = TabHistoryPopupMenuInsets(); | 64 UIEdgeInsets popupInsets = TabHistoryPopupMenuInsets(); |
60 CGFloat popupWidth = kToolsPopupMenuWidth; | 65 CGFloat popupWidth = kToolsPopupMenuWidth; |
61 | 66 |
62 CGPoint origin = CGPointMake(CGRectGetMidX(configuration.sourceRect), | 67 CGPoint origin = CGPointMake(CGRectGetMidX(configuration.sourceRect), |
63 CGRectGetMidY(configuration.sourceRect)); | 68 CGRectGetMidY(configuration.sourceRect)); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 break; | 182 break; |
178 case IDC_NEW_INCOGNITO_TAB: | 183 case IDC_NEW_INCOGNITO_TAB: |
179 base::RecordAction(UserMetricsAction("MobileMenuNewIncognitoTab")); | 184 base::RecordAction(UserMetricsAction("MobileMenuNewIncognitoTab")); |
180 break; | 185 break; |
181 case IDC_NEW_TAB: | 186 case IDC_NEW_TAB: |
182 base::RecordAction(UserMetricsAction("MobileMenuNewTab")); | 187 base::RecordAction(UserMetricsAction("MobileMenuNewTab")); |
183 break; | 188 break; |
184 case IDC_OPTIONS: | 189 case IDC_OPTIONS: |
185 base::RecordAction(UserMetricsAction("MobileMenuSettings")); | 190 base::RecordAction(UserMetricsAction("MobileMenuSettings")); |
186 break; | 191 break; |
187 case IDC_RELOAD: | 192 case TOOLS_RELAOD_ITEM: |
188 base::RecordAction(UserMetricsAction("MobileMenuReload")); | 193 base::RecordAction(UserMetricsAction("MobileMenuReload")); |
189 break; | 194 break; |
190 case IDC_SHARE_PAGE: | 195 case IDC_SHARE_PAGE: |
191 base::RecordAction(UserMetricsAction("MobileMenuShare")); | 196 base::RecordAction(UserMetricsAction("MobileMenuShare")); |
192 break; | 197 break; |
193 case IDC_REQUEST_DESKTOP_SITE: | 198 case IDC_REQUEST_DESKTOP_SITE: |
194 base::RecordAction(UserMetricsAction("MobileMenuRequestDesktopSite")); | 199 base::RecordAction(UserMetricsAction("MobileMenuRequestDesktopSite")); |
195 break; | 200 break; |
196 case IDC_REQUEST_MOBILE_SITE: | 201 case IDC_REQUEST_MOBILE_SITE: |
197 base::RecordAction(UserMetricsAction("MobileMenuRequestMobileSite")); | 202 base::RecordAction(UserMetricsAction("MobileMenuRequestMobileSite")); |
198 break; | 203 break; |
199 case IDC_READER_MODE: | 204 case IDC_READER_MODE: |
200 base::RecordAction(UserMetricsAction("MobileMenuRequestReaderMode")); | 205 base::RecordAction(UserMetricsAction("MobileMenuRequestReaderMode")); |
201 break; | 206 break; |
202 case IDC_SHOW_BOOKMARK_MANAGER: | 207 case IDC_SHOW_BOOKMARK_MANAGER: |
203 base::RecordAction(UserMetricsAction("MobileMenuAllBookmarks")); | 208 base::RecordAction(UserMetricsAction("MobileMenuAllBookmarks")); |
204 break; | 209 break; |
205 case IDC_SHOW_HISTORY: | 210 case IDC_SHOW_HISTORY: |
206 base::RecordAction(UserMetricsAction("MobileMenuHistory")); | 211 base::RecordAction(UserMetricsAction("MobileMenuHistory")); |
207 break; | 212 break; |
208 case IDC_SHOW_OTHER_DEVICES: | 213 case IDC_SHOW_OTHER_DEVICES: |
209 base::RecordAction(UserMetricsAction("MobileMenuRecentTabs")); | 214 base::RecordAction(UserMetricsAction("MobileMenuRecentTabs")); |
210 break; | 215 break; |
211 case IDC_STOP: | 216 case TOOLS_STOP_ITEM: |
212 base::RecordAction(UserMetricsAction("MobileMenuStop")); | 217 base::RecordAction(UserMetricsAction("MobileMenuStop")); |
213 break; | 218 break; |
214 case IDC_PRINT: | 219 case IDC_PRINT: |
215 base::RecordAction(UserMetricsAction("MobileMenuPrint")); | 220 base::RecordAction(UserMetricsAction("MobileMenuPrint")); |
216 break; | 221 break; |
217 case IDC_REPORT_AN_ISSUE: | 222 case IDC_REPORT_AN_ISSUE: |
218 self.containerView.hidden = YES; | 223 self.containerView.hidden = YES; |
219 base::RecordAction(UserMetricsAction("MobileMenuReportAnIssue")); | 224 base::RecordAction(UserMetricsAction("MobileMenuReportAnIssue")); |
220 break; | 225 break; |
221 case IDC_VIEW_SOURCE: | 226 case IDC_VIEW_SOURCE: |
222 // Debug only; no metric. | 227 // Debug only; no metric. |
223 break; | 228 break; |
224 case IDC_SHOW_TOOLS_MENU: | 229 case IDC_SHOW_TOOLS_MENU: |
225 // Do nothing when tapping the tools menu a second time. | 230 // Do nothing when tapping the tools menu a second time. |
226 break; | 231 break; |
227 case IDC_SHOW_READING_LIST: | 232 case IDC_SHOW_READING_LIST: |
228 base::RecordAction(UserMetricsAction("MobileMenuReadingList")); | 233 base::RecordAction(UserMetricsAction("MobileMenuReadingList")); |
229 break; | 234 break; |
230 default: | 235 default: |
231 NOTREACHED(); | 236 NOTREACHED(); |
232 break; | 237 break; |
233 } | 238 } |
234 | 239 |
235 // Close the menu. | 240 // Close the menu. |
236 [self.delegate dismissPopupMenu:self]; | 241 [self.delegate dismissPopupMenu:self]; |
237 } | 242 } |
238 | 243 |
239 @end | 244 @end |
OLD | NEW |