Chromium Code Reviews| 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/webui/web_ui_impl.h" | 5 #include "content/browser/webui/web_ui_impl.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 parameters += base::char16(','); | 37 parameters += base::char16(','); |
| 38 | 38 |
| 39 base::JSONWriter::Write(*arg_list[i], &json); | 39 base::JSONWriter::Write(*arg_list[i], &json); |
| 40 parameters += base::UTF8ToUTF16(json); | 40 parameters += base::UTF8ToUTF16(json); |
| 41 } | 41 } |
| 42 return base::ASCIIToUTF16(function_name) + | 42 return base::ASCIIToUTF16(function_name) + |
| 43 base::char16('(') + parameters + base::char16(')') + base::char16(';'); | 43 base::char16('(') + parameters + base::char16(')') + base::char16(';'); |
| 44 } | 44 } |
| 45 | 45 |
| 46 WebUIImpl::WebUIImpl(WebContents* contents) | 46 WebUIImpl::WebUIImpl(WebContents* contents) |
| 47 : link_transition_type_(ui::PAGE_TRANSITION_LINK), | 47 : WebContentsObserver(contents), |
| 48 link_transition_type_(ui::PAGE_TRANSITION_LINK), | |
| 48 bindings_(BINDINGS_POLICY_WEB_UI), | 49 bindings_(BINDINGS_POLICY_WEB_UI), |
| 49 web_contents_(contents) { | 50 web_contents_(contents) { |
| 50 DCHECK(contents); | 51 DCHECK(contents); |
| 51 } | 52 } |
| 52 | 53 |
| 53 WebUIImpl::~WebUIImpl() { | 54 WebUIImpl::~WebUIImpl() { |
| 54 // Delete the controller first, since it may also be keeping a pointer to some | 55 // Delete the controller first, since it may also be keeping a pointer to some |
| 55 // of the handlers and can call them at destruction. | 56 // of the handlers and can call them at destruction. |
| 56 controller_.reset(); | 57 controller_.reset(); |
| 57 } | 58 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 75 !WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( | 76 !WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI( |
| 76 web_contents_->GetBrowserContext(), source_url)) { | 77 web_contents_->GetBrowserContext(), source_url)) { |
| 77 NOTREACHED() << "Blocked unauthorized use of WebUIBindings."; | 78 NOTREACHED() << "Blocked unauthorized use of WebUIBindings."; |
| 78 return; | 79 return; |
| 79 } | 80 } |
| 80 | 81 |
| 81 ProcessWebUIMessage(source_url, message, args); | 82 ProcessWebUIMessage(source_url, message, args); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void WebUIImpl::RenderViewCreated(RenderViewHost* render_view_host) { | 85 void WebUIImpl::RenderViewCreated(RenderViewHost* render_view_host) { |
| 85 controller_->RenderViewCreated(render_view_host); | 86 controller_->RenderViewCreated(render_view_host); |
|
Charlie Reis
2015/08/28 17:05:56
Do we need to check whether this is our RVH before
| |
| 86 } | 87 } |
| 87 | 88 |
| 88 WebContents* WebUIImpl::GetWebContents() const { | 89 WebContents* WebUIImpl::GetWebContents() const { |
| 89 return web_contents_; | 90 return web_contents_; |
| 90 } | 91 } |
| 91 | 92 |
| 92 float WebUIImpl::GetDeviceScaleFactor() const { | 93 float WebUIImpl::GetDeviceScaleFactor() const { |
| 93 return GetScaleFactorForView(web_contents_->GetRenderWidgetHostView()); | 94 return GetScaleFactorForView(web_contents_->GetRenderWidgetHostView()); |
| 94 } | 95 } |
| 95 | 96 |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 241 } | 242 } |
| 242 | 243 |
| 243 void WebUIImpl::AddToSetIfFrameNameMatches( | 244 void WebUIImpl::AddToSetIfFrameNameMatches( |
| 244 std::set<RenderFrameHost*>* frame_set, | 245 std::set<RenderFrameHost*>* frame_set, |
| 245 RenderFrameHost* host) { | 246 RenderFrameHost* host) { |
| 246 if (host->GetFrameName() == frame_name_) | 247 if (host->GetFrameName() == frame_name_) |
| 247 frame_set->insert(host); | 248 frame_set->insert(host); |
| 248 } | 249 } |
| 249 | 250 |
| 250 } // namespace content | 251 } // namespace content |
| OLD | NEW |