OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <utility> | 10 #include <utility> |
(...skipping 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1021 void WebContentsImpl::UpdateDeviceScaleFactor(double device_scale_factor) { | 1021 void WebContentsImpl::UpdateDeviceScaleFactor(double device_scale_factor) { |
1022 SendPageMessage( | 1022 SendPageMessage( |
1023 new PageMsg_SetDeviceScaleFactor(MSG_ROUTING_NONE, device_scale_factor)); | 1023 new PageMsg_SetDeviceScaleFactor(MSG_ROUTING_NONE, device_scale_factor)); |
1024 } | 1024 } |
1025 | 1025 |
1026 void WebContentsImpl::GetScreenInfo(ScreenInfo* screen_info) { | 1026 void WebContentsImpl::GetScreenInfo(ScreenInfo* screen_info) { |
1027 if (GetView()) | 1027 if (GetView()) |
1028 GetView()->GetScreenInfo(screen_info); | 1028 GetView()->GetScreenInfo(screen_info); |
1029 } | 1029 } |
1030 | 1030 |
1031 WebUI* WebContentsImpl::CreateSubframeWebUI(const GURL& url, | 1031 std::unique_ptr<WebUI> WebContentsImpl::CreateSubframeWebUI( |
1032 const std::string& frame_name) { | 1032 const GURL& url, |
| 1033 const std::string& frame_name) { |
1033 DCHECK(!frame_name.empty()); | 1034 DCHECK(!frame_name.empty()); |
1034 return CreateWebUI(url, frame_name); | 1035 return CreateWebUI(url, frame_name); |
1035 } | 1036 } |
1036 | 1037 |
1037 WebUI* WebContentsImpl::GetWebUI() const { | 1038 WebUI* WebContentsImpl::GetWebUI() const { |
1038 WebUI* commited_web_ui = GetCommittedWebUI(); | 1039 WebUI* commited_web_ui = GetCommittedWebUI(); |
1039 return commited_web_ui ? commited_web_ui | 1040 return commited_web_ui ? commited_web_ui |
1040 : GetRenderManager()->GetNavigatingWebUI(); | 1041 : GetRenderManager()->GetNavigatingWebUI(); |
1041 } | 1042 } |
1042 | 1043 |
(...skipping 3769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4812 RenderViewHost* new_host) { | 4813 RenderViewHost* new_host) { |
4813 NotifyViewSwapped(old_host, new_host); | 4814 NotifyViewSwapped(old_host, new_host); |
4814 } | 4815 } |
4815 | 4816 |
4816 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 4817 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
4817 return GetController(); | 4818 return GetController(); |
4818 } | 4819 } |
4819 | 4820 |
4820 std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost( | 4821 std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUIForRenderFrameHost( |
4821 const GURL& url) { | 4822 const GURL& url) { |
4822 return std::unique_ptr<WebUIImpl>( | 4823 return CreateWebUI(url, std::string()); |
4823 static_cast<WebUIImpl*>(CreateWebUI(url, std::string()))); | |
4824 } | 4824 } |
4825 | 4825 |
4826 NavigationEntry* | 4826 NavigationEntry* |
4827 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { | 4827 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { |
4828 return controller_.GetLastCommittedEntry(); | 4828 return controller_.GetLastCommittedEntry(); |
4829 } | 4829 } |
4830 | 4830 |
4831 void WebContentsImpl::CreateRenderWidgetHostViewForRenderManager( | 4831 void WebContentsImpl::CreateRenderWidgetHostViewForRenderManager( |
4832 RenderViewHost* render_view_host) { | 4832 RenderViewHost* render_view_host) { |
4833 RenderWidgetHostViewBase* rwh_view = | 4833 RenderWidgetHostViewBase* rwh_view = |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5053 } | 5053 } |
5054 | 5054 |
5055 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 5055 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
5056 if (!delegate_) | 5056 if (!delegate_) |
5057 return; | 5057 return; |
5058 const gfx::Size new_size = GetPreferredSize(); | 5058 const gfx::Size new_size = GetPreferredSize(); |
5059 if (new_size != old_size) | 5059 if (new_size != old_size) |
5060 delegate_->UpdatePreferredSize(this, new_size); | 5060 delegate_->UpdatePreferredSize(this, new_size); |
5061 } | 5061 } |
5062 | 5062 |
5063 WebUI* WebContentsImpl::CreateWebUI(const GURL& url, | 5063 std::unique_ptr<WebUIImpl> WebContentsImpl::CreateWebUI( |
5064 const std::string& frame_name) { | 5064 const GURL& url, |
5065 WebUIImpl* web_ui = new WebUIImpl(this, frame_name); | 5065 const std::string& frame_name) { |
5066 WebUIController* controller = WebUIControllerFactoryRegistry::GetInstance()-> | 5066 std::unique_ptr<WebUIImpl> web_ui = |
5067 CreateWebUIControllerForURL(web_ui, url); | 5067 base::MakeUnique<WebUIImpl>(this, frame_name); |
| 5068 WebUIController* controller = |
| 5069 WebUIControllerFactoryRegistry::GetInstance() |
| 5070 ->CreateWebUIControllerForURL(web_ui.get(), url); |
5068 if (controller) { | 5071 if (controller) { |
5069 web_ui->AddMessageHandler(new GenericHandler()); | 5072 web_ui->AddMessageHandler(new GenericHandler()); |
5070 web_ui->SetController(controller); | 5073 web_ui->SetController(controller); |
5071 return web_ui; | 5074 return web_ui; |
5072 } | 5075 } |
5073 | 5076 |
5074 delete web_ui; | 5077 return nullptr; |
5075 return NULL; | |
5076 } | 5078 } |
5077 | 5079 |
5078 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { | 5080 FindRequestManager* WebContentsImpl::GetOrCreateFindRequestManager() { |
5079 // TODO(paulmeyer): This method will need to access (or potentially create) | 5081 // TODO(paulmeyer): This method will need to access (or potentially create) |
5080 // the FindRequestManager in the outermost WebContents once find-in-page | 5082 // the FindRequestManager in the outermost WebContents once find-in-page |
5081 // across GuestViews is implemented. | 5083 // across GuestViews is implemented. |
5082 if (!find_request_manager_) | 5084 if (!find_request_manager_) |
5083 find_request_manager_.reset(new FindRequestManager(this)); | 5085 find_request_manager_.reset(new FindRequestManager(this)); |
5084 | 5086 |
5085 return find_request_manager_.get(); | 5087 return find_request_manager_.get(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5195 dialog_manager_ = dialog_manager; | 5197 dialog_manager_ = dialog_manager; |
5196 } | 5198 } |
5197 | 5199 |
5198 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { | 5200 void WebContentsImpl::RemoveBindingSet(const std::string& interface_name) { |
5199 auto it = binding_sets_.find(interface_name); | 5201 auto it = binding_sets_.find(interface_name); |
5200 if (it != binding_sets_.end()) | 5202 if (it != binding_sets_.end()) |
5201 binding_sets_.erase(it); | 5203 binding_sets_.erase(it); |
5202 } | 5204 } |
5203 | 5205 |
5204 } // namespace content | 5206 } // namespace content |
OLD | NEW |