| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "content/browser/child_process_security_policy_impl.h" | 12 #include "content/browser/child_process_security_policy_impl.h" |
| 13 #include "content/browser/renderer_host/render_process_host_impl.h" | 13 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 14 #include "content/browser/renderer_host/render_view_host.h" | 14 #include "content/browser/renderer_host/render_view_host.h" |
| 15 #include "content/browser/tab_contents/tab_contents.h" | 15 #include "content/browser/tab_contents/tab_contents.h" |
| 16 #include "content/browser/webui/generic_handler.h" | |
| 17 #include "content/common/view_messages.h" | 16 #include "content/common/view_messages.h" |
| 18 #include "content/public/browser/web_contents_view.h" | 17 #include "content/public/browser/web_contents_view.h" |
| 19 #include "content/public/browser/web_ui_controller.h" | 18 #include "content/public/browser/web_ui_controller.h" |
| 19 #include "content/public/browser/web_ui_message_handler.h" |
| 20 #include "content/public/common/bindings_policy.h" | 20 #include "content/public/common/bindings_policy.h" |
| 21 #include "ui/base/ui_base_switches.h" | 21 #include "ui/base/ui_base_switches.h" |
| 22 | 22 |
| 23 using content::WebContents; | 23 using content::WebContents; |
| 24 using content::WebUIController; | 24 using content::WebUIController; |
| 25 using content::WebUIMessageHandler; | 25 using content::WebUIMessageHandler; |
| 26 | 26 |
| 27 namespace content { | 27 namespace content { |
| 28 | 28 |
| 29 const WebUI::TypeID WebUI::kNoWebUI = NULL; | 29 const WebUI::TypeID WebUI::kNoWebUI = NULL; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 WebUIImpl::WebUIImpl(WebContents* contents) | 50 WebUIImpl::WebUIImpl(WebContents* contents) |
| 51 : hide_favicon_(false), | 51 : hide_favicon_(false), |
| 52 focus_location_bar_by_default_(false), | 52 focus_location_bar_by_default_(false), |
| 53 should_hide_url_(false), | 53 should_hide_url_(false), |
| 54 link_transition_type_(content::PAGE_TRANSITION_LINK), | 54 link_transition_type_(content::PAGE_TRANSITION_LINK), |
| 55 bindings_(content::BINDINGS_POLICY_WEB_UI), | 55 bindings_(content::BINDINGS_POLICY_WEB_UI), |
| 56 web_contents_(contents) { | 56 web_contents_(contents) { |
| 57 DCHECK(contents); | 57 DCHECK(contents); |
| 58 AddMessageHandler(new GenericHandler()); | |
| 59 } | 58 } |
| 60 | 59 |
| 61 WebUIImpl::~WebUIImpl() { | 60 WebUIImpl::~WebUIImpl() { |
| 62 // Delete the controller first, since it may also be keeping a pointer to some | 61 // Delete the controller first, since it may also be keeping a pointer to some |
| 63 // of the handlers and can call them at destruction. | 62 // of the handlers and can call them at destruction. |
| 64 controller_.reset(); | 63 controller_.reset(); |
| 65 STLDeleteContainerPointers(handlers_.begin(), handlers_.end()); | 64 STLDeleteContainerPointers(handlers_.begin(), handlers_.end()); |
| 66 } | 65 } |
| 67 | 66 |
| 68 // WebUIImpl, public: ---------------------------------------------------------- | 67 // WebUIImpl, public: ---------------------------------------------------------- |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 DCHECK(!handler->web_ui()); | 256 DCHECK(!handler->web_ui()); |
| 258 handler->set_web_ui(this); | 257 handler->set_web_ui(this); |
| 259 handler->RegisterMessages(); | 258 handler->RegisterMessages(); |
| 260 handlers_.push_back(handler); | 259 handlers_.push_back(handler); |
| 261 } | 260 } |
| 262 | 261 |
| 263 void WebUIImpl::ExecuteJavascript(const string16& javascript) { | 262 void WebUIImpl::ExecuteJavascript(const string16& javascript) { |
| 264 web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame( | 263 web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame( |
| 265 ASCIIToUTF16(frame_xpath_), javascript); | 264 ASCIIToUTF16(frame_xpath_), javascript); |
| 266 } | 265 } |
| OLD | NEW |