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/web/web_state/web_state_impl.h" | 5 #import "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/logging.h" | 10 #include "base/logging.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 #include "ios/web/public/web_thread.h" | 30 #include "ios/web/public/web_thread.h" |
31 #include "ios/web/public/webui/web_ui_ios_controller.h" | 31 #include "ios/web/public/webui/web_ui_ios_controller.h" |
32 #include "ios/web/web_state/global_web_state_event_tracker.h" | 32 #include "ios/web/web_state/global_web_state_event_tracker.h" |
33 #import "ios/web/web_state/navigation_context_impl.h" | 33 #import "ios/web/web_state/navigation_context_impl.h" |
34 #import "ios/web/web_state/session_certificate_policy_cache_impl.h" | 34 #import "ios/web/web_state/session_certificate_policy_cache_impl.h" |
35 #import "ios/web/web_state/ui/crw_web_controller.h" | 35 #import "ios/web/web_state/ui/crw_web_controller.h" |
36 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" | 36 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" |
37 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" | 37 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" |
38 #include "ios/web/webui/web_ui_ios_impl.h" | 38 #include "ios/web/webui/web_ui_ios_impl.h" |
39 #include "net/http/http_response_headers.h" | 39 #include "net/http/http_response_headers.h" |
40 #include "ui/gfx/image/image.h" | |
40 | 41 |
41 namespace web { | 42 namespace web { |
42 | 43 |
43 /* static */ | 44 /* static */ |
44 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { | 45 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { |
45 std::unique_ptr<WebStateImpl> web_state(new WebStateImpl(params)); | 46 std::unique_ptr<WebStateImpl> web_state(new WebStateImpl(params)); |
46 | 47 |
47 // Initialize the new session. | 48 // Initialize the new session. |
48 web_state->GetNavigationManagerImpl().InitializeSession(); | 49 web_state->GetNavigationManagerImpl().InitializeSession(); |
49 | 50 |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
663 } | 664 } |
664 | 665 |
665 id<CRWWebViewProxy> WebStateImpl::GetWebViewProxy() const { | 666 id<CRWWebViewProxy> WebStateImpl::GetWebViewProxy() const { |
666 return [web_controller_ webViewProxy]; | 667 return [web_controller_ webViewProxy]; |
667 } | 668 } |
668 | 669 |
669 bool WebStateImpl::HasOpener() const { | 670 bool WebStateImpl::HasOpener() const { |
670 return created_with_opener_; | 671 return created_with_opener_; |
671 } | 672 } |
672 | 673 |
674 void WebStateImpl::TakeSnapshot( | |
675 const base::Callback<void(const gfx::Image& snapshot)>& callback) const { | |
marq (ping after 24h)
2017/06/21 11:13:23
The CL description describes this method as asynch
rohitrao (ping after 24h)
2017/06/21 11:38:15
Should we post callback to the current TaskRunner,
edchin
2017/06/21 16:57:24
I'll implement Rohit's suggestion for now. The ios
Eugene But (OOO till 7-30)
2017/06/21 22:11:29
I believe the API should be either always synchron
edchin
2017/06/22 07:01:07
Made pre-ios-11 also asynchronous using SequencedT
| |
676 UIView* view = [web_controller_ view]; | |
677 if (!view || CGRectIsEmpty(view.bounds)) { | |
678 callback.Run(gfx::Image()); | |
679 return; | |
680 } | |
681 UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, 0); | |
marq (ping after 24h)
2017/06/21 11:13:23
Is this preferable to UIView's -snapshotViewAfterS
rohitrao (ping after 24h)
2017/06/21 11:38:15
I don't think that call actually works consistentl
edchin
2017/06/21 16:57:24
Ditto.
| |
682 [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; | |
683 UIImage* snapshot = UIGraphicsGetImageFromCurrentImageContext(); | |
684 UIGraphicsEndImageContext(); | |
685 callback.Run(gfx::Image(snapshot)); | |
marq (ping after 24h)
2017/06/21 11:13:23
What's the cost of converting to/from a gfx::Image
rohitrao (ping after 24h)
2017/06/21 11:38:15
gfx::Images are pretty cheap, as long as you don't
edchin
2017/06/21 16:57:24
There was some discussion on this on the design do
marq (ping after 24h)
2017/06/22 11:55:31
I agree that this approach is consistent with that
| |
686 } | |
687 | |
673 void WebStateImpl::OnNavigationStarted(web::NavigationContext* context) { | 688 void WebStateImpl::OnNavigationStarted(web::NavigationContext* context) { |
674 for (auto& observer : observers_) | 689 for (auto& observer : observers_) |
675 observer.DidStartNavigation(context); | 690 observer.DidStartNavigation(context); |
676 } | 691 } |
677 | 692 |
678 void WebStateImpl::OnNavigationFinished(web::NavigationContext* context) { | 693 void WebStateImpl::OnNavigationFinished(web::NavigationContext* context) { |
679 for (auto& observer : observers_) | 694 for (auto& observer : observers_) |
680 observer.DidFinishNavigation(context); | 695 observer.DidFinishNavigation(context); |
681 } | 696 } |
682 | 697 |
(...skipping 26 matching lines...) Expand all Loading... | |
709 const LoadCommittedDetails& load_details) { | 724 const LoadCommittedDetails& load_details) { |
710 for (auto& observer : observers_) | 725 for (auto& observer : observers_) |
711 observer.NavigationItemCommitted(load_details); | 726 observer.NavigationItemCommitted(load_details); |
712 } | 727 } |
713 | 728 |
714 WebState* WebStateImpl::GetWebState() { | 729 WebState* WebStateImpl::GetWebState() { |
715 return this; | 730 return this; |
716 } | 731 } |
717 | 732 |
718 } // namespace web | 733 } // namespace web |
OLD | NEW |