| 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/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 parameters += char16(','); | 38 parameters += char16(','); |
| 39 | 39 |
| 40 base::JSONWriter::Write(arg_list[i], &json); | 40 base::JSONWriter::Write(arg_list[i], &json); |
| 41 parameters += UTF8ToUTF16(json); | 41 parameters += UTF8ToUTF16(json); |
| 42 } | 42 } |
| 43 return ASCIIToUTF16(function_name) + | 43 return ASCIIToUTF16(function_name) + |
| 44 char16('(') + parameters + char16(')') + char16(';'); | 44 char16('(') + parameters + char16(')') + char16(';'); |
| 45 } | 45 } |
| 46 | 46 |
| 47 WebUIImpl::WebUIImpl(WebContents* contents) | 47 WebUIImpl::WebUIImpl(WebContents* contents) |
| 48 : hide_favicon_(false), | 48 : link_transition_type_(PAGE_TRANSITION_LINK), |
| 49 focus_location_bar_by_default_(false), | |
| 50 should_hide_url_(false), | |
| 51 link_transition_type_(PAGE_TRANSITION_LINK), | |
| 52 bindings_(BINDINGS_POLICY_WEB_UI), | 49 bindings_(BINDINGS_POLICY_WEB_UI), |
| 53 web_contents_(contents) { | 50 web_contents_(contents) { |
| 54 DCHECK(contents); | 51 DCHECK(contents); |
| 55 } | 52 } |
| 56 | 53 |
| 57 WebUIImpl::~WebUIImpl() { | 54 WebUIImpl::~WebUIImpl() { |
| 58 // 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 |
| 59 // of the handlers and can call them at destruction. | 56 // of the handlers and can call them at destruction. |
| 60 controller_.reset(); | 57 controller_.reset(); |
| 61 STLDeleteContainerPointers(handlers_.begin(), handlers_.end()); | 58 STLDeleteContainerPointers(handlers_.begin(), handlers_.end()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 } | 101 } |
| 105 | 102 |
| 106 WebContents* WebUIImpl::GetWebContents() const { | 103 WebContents* WebUIImpl::GetWebContents() const { |
| 107 return web_contents_; | 104 return web_contents_; |
| 108 } | 105 } |
| 109 | 106 |
| 110 ui::ScaleFactor WebUIImpl::GetDeviceScaleFactor() const { | 107 ui::ScaleFactor WebUIImpl::GetDeviceScaleFactor() const { |
| 111 return GetScaleFactorForView(web_contents_->GetRenderWidgetHostView()); | 108 return GetScaleFactorForView(web_contents_->GetRenderWidgetHostView()); |
| 112 } | 109 } |
| 113 | 110 |
| 114 bool WebUIImpl::ShouldHideFavicon() const { | |
| 115 return hide_favicon_; | |
| 116 } | |
| 117 | |
| 118 void WebUIImpl::HideFavicon() { | |
| 119 hide_favicon_ = true; | |
| 120 } | |
| 121 | |
| 122 bool WebUIImpl::ShouldFocusLocationBarByDefault() const { | |
| 123 return focus_location_bar_by_default_; | |
| 124 } | |
| 125 | |
| 126 void WebUIImpl::FocusLocationBarByDefault() { | |
| 127 focus_location_bar_by_default_ = true; | |
| 128 } | |
| 129 | |
| 130 bool WebUIImpl::ShouldHideURL() const { | |
| 131 return should_hide_url_; | |
| 132 } | |
| 133 | |
| 134 void WebUIImpl::HideURL() { | |
| 135 should_hide_url_ = true; | |
| 136 } | |
| 137 | |
| 138 const string16& WebUIImpl::GetOverriddenTitle() const { | 111 const string16& WebUIImpl::GetOverriddenTitle() const { |
| 139 return overridden_title_; | 112 return overridden_title_; |
| 140 } | 113 } |
| 141 | 114 |
| 142 void WebUIImpl::OverrideTitle(const string16& title) { | 115 void WebUIImpl::OverrideTitle(const string16& title) { |
| 143 overridden_title_ = title; | 116 overridden_title_ = title; |
| 144 } | 117 } |
| 145 | 118 |
| 146 PageTransition WebUIImpl::GetLinkTransitionType() const { | 119 PageTransition WebUIImpl::GetLinkTransitionType() const { |
| 147 return link_transition_type_; | 120 return link_transition_type_; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 handlers_.push_back(handler); | 230 handlers_.push_back(handler); |
| 258 } | 231 } |
| 259 | 232 |
| 260 void WebUIImpl::ExecuteJavascript(const string16& javascript) { | 233 void WebUIImpl::ExecuteJavascript(const string16& javascript) { |
| 261 static_cast<RenderViewHostImpl*>( | 234 static_cast<RenderViewHostImpl*>( |
| 262 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame( | 235 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame( |
| 263 ASCIIToUTF16(frame_xpath_), javascript); | 236 ASCIIToUTF16(frame_xpath_), javascript); |
| 264 } | 237 } |
| 265 | 238 |
| 266 } // namespace content | 239 } // namespace content |
| OLD | NEW |