OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ntp/google_landing_controller.h" | 5 #import "ios/chrome/browser/ui/ntp/google_landing_controller.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
(...skipping 1363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 base::WeakNSObject<GoogleLandingController> weakSelf(self); | 1374 base::WeakNSObject<GoogleLandingController> weakSelf(self); |
1375 action = ^{ | 1375 action = ^{ |
1376 base::scoped_nsobject<GoogleLandingController> strongSelf( | 1376 base::scoped_nsobject<GoogleLandingController> strongSelf( |
1377 [weakSelf retain]); | 1377 [weakSelf retain]); |
1378 if (!strongSelf) | 1378 if (!strongSelf) |
1379 return; | 1379 return; |
1380 MostVisitedCell* cell = (MostVisitedCell*)sender.view; | 1380 MostVisitedCell* cell = (MostVisitedCell*)sender.view; |
1381 [strongSelf logMostVisitedClick:index tileType:cell.tileType]; | 1381 [strongSelf logMostVisitedClick:index tileType:cell.tileType]; |
1382 [[strongSelf loader] webPageOrderedOpen:url | 1382 [[strongSelf loader] webPageOrderedOpen:url |
1383 referrer:web::Referrer() | 1383 referrer:web::Referrer() |
1384 windowName:nil | |
1385 inBackground:YES | 1384 inBackground:YES |
1386 appendTo:kCurrentTab]; | 1385 appendTo:kCurrentTab]; |
1387 }; | 1386 }; |
1388 [_contextMenuCoordinator | 1387 [_contextMenuCoordinator |
1389 addItemWithTitle:l10n_util::GetNSStringWithFixup( | 1388 addItemWithTitle:l10n_util::GetNSStringWithFixup( |
1390 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB) | 1389 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWTAB) |
1391 action:action]; | 1390 action:action]; |
1392 | 1391 |
1393 if (!_browserState->IsOffTheRecord()) { | 1392 if (!_browserState->IsOffTheRecord()) { |
1394 // Open in Incognito Tab. | 1393 // Open in Incognito Tab. |
1395 action = ^{ | 1394 action = ^{ |
1396 base::scoped_nsobject<GoogleLandingController> strongSelf( | 1395 base::scoped_nsobject<GoogleLandingController> strongSelf( |
1397 [weakSelf retain]); | 1396 [weakSelf retain]); |
1398 if (!strongSelf) | 1397 if (!strongSelf) |
1399 return; | 1398 return; |
1400 MostVisitedCell* cell = (MostVisitedCell*)sender.view; | 1399 MostVisitedCell* cell = (MostVisitedCell*)sender.view; |
1401 [strongSelf logMostVisitedClick:index tileType:cell.tileType]; | 1400 [strongSelf logMostVisitedClick:index tileType:cell.tileType]; |
1402 [[strongSelf loader] webPageOrderedOpen:url | 1401 [[strongSelf loader] webPageOrderedOpen:url |
1403 referrer:web::Referrer() | 1402 referrer:web::Referrer() |
1404 windowName:nil | |
1405 inIncognito:YES | 1403 inIncognito:YES |
1406 inBackground:NO | 1404 inBackground:NO |
1407 appendTo:kCurrentTab]; | 1405 appendTo:kCurrentTab]; |
1408 }; | 1406 }; |
1409 [_contextMenuCoordinator | 1407 [_contextMenuCoordinator |
1410 addItemWithTitle:l10n_util::GetNSStringWithFixup( | 1408 addItemWithTitle:l10n_util::GetNSStringWithFixup( |
1411 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB) | 1409 IDS_IOS_CONTENT_CONTEXT_OPENLINKNEWINCOGNITOTAB) |
1412 action:action]; | 1410 action:action]; |
1413 } | 1411 } |
1414 | 1412 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1458 |
1461 - (void)onPromoLabelTapped { | 1459 - (void)onPromoLabelTapped { |
1462 [_focuser cancelOmniboxEdit]; | 1460 [_focuser cancelOmniboxEdit]; |
1463 _notification_promo->HandleClosed(); | 1461 _notification_promo->HandleClosed(); |
1464 [_promoHeaderView setHidden:YES]; | 1462 [_promoHeaderView setHidden:YES]; |
1465 [self.view setNeedsLayout]; | 1463 [self.view setNeedsLayout]; |
1466 | 1464 |
1467 if (_notification_promo->IsURLPromo()) { | 1465 if (_notification_promo->IsURLPromo()) { |
1468 [_loader webPageOrderedOpen:_notification_promo->url() | 1466 [_loader webPageOrderedOpen:_notification_promo->url() |
1469 referrer:web::Referrer() | 1467 referrer:web::Referrer() |
1470 windowName:nil | |
1471 inBackground:NO | 1468 inBackground:NO |
1472 appendTo:kCurrentTab]; | 1469 appendTo:kCurrentTab]; |
1473 _notification_promo.reset(); | 1470 _notification_promo.reset(); |
1474 return; | 1471 return; |
1475 } | 1472 } |
1476 | 1473 |
1477 if (_notification_promo->IsChromeCommand()) { | 1474 if (_notification_promo->IsChromeCommand()) { |
1478 base::scoped_nsobject<GenericChromeCommand> command( | 1475 base::scoped_nsobject<GenericChromeCommand> command( |
1479 [[GenericChromeCommand alloc] | 1476 [[GenericChromeCommand alloc] |
1480 initWithTag:_notification_promo->command_id()]); | 1477 initWithTag:_notification_promo->command_id()]); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1744 if (!view) { | 1741 if (!view) { |
1745 return nil; | 1742 return nil; |
1746 } | 1743 } |
1747 if ([view isKindOfClass:aClass]) { | 1744 if ([view isKindOfClass:aClass]) { |
1748 return view; | 1745 return view; |
1749 } | 1746 } |
1750 return [self nearestAncestorOfView:[view superview] withClass:aClass]; | 1747 return [self nearestAncestorOfView:[view superview] withClass:aClass]; |
1751 } | 1748 } |
1752 | 1749 |
1753 @end | 1750 @end |
OLD | NEW |