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/clean/chrome/browser/ui/web_contents/web_coordinator.h" | 5 #import "ios/clean/chrome/browser/ui/web_contents/web_coordinator.h" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" | 9 #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" |
10 #import "ios/clean/chrome/browser/ui/commands/overlay_commands.h" | 10 #import "ios/clean/chrome/browser/ui/commands/overlay_commands.h" |
11 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" | 11 #import "ios/clean/chrome/browser/ui/context_menu/context_menu_context_impl.h" |
12 #import "ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.h
" | 12 #import "ios/clean/chrome/browser/ui/context_menu/web_context_menu_coordinator.h
" |
| 13 #import "ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_
coordinator.h" |
| 14 #import "ios/clean/chrome/browser/ui/dialogs/http_auth_dialogs/http_auth_dialog_
state.h" |
13 #import "ios/clean/chrome/browser/ui/overlays/overlay_queue.h" | 15 #import "ios/clean/chrome/browser/ui/overlays/overlay_queue.h" |
14 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" | 16 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_mediator.h" |
15 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h
" | 17 #import "ios/clean/chrome/browser/ui/web_contents/web_contents_view_controller.h
" |
16 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" | 18 #import "ios/shared/chrome/browser/ui/browser_list/browser.h" |
17 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" | 19 #import "ios/shared/chrome/browser/ui/commands/command_dispatcher.h" |
18 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" | 20 #import "ios/shared/chrome/browser/ui/coordinators/browser_coordinator+internal.
h" |
19 #include "ios/web/public/navigation_manager.h" | 21 #include "ios/web/public/navigation_manager.h" |
20 #include "ios/web/public/web_state/web_state.h" | 22 #include "ios/web/public/web_state/web_state.h" |
21 #import "ios/web/public/web_state/web_state_delegate_bridge.h" | 23 #import "ios/web/public/web_state/web_state_delegate_bridge.h" |
22 | 24 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 handleContextMenu:(const web::ContextMenuParams&)params { | 129 handleContextMenu:(const web::ContextMenuParams&)params { |
128 ContextMenuContextImpl* context = | 130 ContextMenuContextImpl* context = |
129 [[ContextMenuContextImpl alloc] initWithParams:params]; | 131 [[ContextMenuContextImpl alloc] initWithParams:params]; |
130 WebContextMenuCoordinator* contextMenu = | 132 WebContextMenuCoordinator* contextMenu = |
131 [[WebContextMenuCoordinator alloc] initWithContext:context]; | 133 [[WebContextMenuCoordinator alloc] initWithContext:context]; |
132 [self addChildCoordinator:contextMenu]; | 134 [self addChildCoordinator:contextMenu]; |
133 [contextMenu start]; | 135 [contextMenu start]; |
134 return YES; | 136 return YES; |
135 } | 137 } |
136 | 138 |
| 139 - (void)webState:(web::WebState*)webState |
| 140 didRequestHTTPAuthForProtectionSpace:(NSURLProtectionSpace*)protectionSpace |
| 141 proposedCredential:(NSURLCredential*)proposedCredential |
| 142 completionHandler:(void (^)(NSString* username, |
| 143 NSString* password))handler { |
| 144 HTTPAuthDialogState* state = |
| 145 [HTTPAuthDialogState stateWithWebState:webState |
| 146 protectionSpace:protectionSpace |
| 147 credential:proposedCredential |
| 148 callback:handler]; |
| 149 HTTPAuthDialogCoordinator* coordinator = |
| 150 [[HTTPAuthDialogCoordinator alloc] initWithState:state]; |
| 151 [self createDialogHelpers]; |
| 152 OverlayQueue::FromWebState(webState)->AddOverlay(coordinator); |
| 153 } |
| 154 |
137 #pragma mark - OverlayPresentationCommands | 155 #pragma mark - OverlayPresentationCommands |
138 | 156 |
139 - (void)startNextOverlayForWebState:(web::WebState*)webState { | 157 - (void)startNextOverlayForWebState:(web::WebState*)webState { |
140 DCHECK_EQ(self.webState, webState); | 158 DCHECK_EQ(self.webState, webState); |
141 [self startNextOverlay]; | 159 [self startNextOverlay]; |
142 } | 160 } |
143 | 161 |
144 #pragma mark - | 162 #pragma mark - |
145 | 163 |
146 - (void)createDialogHelpers { | 164 - (void)createDialogHelpers { |
147 id<OverlaySchedulerCommands> overlayDispatcher = | 165 id<OverlaySchedulerCommands> overlayDispatcher = |
148 static_cast<id<OverlaySchedulerCommands>>(self.browser->dispatcher()); | 166 static_cast<id<OverlaySchedulerCommands>>(self.browser->dispatcher()); |
149 OverlayQueue::CreateForWebState(self.webState, overlayDispatcher); | 167 OverlayQueue::CreateForWebState(self.webState, overlayDispatcher); |
150 } | 168 } |
151 | 169 |
152 - (void)startNextOverlay { | 170 - (void)startNextOverlay { |
153 OverlayQueue* queue = OverlayQueue::FromWebState(self.webState); | 171 OverlayQueue* queue = OverlayQueue::FromWebState(self.webState); |
154 if (queue->HasQueuedOverlays() && !queue->IsShowingOverlay()) | 172 if (queue->HasQueuedOverlays() && !queue->IsShowingOverlay()) |
155 queue->StartNextOverlay(self); | 173 queue->StartNextOverlay(self); |
156 } | 174 } |
157 | 175 |
158 @end | 176 @end |
OLD | NEW |