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/web/web_state/web_state_impl.h" | 5 #include "ios/web/web_state/web_state_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
11 #include "ios/web/interstitials/web_interstitial_impl.h" | 11 #include "ios/web/interstitials/web_interstitial_impl.h" |
12 #import "ios/web/navigation/crw_session_controller.h" | 12 #import "ios/web/navigation/crw_session_controller.h" |
13 #import "ios/web/navigation/crw_session_entry.h" | 13 #import "ios/web/navigation/crw_session_entry.h" |
14 #include "ios/web/navigation/navigation_item_impl.h" | 14 #include "ios/web/navigation/navigation_item_impl.h" |
15 #include "ios/web/net/request_group_util.h" | 15 #include "ios/web/net/request_group_util.h" |
16 #include "ios/web/public/browser_state.h" | 16 #include "ios/web/public/browser_state.h" |
| 17 #import "ios/web/public/java_script_dialog_presenter.h" |
17 #include "ios/web/public/navigation_item.h" | 18 #include "ios/web/public/navigation_item.h" |
18 #include "ios/web/public/url_util.h" | 19 #include "ios/web/public/url_util.h" |
19 #include "ios/web/public/web_client.h" | 20 #include "ios/web/public/web_client.h" |
20 #import "ios/web/public/web_state/context_menu_params.h" | 21 #import "ios/web/public/web_state/context_menu_params.h" |
21 #include "ios/web/public/web_state/credential.h" | 22 #include "ios/web/public/web_state/credential.h" |
22 #include "ios/web/public/web_state/ui/crw_content_view.h" | 23 #include "ios/web/public/web_state/ui/crw_content_view.h" |
23 #include "ios/web/public/web_state/web_state_delegate.h" | 24 #include "ios/web/public/web_state/web_state_delegate.h" |
24 #include "ios/web/public/web_state/web_state_observer.h" | 25 #include "ios/web/public/web_state/web_state_observer.h" |
25 #include "ios/web/public/web_state/web_state_policy_decider.h" | 26 #include "ios/web/public/web_state/web_state_policy_decider.h" |
26 #include "ios/web/web_state/global_web_state_event_tracker.h" | 27 #include "ios/web/web_state/global_web_state_event_tracker.h" |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 } | 423 } |
423 } | 424 } |
424 | 425 |
425 bool WebStateImpl::HandleContextMenu(const web::ContextMenuParams& params) { | 426 bool WebStateImpl::HandleContextMenu(const web::ContextMenuParams& params) { |
426 if (delegate_) { | 427 if (delegate_) { |
427 return delegate_->HandleContextMenu(this, params); | 428 return delegate_->HandleContextMenu(this, params); |
428 } | 429 } |
429 return false; | 430 return false; |
430 } | 431 } |
431 | 432 |
| 433 void WebStateImpl::RunJavaScriptDialog( |
| 434 const GURL& origin_url, |
| 435 JavaScriptDialogType javascript_dialog_type, |
| 436 NSString* message_text, |
| 437 NSString* default_prompt_text, |
| 438 const DialogClosedCallback& callback) { |
| 439 JavaScriptDialogPresenter* presenter = |
| 440 delegate_ ? delegate_->GetJavaScriptDialogPresenter(this) : nullptr; |
| 441 if (!presenter) { |
| 442 callback.Run(false, nil); |
| 443 return; |
| 444 } |
| 445 presenter->RunJavaScriptDialog(this, origin_url, javascript_dialog_type, |
| 446 message_text, default_prompt_text, callback); |
| 447 } |
| 448 |
| 449 void WebStateImpl::CancelActiveAndPendingDialogs() { |
| 450 if (delegate_) { |
| 451 JavaScriptDialogPresenter* presenter = |
| 452 delegate_->GetJavaScriptDialogPresenter(this); |
| 453 if (presenter) { |
| 454 presenter->CancelActiveAndPendingDialogs(this); |
| 455 } |
| 456 } |
| 457 } |
| 458 |
432 WebUIIOS* WebStateImpl::CreateWebUIIOS(const GURL& url) { | 459 WebUIIOS* WebStateImpl::CreateWebUIIOS(const GURL& url) { |
433 WebUIIOSControllerFactory* factory = | 460 WebUIIOSControllerFactory* factory = |
434 WebUIIOSControllerFactoryRegistry::GetInstance(); | 461 WebUIIOSControllerFactoryRegistry::GetInstance(); |
435 if (!factory) | 462 if (!factory) |
436 return NULL; | 463 return NULL; |
437 WebUIIOSImpl* web_ui = new WebUIIOSImpl(this); | 464 WebUIIOSImpl* web_ui = new WebUIIOSImpl(this); |
438 WebUIIOSController* controller = | 465 WebUIIOSController* controller = |
439 factory->CreateWebUIIOSControllerForURL(web_ui, url); | 466 factory->CreateWebUIIOSControllerForURL(web_ui, url); |
440 if (controller) { | 467 if (controller) { |
441 web_ui->SetController(controller); | 468 web_ui->SetController(controller); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 const LoadCommittedDetails& load_details) { | 690 const LoadCommittedDetails& load_details) { |
664 FOR_EACH_OBSERVER(WebStateObserver, observers_, | 691 FOR_EACH_OBSERVER(WebStateObserver, observers_, |
665 NavigationItemCommitted(load_details)); | 692 NavigationItemCommitted(load_details)); |
666 } | 693 } |
667 | 694 |
668 WebState* WebStateImpl::GetWebState() { | 695 WebState* WebStateImpl::GetWebState() { |
669 return this; | 696 return this; |
670 } | 697 } |
671 | 698 |
672 } // namespace web | 699 } // namespace web |
OLD | NEW |