OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer/extensions/extension_dispatcher.h" | 5 #include "chrome/renderer/extensions/extension_dispatcher.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/common/child_process_logging.h" | 8 #include "chrome/common/child_process_logging.h" |
9 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
10 #include "chrome/common/extensions/extension.h" | 10 #include "chrome/common/extensions/extension.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 IPC_MESSAGE_UNHANDLED(handled = false) | 72 IPC_MESSAGE_UNHANDLED(handled = false) |
73 IPC_END_MESSAGE_MAP() | 73 IPC_END_MESSAGE_MAP() |
74 | 74 |
75 return handled; | 75 return handled; |
76 } | 76 } |
77 | 77 |
78 void ExtensionDispatcher::WebKitInitialized() { | 78 void ExtensionDispatcher::WebKitInitialized() { |
79 // For extensions, we want to ensure we call the IdleHandler every so often, | 79 // For extensions, we want to ensure we call the IdleHandler every so often, |
80 // even if the extension keeps up activity. | 80 // even if the extension keeps up activity. |
81 if (is_extension_process_) { | 81 if (is_extension_process_) { |
82 forced_idle_timer_.Start(FROM_HERE, | 82 forced_idle_timer_.Start( |
83 base::TimeDelta::FromSeconds(kMaxExtensionIdleHandlerDelayS), | 83 base::TimeDelta::FromSeconds(kMaxExtensionIdleHandlerDelayS), |
84 RenderThread::current(), &RenderThread::IdleHandler); | 84 RenderThread::current(), &RenderThread::IdleHandler); |
85 } | 85 } |
86 | 86 |
87 RegisterExtension(extensions_v8::ChromeAppExtension::Get(this), false); | 87 RegisterExtension(extensions_v8::ChromeAppExtension::Get(this), false); |
88 | 88 |
89 if (CommandLine::ForCurrentProcess()->HasSwitch( | 89 if (CommandLine::ForCurrentProcess()->HasSwitch( |
90 switches::kEnableInlineWebstoreInstall)) { | 90 switches::kEnableInlineWebstoreInstall)) { |
91 RegisterExtension(extensions_v8::ChromeWebstoreExtension::Get(), false); | 91 RegisterExtension(extensions_v8::ChromeWebstoreExtension::Get(), false); |
92 } | 92 } |
(...skipping 18 matching lines...) Expand all Loading... |
111 } | 111 } |
112 | 112 |
113 void ExtensionDispatcher::IdleNotification() { | 113 void ExtensionDispatcher::IdleNotification() { |
114 if (is_extension_process_) { | 114 if (is_extension_process_) { |
115 // Dampen the forced delay as well if the extension stays idle for long | 115 // Dampen the forced delay as well if the extension stays idle for long |
116 // periods of time. | 116 // periods of time. |
117 int64 forced_delay_s = std::max(static_cast<int64>( | 117 int64 forced_delay_s = std::max(static_cast<int64>( |
118 RenderThread::current()->idle_notification_delay_in_s()), | 118 RenderThread::current()->idle_notification_delay_in_s()), |
119 kMaxExtensionIdleHandlerDelayS); | 119 kMaxExtensionIdleHandlerDelayS); |
120 forced_idle_timer_.Stop(); | 120 forced_idle_timer_.Stop(); |
121 forced_idle_timer_.Start(FROM_HERE, | 121 forced_idle_timer_.Start( |
122 base::TimeDelta::FromSeconds(forced_delay_s), | 122 base::TimeDelta::FromSeconds(forced_delay_s), |
123 RenderThread::current(), &RenderThread::IdleHandler); | 123 RenderThread::current(), &RenderThread::IdleHandler); |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 void ExtensionDispatcher::OnSetFunctionNames( | 127 void ExtensionDispatcher::OnSetFunctionNames( |
128 const std::vector<std::string>& names) { | 128 const std::vector<std::string>& names) { |
129 function_names_.clear(); | 129 function_names_.clear(); |
130 for (size_t i = 0; i < names.size(); ++i) | 130 for (size_t i = 0; i < names.size(); ++i) |
131 function_names_.insert(names[i]); | 131 function_names_.insert(names[i]); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 child_process_logging::SetActiveExtensions(active_extensions); | 331 child_process_logging::SetActiveExtensions(active_extensions); |
332 } | 332 } |
333 | 333 |
334 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, | 334 void ExtensionDispatcher::RegisterExtension(v8::Extension* extension, |
335 bool restrict_to_extensions) { | 335 bool restrict_to_extensions) { |
336 if (restrict_to_extensions) | 336 if (restrict_to_extensions) |
337 restricted_v8_extensions_.insert(extension->name()); | 337 restricted_v8_extensions_.insert(extension->name()); |
338 | 338 |
339 RenderThread::current()->RegisterExtension(extension); | 339 RenderThread::current()->RegisterExtension(extension); |
340 } | 340 } |
OLD | NEW |