Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: webkit/plugins/ppapi/host_globals.cc

Issue 11416214: PPAPI: Move PPB_Console out of dev. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Nits Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/plugins/ppapi/host_globals.h ('k') | webkit/plugins/ppapi/plugin_module.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "webkit/plugins/ppapi/host_globals.h" 5 #include "webkit/plugins/ppapi/host_globals.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 27 matching lines...) Expand all
38 // Adds all WebPluginContainers associated with the given module to the set. 38 // Adds all WebPluginContainers associated with the given module to the set.
39 void GetAllContainersForModule(PluginModule* module, 39 void GetAllContainersForModule(PluginModule* module,
40 ContainerSet* containers) { 40 ContainerSet* containers) {
41 const PluginModule::PluginInstanceSet& instances = 41 const PluginModule::PluginInstanceSet& instances =
42 module->GetAllInstances(); 42 module->GetAllInstances();
43 for (PluginModule::PluginInstanceSet::const_iterator i = instances.begin(); 43 for (PluginModule::PluginInstanceSet::const_iterator i = instances.begin();
44 i != instances.end(); ++i) 44 i != instances.end(); ++i)
45 containers->insert((*i)->container()); 45 containers->insert((*i)->container());
46 } 46 }
47 47
48 WebConsoleMessage::Level LogLevelToWebLogLevel(PP_LogLevel_Dev level) { 48 WebConsoleMessage::Level LogLevelToWebLogLevel(PP_LogLevel level) {
49 switch (level) { 49 switch (level) {
50 case PP_LOGLEVEL_TIP: 50 case PP_LOGLEVEL_TIP:
51 return WebConsoleMessage::LevelTip; 51 return WebConsoleMessage::LevelTip;
52 case PP_LOGLEVEL_LOG: 52 case PP_LOGLEVEL_LOG:
53 return WebConsoleMessage::LevelLog; 53 return WebConsoleMessage::LevelLog;
54 case PP_LOGLEVEL_WARNING: 54 case PP_LOGLEVEL_WARNING:
55 return WebConsoleMessage::LevelWarning; 55 return WebConsoleMessage::LevelWarning;
56 case PP_LOGLEVEL_ERROR: 56 case PP_LOGLEVEL_ERROR:
57 default: 57 default:
58 return WebConsoleMessage::LevelError; 58 return WebConsoleMessage::LevelError;
59 } 59 }
60 } 60 }
61 61
62 WebConsoleMessage MakeLogMessage(PP_LogLevel_Dev level, 62 WebConsoleMessage MakeLogMessage(PP_LogLevel level,
63 const std::string& source, 63 const std::string& source,
64 const std::string& message) { 64 const std::string& message) {
65 std::string result = source; 65 std::string result = source;
66 if (!result.empty()) 66 if (!result.empty())
67 result.append(": "); 67 result.append(": ");
68 result.append(message); 68 result.append(message);
69 return WebConsoleMessage(LogLevelToWebLogLevel(level), 69 return WebConsoleMessage(LogLevelToWebLogLevel(level),
70 WebString(UTF8ToUTF16(result))); 70 WebString(UTF8ToUTF16(result)));
71 } 71 }
72 72
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 void HostGlobals::PreCacheFontForFlash(const void* logfontw) { 134 void HostGlobals::PreCacheFontForFlash(const void* logfontw) {
135 // Not implemented in-process. 135 // Not implemented in-process.
136 } 136 }
137 137
138 base::Lock* HostGlobals::GetProxyLock() { 138 base::Lock* HostGlobals::GetProxyLock() {
139 // We do not lock on the host side. 139 // We do not lock on the host side.
140 return NULL; 140 return NULL;
141 } 141 }
142 142
143 void HostGlobals::LogWithSource(PP_Instance instance, 143 void HostGlobals::LogWithSource(PP_Instance instance,
144 PP_LogLevel_Dev level, 144 PP_LogLevel level,
145 const std::string& source, 145 const std::string& source,
146 const std::string& value) { 146 const std::string& value) {
147 PluginInstance* instance_object = HostGlobals::Get()->GetInstance(instance); 147 PluginInstance* instance_object = HostGlobals::Get()->GetInstance(instance);
148 if (instance_object) { 148 if (instance_object) {
149 instance_object->container()->element().document().frame()-> 149 instance_object->container()->element().document().frame()->
150 addMessageToConsole(MakeLogMessage(level, source, value)); 150 addMessageToConsole(MakeLogMessage(level, source, value));
151 } else { 151 } else {
152 BroadcastLogWithSource(0, level, source, value); 152 BroadcastLogWithSource(0, level, source, value);
153 } 153 }
154 } 154 }
155 155
156 void HostGlobals::BroadcastLogWithSource(PP_Module pp_module, 156 void HostGlobals::BroadcastLogWithSource(PP_Module pp_module,
157 PP_LogLevel_Dev level, 157 PP_LogLevel level,
158 const std::string& source, 158 const std::string& source,
159 const std::string& value) { 159 const std::string& value) {
160 // Get the unique containers associated with the broadcast. This prevents us 160 // Get the unique containers associated with the broadcast. This prevents us
161 // from sending the same message to the same console when there are two 161 // from sending the same message to the same console when there are two
162 // instances on the page. 162 // instances on the page.
163 ContainerSet containers; 163 ContainerSet containers;
164 PluginModule* module = GetModule(pp_module); 164 PluginModule* module = GetModule(pp_module);
165 if (module) { 165 if (module) {
166 GetAllContainersForModule(module, &containers); 166 GetAllContainersForModule(module, &containers);
167 } else { 167 } else {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 return NULL; 261 return NULL;
262 return found->second; 262 return found->second;
263 } 263 }
264 264
265 bool HostGlobals::IsHostGlobals() const { 265 bool HostGlobals::IsHostGlobals() const {
266 return true; 266 return true;
267 } 267 }
268 268
269 } // namespace ppapi 269 } // namespace ppapi
270 } // namespace webkit 270 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/plugins/ppapi/host_globals.h ('k') | webkit/plugins/ppapi/plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698