| 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 #include "ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.h" | 5 #include "ios/chrome/browser/native_app_launcher/native_app_infobar_delegate.h" |
| 6 | 6 |
| 7 #import <Foundation/Foundation.h> | 7 #import <Foundation/Foundation.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/mac/scoped_nsobject.h" | |
| 13 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 15 #include "components/infobars/core/infobar_manager.h" | 14 #include "components/infobars/core/infobar_manager.h" |
| 16 #import "ios/chrome/browser/native_app_launcher/native_app_infobar_controller.h" | 15 #import "ios/chrome/browser/native_app_launcher/native_app_infobar_controller.h" |
| 17 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller
_protocol.h" | 16 #import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller
_protocol.h" |
| 18 #include "ios/chrome/grit/ios_strings.h" | 17 #include "ios/chrome/grit/ios_strings.h" |
| 19 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 20 | 19 |
| 20 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 21 #error "This file requires ARC support." |
| 22 #endif |
| 23 |
| 21 namespace native_app_infobar { | 24 namespace native_app_infobar { |
| 22 const CGSize kSmallIconSize = {29.0, 29.0}; | 25 const CGSize kSmallIconSize = {29.0, 29.0}; |
| 23 } // namespace native_app_infobar | 26 } // namespace native_app_infobar |
| 24 | 27 |
| 25 NativeAppInfoBarDelegate::NativeAppInfoBarDelegate( | 28 NativeAppInfoBarDelegate::NativeAppInfoBarDelegate( |
| 26 id<NativeAppNavigationControllerProtocol> controller, | 29 id<NativeAppNavigationControllerProtocol> controller, |
| 27 const GURL& page_url, | 30 const GURL& page_url, |
| 28 NativeAppControllerType type) | 31 NativeAppControllerType type) |
| 29 : controller_(controller), page_url_(page_url), type_(type) {} | 32 : controller_(controller), page_url_(page_url), type_(type) {} |
| 30 | 33 |
| 31 NativeAppInfoBarDelegate::~NativeAppInfoBarDelegate() {} | 34 NativeAppInfoBarDelegate::~NativeAppInfoBarDelegate() {} |
| 32 | 35 |
| 33 // static | 36 // static |
| 34 bool NativeAppInfoBarDelegate::Create( | 37 bool NativeAppInfoBarDelegate::Create( |
| 35 infobars::InfoBarManager* manager, | 38 infobars::InfoBarManager* manager, |
| 36 id<NativeAppNavigationControllerProtocol> controller_protocol, | 39 id<NativeAppNavigationControllerProtocol> controller_protocol, |
| 37 const GURL& page_url, | 40 const GURL& page_url, |
| 38 NativeAppControllerType type) { | 41 NativeAppControllerType type) { |
| 39 DCHECK(manager); | 42 DCHECK(manager); |
| 40 auto infobar = | 43 auto infobar = |
| 41 base::MakeUnique<InfoBarIOS>(base::MakeUnique<NativeAppInfoBarDelegate>( | 44 base::MakeUnique<InfoBarIOS>(base::MakeUnique<NativeAppInfoBarDelegate>( |
| 42 controller_protocol, page_url, type)); | 45 controller_protocol, page_url, type)); |
| 43 base::scoped_nsobject<NativeAppInfoBarController> controller( | 46 NativeAppInfoBarController* controller = |
| 44 [[NativeAppInfoBarController alloc] initWithDelegate:infobar.get()]); | 47 [[NativeAppInfoBarController alloc] initWithDelegate:infobar.get()]; |
| 45 infobar->SetController(controller); | 48 infobar->SetController(controller); |
| 46 return !!manager->AddInfoBar(std::move(infobar)); | 49 return !!manager->AddInfoBar(std::move(infobar)); |
| 47 } | 50 } |
| 48 | 51 |
| 49 bool NativeAppInfoBarDelegate::ShouldExpire( | 52 bool NativeAppInfoBarDelegate::ShouldExpire( |
| 50 const NavigationDetails& details) const { | 53 const NavigationDetails& details) const { |
| 51 return details.is_navigation_to_different_page; | 54 return details.is_navigation_to_different_page; |
| 52 } | 55 } |
| 53 | 56 |
| 54 NativeAppInfoBarDelegate* | 57 NativeAppInfoBarDelegate* |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 case NATIVE_APP_ACTION_IGNORE: | 143 case NATIVE_APP_ACTION_IGNORE: |
| 141 case NATIVE_APP_ACTION_COUNT: | 144 case NATIVE_APP_ACTION_COUNT: |
| 142 NOTREACHED(); | 145 NOTREACHED(); |
| 143 break; | 146 break; |
| 144 } | 147 } |
| 145 } | 148 } |
| 146 | 149 |
| 147 NativeAppControllerType NativeAppInfoBarDelegate::GetControllerType() const { | 150 NativeAppControllerType NativeAppInfoBarDelegate::GetControllerType() const { |
| 148 return type_; | 151 return type_; |
| 149 } | 152 } |
| OLD | NEW |