| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/dom_ui/dom_ui.h" | 5 #include "chrome/browser/dom_ui/dom_ui.h" |
| 6 | 6 |
| 7 #include "base/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
| 8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
| 9 #include "base/stl_util-inl.h" | 9 #include "base/stl_util-inl.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 const std::vector<const Value*>& args) { | 119 const std::vector<const Value*>& args) { |
| 120 ExecuteJavascript(GetJavascript(function_name, args)); | 120 ExecuteJavascript(GetJavascript(function_name, args)); |
| 121 } | 121 } |
| 122 | 122 |
| 123 ui::ThemeProvider* DOMUI::GetThemeProvider() const { | 123 ui::ThemeProvider* DOMUI::GetThemeProvider() const { |
| 124 return GetProfile()->GetThemeProvider(); | 124 return GetProfile()->GetThemeProvider(); |
| 125 } | 125 } |
| 126 | 126 |
| 127 void DOMUI::RegisterMessageCallback(const std::string &message, | 127 void DOMUI::RegisterMessageCallback(const std::string &message, |
| 128 MessageCallback *callback) { | 128 MessageCallback *callback) { |
| 129 message_callbacks_.insert(std::make_pair(message, callback)); | 129 std::pair<MessageCallbackMap::iterator, bool> result = |
| 130 message_callbacks_.insert(std::make_pair(message, callback)); |
| 131 |
| 132 // Overwrite preexisting message callback mappings. |
| 133 if (register_callback_overwrites() && !result.second) |
| 134 result.first->second = callback; |
| 130 } | 135 } |
| 131 | 136 |
| 132 Profile* DOMUI::GetProfile() const { | 137 Profile* DOMUI::GetProfile() const { |
| 133 DCHECK(tab_contents()); | 138 DCHECK(tab_contents()); |
| 134 return tab_contents()->profile(); | 139 return tab_contents()->profile(); |
| 135 } | 140 } |
| 136 | 141 |
| 137 RenderViewHost* DOMUI::GetRenderViewHost() const { | 142 RenderViewHost* DOMUI::GetRenderViewHost() const { |
| 138 DCHECK(tab_contents()); | 143 DCHECK(tab_contents()); |
| 139 return tab_contents()->render_view_host(); | 144 return tab_contents()->render_view_host(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 201 } |
| 197 | 202 |
| 198 // TODO(viettrungluu): convert to string16 (or UTF-8 std::string?). | 203 // TODO(viettrungluu): convert to string16 (or UTF-8 std::string?). |
| 199 std::wstring DOMMessageHandler::ExtractStringValue(const ListValue* value) { | 204 std::wstring DOMMessageHandler::ExtractStringValue(const ListValue* value) { |
| 200 string16 string16_value; | 205 string16 string16_value; |
| 201 if (value->GetString(0, &string16_value)) | 206 if (value->GetString(0, &string16_value)) |
| 202 return UTF16ToWideHack(string16_value); | 207 return UTF16ToWideHack(string16_value); |
| 203 NOTREACHED(); | 208 NOTREACHED(); |
| 204 return std::wstring(); | 209 return std::wstring(); |
| 205 } | 210 } |
| OLD | NEW |