Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(588)

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller_dependency_factory.mm

Issue 2588713002: Upstream Chrome on iOS source code [4/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h"
6
7 #import <PassKit/PassKit.h>
8
9 #include "base/ios/ios_util.h"
10 #include "components/infobars/core/infobar_manager.h"
11 #include "components/infobars/core/simple_alert_infobar_delegate.h"
12 #include "components/strings/grit/components_strings.h"
13 #include "components/toolbar/toolbar_model_impl.h"
14 #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
15 #import "ios/chrome/browser/tabs/tab_model.h"
16 #import "ios/chrome/browser/ui/activity_services/activity_service_controller.h"
17 #import "ios/chrome/browser/ui/activity_services/share_protocol.h"
18 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
19 #import "ios/chrome/browser/ui/key_commands_provider.h"
20 #import "ios/chrome/browser/ui/preload_controller.h"
21 #include "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h"
22 #include "ios/chrome/browser/ui/toolbar/toolbar_model_impl_ios.h"
23 #import "ios/chrome/browser/ui/toolbar/web_toolbar_controller.h"
24 #include "ios/chrome/grit/ios_strings.h"
25 #import "ios/third_party/material_components_ios/src/components/Snackbar/src/Mat erialSnackbar.h"
26 #include "ui/base/l10n/l10n_util.h"
27 #include "ui/base/l10n/l10n_util_mac.h"
28
29 NSString* const kBrowserViewControllerSnackbarCategory =
30 @"BrowserViewControllerSnackbarCategory";
31
32 @implementation BrowserViewControllerDependencyFactory
33
34 - (id)initWithBrowserState:(ios::ChromeBrowserState*)browserState {
35 self = [super init];
36 if (self) {
37 browserState_ = browserState;
38 }
39 return self;
40 }
41
42 - (id<ShareProtocol>)shareControllerInstance {
43 return [ActivityServiceController sharedInstance];
44 }
45
46 - (PKAddPassesViewController*)newPassKitViewControllerForPass:(PKPass*)pass {
47 return [[PKAddPassesViewController alloc] initWithPass:pass];
48 }
49
50 - (void)showPassKitErrorInfoBarForManager:
51 (infobars::InfoBarManager*)infoBarManager {
52 DCHECK(infoBarManager);
53 SimpleAlertInfoBarDelegate::Create(
54 infoBarManager,
55 infobars::InfoBarDelegate::SHOW_PASSKIT_INFOBAR_ERROR_DELEGATE,
56 infobars::InfoBarDelegate::kNoIconID, gfx::VectorIconId::VECTOR_ICON_NONE,
57 l10n_util::GetStringUTF16(IDS_IOS_GENERIC_PASSKIT_ERROR), true);
58 }
59
60 - (PreloadController*)newPreloadController {
61 return [[PreloadController alloc] initWithBrowserState:browserState_];
62 }
63
64 - (TabStripController*)newTabStripControllerWithTabModel:(TabModel*)model {
65 TabStrip::Style style = TabStrip::kStyleDark;
66 if (browserState_ && browserState_->IsOffTheRecord())
67 style = TabStrip::kStyleIncognito;
68 return [[TabStripController alloc] initWithTabModel:model style:style];
69 }
70
71 - (ToolbarModelIOS*)newToolbarModelIOSWithDelegate:
72 (ToolbarModelDelegateIOS*)delegate {
73 return new ToolbarModelImplIOS(delegate);
74 }
75
76 - (WebToolbarController*)
77 newWebToolbarControllerWithDelegate:(id<WebToolbarDelegate>)delegate
78 urlLoader:(id<UrlLoader>)urlLoader
79 preloadProvider:(id<PreloadProvider>)preload {
80 return [[WebToolbarController alloc] initWithDelegate:delegate
81 urlLoader:urlLoader
82 browserState:browserState_
83 preloadProvider:preload];
84 }
85
86 - (KeyCommandsProvider*)newKeyCommandsProvider {
87 return [[KeyCommandsProvider alloc] init];
88 }
89
90 - (void)showSnackbarWithMessage:(NSString*)text {
91 MDCSnackbarMessage* message = [MDCSnackbarMessage messageWithText:text];
92 message.accessibilityLabel = text;
93 message.duration = 2.0;
94 message.category = kBrowserViewControllerSnackbarCategory;
95 [MDCSnackbarManager showMessage:message];
96 }
97
98 - (AlertCoordinator*)alertCoordinatorWithTitle:(NSString*)title
99 message:(NSString*)message
100 viewController:
101 (UIViewController*)viewController {
102 AlertCoordinator* alertCoordinator = [[[AlertCoordinator alloc]
103 initWithBaseViewController:viewController
104 title:title
105 message:message] autorelease];
106 [alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_OK)
107 action:nil
108 style:UIAlertActionStyleDefault];
109 return alertCoordinator;
110 }
111
112 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698