OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/history/history_panel_view_controller.h" | 5 #import "ios/chrome/browser/ui/history/history_panel_view_controller.h" |
6 | 6 |
7 #include "base/ios/block_types.h" | 7 #include "base/ios/block_types.h" |
8 #include "base/ios/ios_util.h" | 8 #include "base/ios/ios_util.h" |
9 #include "base/ios/weak_nsobject.h" | 9 #include "base/ios/weak_nsobject.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 11 #include "base/metrics/user_metrics.h" |
| 12 #include "base/metrics/user_metrics_action.h" |
11 #include "components/strings/grit/components_strings.h" | 13 #include "components/strings/grit/components_strings.h" |
12 #import "ios/chrome/browser/ui/history/clear_browsing_bar.h" | 14 #import "ios/chrome/browser/ui/history/clear_browsing_bar.h" |
13 #import "ios/chrome/browser/ui/history/history_collection_view_controller.h" | 15 #import "ios/chrome/browser/ui/history/history_collection_view_controller.h" |
14 #import "ios/chrome/browser/ui/history/history_search_view_controller.h" | 16 #import "ios/chrome/browser/ui/history/history_search_view_controller.h" |
15 #import "ios/chrome/browser/ui/icons/chrome_icon.h" | 17 #import "ios/chrome/browser/ui/icons/chrome_icon.h" |
16 #import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h" | 18 #import "ios/chrome/browser/ui/keyboard/UIKeyCommand+Chrome.h" |
17 #import "ios/chrome/browser/ui/material_components/utils.h" | 19 #import "ios/chrome/browser/ui/material_components/utils.h" |
18 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/panel_bar_view.h" | 20 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/panel_bar_view.h" |
19 #import "ios/chrome/browser/ui/show_privacy_settings_util.h" | 21 #import "ios/chrome/browser/ui/show_privacy_settings_util.h" |
20 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 22 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 [self closeHistoryWithCompletion:nil]; | 302 [self closeHistoryWithCompletion:nil]; |
301 } | 303 } |
302 | 304 |
303 - (void)closeHistoryWithCompletion:(ProceduralBlock)completion { | 305 - (void)closeHistoryWithCompletion:(ProceduralBlock)completion { |
304 [self.presentingViewController dismissViewControllerAnimated:YES | 306 [self.presentingViewController dismissViewControllerAnimated:YES |
305 completion:completion]; | 307 completion:completion]; |
306 } | 308 } |
307 | 309 |
308 - (void)openPrivacySettings { | 310 - (void)openPrivacySettings { |
309 [self exitSearchMode]; | 311 [self exitSearchMode]; |
| 312 base::RecordAction( |
| 313 base::UserMetricsAction("HistoryPage_InitClearBrowsingData")); |
310 ShowClearBrowsingData(); | 314 ShowClearBrowsingData(); |
311 } | 315 } |
312 | 316 |
313 - (void)enterEditingMode { | 317 - (void)enterEditingMode { |
314 [_historyCollectionController setEditing:YES]; | 318 [_historyCollectionController setEditing:YES]; |
315 [_clearBrowsingBar setEditing:YES]; | 319 [_clearBrowsingBar setEditing:YES]; |
316 if (_historyCollectionController.get().searching) { | 320 if (_historyCollectionController.get().searching) { |
317 [_searchViewController setEnabled:NO]; | 321 [_searchViewController setEnabled:NO]; |
318 } | 322 } |
319 DCHECK([_historyCollectionController isEditing]); | 323 DCHECK([_historyCollectionController isEditing]); |
320 [self configureNavigationBar]; | 324 [self configureNavigationBar]; |
321 } | 325 } |
322 | 326 |
323 - (void)exitEditingMode { | 327 - (void)exitEditingMode { |
324 [_historyCollectionController setEditing:NO]; | 328 [_historyCollectionController setEditing:NO]; |
325 [_clearBrowsingBar setEditing:NO]; | 329 [_clearBrowsingBar setEditing:NO]; |
326 if (_historyCollectionController.get().searching) { | 330 if (_historyCollectionController.get().searching) { |
327 [_searchViewController setEnabled:YES]; | 331 [_searchViewController setEnabled:YES]; |
328 } | 332 } |
329 DCHECK(![_historyCollectionController isEditing]); | 333 DCHECK(![_historyCollectionController isEditing]); |
330 [self configureNavigationBar]; | 334 [self configureNavigationBar]; |
331 } | 335 } |
332 | 336 |
333 - (void)deleteSelectedItems { | 337 - (void)deleteSelectedItems { |
334 [_historyCollectionController deleteSelectedItemsFromHistory]; | 338 [_historyCollectionController deleteSelectedItemsFromHistory]; |
| 339 base::RecordAction(base::UserMetricsAction("HistoryPage_RemoveSelected")); |
335 [self exitEditingMode]; | 340 [self exitEditingMode]; |
336 } | 341 } |
337 - (void)enterSearchMode { | 342 - (void)enterSearchMode { |
338 if (!_searchViewController) { | 343 if (!_searchViewController) { |
339 _searchViewController.reset([[HistorySearchViewController alloc] init]); | 344 _searchViewController.reset([[HistorySearchViewController alloc] init]); |
340 [_searchViewController setDelegate:self]; | 345 [_searchViewController setDelegate:self]; |
341 } | 346 } |
342 | 347 |
343 UIView* searchBarView = [_searchViewController view]; | 348 UIView* searchBarView = [_searchViewController view]; |
344 [_searchViewController willMoveToParentViewController:self]; | 349 [_searchViewController willMoveToParentViewController:self]; |
345 [self.view addSubview:searchBarView]; | 350 [self.view addSubview:searchBarView]; |
346 _historyCollectionController.get().searching = YES; | 351 _historyCollectionController.get().searching = YES; |
347 [_searchViewController didMoveToParentViewController:self]; | 352 [_searchViewController didMoveToParentViewController:self]; |
| 353 base::RecordAction(base::UserMetricsAction("HistoryPage_Search")); |
348 | 354 |
349 // Constraints to make search bar cover header. | 355 // Constraints to make search bar cover header. |
350 [searchBarView setTranslatesAutoresizingMaskIntoConstraints:NO]; | 356 [searchBarView setTranslatesAutoresizingMaskIntoConstraints:NO]; |
351 MDCFlexibleHeaderView* headerView = | 357 MDCFlexibleHeaderView* headerView = |
352 _appBar.get().headerViewController.headerView; | 358 _appBar.get().headerViewController.headerView; |
353 NSArray* constraints = @[ | 359 NSArray* constraints = @[ |
354 [[searchBarView topAnchor] constraintEqualToAnchor:headerView.topAnchor], | 360 [[searchBarView topAnchor] constraintEqualToAnchor:headerView.topAnchor], |
355 [[searchBarView leadingAnchor] | 361 [[searchBarView leadingAnchor] |
356 constraintEqualToAnchor:headerView.leadingAnchor], | 362 constraintEqualToAnchor:headerView.leadingAnchor], |
357 [[searchBarView heightAnchor] | 363 [[searchBarView heightAnchor] |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 base::WeakNSObject<HistoryPanelViewController> weakSelf(self); | 408 base::WeakNSObject<HistoryPanelViewController> weakSelf(self); |
403 return @[ [UIKeyCommand cr_keyCommandWithInput:UIKeyInputEscape | 409 return @[ [UIKeyCommand cr_keyCommandWithInput:UIKeyInputEscape |
404 modifierFlags:Cr_UIKeyModifierNone | 410 modifierFlags:Cr_UIKeyModifierNone |
405 title:nil | 411 title:nil |
406 action:^{ | 412 action:^{ |
407 [weakSelf closeHistory]; | 413 [weakSelf closeHistory]; |
408 }] ]; | 414 }] ]; |
409 } | 415 } |
410 | 416 |
411 @end | 417 @end |
OLD | NEW |