OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/dispatcher.h" | 5 #include "extensions/renderer/dispatcher.h" |
6 | 6 |
| 7 #include <stddef.h> |
| 8 |
7 #include <utility> | 9 #include <utility> |
8 | 10 |
9 #include "base/bind.h" | 11 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
11 #include "base/callback.h" | 13 #include "base/callback.h" |
12 #include "base/command_line.h" | 14 #include "base/command_line.h" |
13 #include "base/debug/alias.h" | 15 #include "base/debug/alias.h" |
14 #include "base/lazy_instance.h" | 16 #include "base/lazy_instance.h" |
| 17 #include "base/macros.h" |
15 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
16 #include "base/metrics/histogram_macros.h" | 19 #include "base/metrics/histogram_macros.h" |
17 #include "base/metrics/user_metrics_action.h" | 20 #include "base/metrics/user_metrics_action.h" |
18 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
19 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
20 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
21 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
22 #include "base/time/time.h" | 25 #include "base/time/time.h" |
23 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "build/build_config.h" |
24 #include "content/grit/content_resources.h" | 28 #include "content/grit/content_resources.h" |
25 #include "content/public/child/v8_value_converter.h" | 29 #include "content/public/child/v8_value_converter.h" |
26 #include "content/public/common/browser_plugin_guest_mode.h" | 30 #include "content/public/common/browser_plugin_guest_mode.h" |
27 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
28 #include "content/public/common/url_constants.h" | 32 #include "content/public/common/url_constants.h" |
29 #include "content/public/renderer/render_frame.h" | 33 #include "content/public/renderer/render_frame.h" |
30 #include "content/public/renderer/render_thread.h" | 34 #include "content/public/renderer/render_thread.h" |
31 #include "extensions/common/api/messaging/message.h" | 35 #include "extensions/common/api/messaging/message.h" |
32 #include "extensions/common/constants.h" | 36 #include "extensions/common/constants.h" |
33 #include "extensions/common/extension_api.h" | 37 #include "extensions/common/extension_api.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 using blink::WebSecurityPolicy; | 122 using blink::WebSecurityPolicy; |
119 using blink::WebString; | 123 using blink::WebString; |
120 using blink::WebVector; | 124 using blink::WebVector; |
121 using blink::WebView; | 125 using blink::WebView; |
122 using content::RenderThread; | 126 using content::RenderThread; |
123 | 127 |
124 namespace extensions { | 128 namespace extensions { |
125 | 129 |
126 namespace { | 130 namespace { |
127 | 131 |
128 static const int64 kInitialExtensionIdleHandlerDelayMs = 5 * 1000; | 132 static const int64_t kInitialExtensionIdleHandlerDelayMs = 5 * 1000; |
129 static const int64 kMaxExtensionIdleHandlerDelayMs = 5 * 60 * 1000; | 133 static const int64_t kMaxExtensionIdleHandlerDelayMs = 5 * 60 * 1000; |
130 static const char kEventDispatchFunction[] = "dispatchEvent"; | 134 static const char kEventDispatchFunction[] = "dispatchEvent"; |
131 static const char kOnSuspendEvent[] = "runtime.onSuspend"; | 135 static const char kOnSuspendEvent[] = "runtime.onSuspend"; |
132 static const char kOnSuspendCanceledEvent[] = "runtime.onSuspendCanceled"; | 136 static const char kOnSuspendCanceledEvent[] = "runtime.onSuspendCanceled"; |
133 | 137 |
134 void CrashOnException(const v8::TryCatch& trycatch) { | 138 void CrashOnException(const v8::TryCatch& trycatch) { |
135 NOTREACHED(); | 139 NOTREACHED(); |
136 }; | 140 }; |
137 | 141 |
138 // Returns the global value for "chrome" from |context|. If one doesn't exist | 142 // Returns the global value for "chrome" from |context|. If one doesn't exist |
139 // creates a new object for it. | 143 // creates a new object for it. |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
928 EnableCustomElementWhiteList(); | 932 EnableCustomElementWhiteList(); |
929 | 933 |
930 is_webkit_initialized_ = true; | 934 is_webkit_initialized_ = true; |
931 } | 935 } |
932 | 936 |
933 void Dispatcher::IdleNotification() { | 937 void Dispatcher::IdleNotification() { |
934 if (set_idle_notifications_ && forced_idle_timer_) { | 938 if (set_idle_notifications_ && forced_idle_timer_) { |
935 // Dampen the forced delay as well if the extension stays idle for long | 939 // Dampen the forced delay as well if the extension stays idle for long |
936 // periods of time. (forced_idle_timer_ can be NULL after | 940 // periods of time. (forced_idle_timer_ can be NULL after |
937 // OnRenderProcessShutdown has been called.) | 941 // OnRenderProcessShutdown has been called.) |
938 int64 forced_delay_ms = | 942 int64_t forced_delay_ms = |
939 std::max(RenderThread::Get()->GetIdleNotificationDelayInMs(), | 943 std::max(RenderThread::Get()->GetIdleNotificationDelayInMs(), |
940 kMaxExtensionIdleHandlerDelayMs); | 944 kMaxExtensionIdleHandlerDelayMs); |
941 forced_idle_timer_->Stop(); | 945 forced_idle_timer_->Stop(); |
942 forced_idle_timer_->Start( | 946 forced_idle_timer_->Start( |
943 FROM_HERE, | 947 FROM_HERE, |
944 base::TimeDelta::FromMilliseconds(forced_delay_ms), | 948 base::TimeDelta::FromMilliseconds(forced_delay_ms), |
945 RenderThread::Get(), | 949 RenderThread::Get(), |
946 &RenderThread::IdleHandler); | 950 &RenderThread::IdleHandler); |
947 } | 951 } |
948 } | 952 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 system_font_size_ = font_size; | 1094 system_font_size_ = font_size; |
1091 } | 1095 } |
1092 | 1096 |
1093 void Dispatcher::OnSetWebViewPartitionID(const std::string& partition_id) { | 1097 void Dispatcher::OnSetWebViewPartitionID(const std::string& partition_id) { |
1094 // |webview_partition_id_| cannot be changed once set. | 1098 // |webview_partition_id_| cannot be changed once set. |
1095 CHECK(webview_partition_id_.empty() || webview_partition_id_ == partition_id); | 1099 CHECK(webview_partition_id_.empty() || webview_partition_id_ == partition_id); |
1096 webview_partition_id_ = partition_id; | 1100 webview_partition_id_ = partition_id; |
1097 } | 1101 } |
1098 | 1102 |
1099 void Dispatcher::OnShouldSuspend(const std::string& extension_id, | 1103 void Dispatcher::OnShouldSuspend(const std::string& extension_id, |
1100 uint64 sequence_id) { | 1104 uint64_t sequence_id) { |
1101 RenderThread::Get()->Send( | 1105 RenderThread::Get()->Send( |
1102 new ExtensionHostMsg_ShouldSuspendAck(extension_id, sequence_id)); | 1106 new ExtensionHostMsg_ShouldSuspendAck(extension_id, sequence_id)); |
1103 } | 1107 } |
1104 | 1108 |
1105 void Dispatcher::OnSuspend(const std::string& extension_id) { | 1109 void Dispatcher::OnSuspend(const std::string& extension_id) { |
1106 // Dispatch the suspend event. This doesn't go through the standard event | 1110 // Dispatch the suspend event. This doesn't go through the standard event |
1107 // dispatch machinery because it requires special handling. We need to let | 1111 // dispatch machinery because it requires special handling. We need to let |
1108 // the browser know when we are starting and stopping the event dispatch, so | 1112 // the browser know when we are starting and stopping the event dispatch, so |
1109 // that it still considers the extension idle despite any activity the suspend | 1113 // that it still considers the extension idle despite any activity the suspend |
1110 // event creates. | 1114 // event creates. |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1602 // The "guestViewDeny" module must always be loaded last. It registers | 1606 // The "guestViewDeny" module must always be loaded last. It registers |
1603 // error-providing custom elements for the GuestView types that are not | 1607 // error-providing custom elements for the GuestView types that are not |
1604 // available, and thus all of those types must have been checked and loaded | 1608 // available, and thus all of those types must have been checked and loaded |
1605 // (or not loaded) beforehand. | 1609 // (or not loaded) beforehand. |
1606 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { | 1610 if (context_type == Feature::BLESSED_EXTENSION_CONTEXT) { |
1607 module_system->Require("guestViewDeny"); | 1611 module_system->Require("guestViewDeny"); |
1608 } | 1612 } |
1609 } | 1613 } |
1610 | 1614 |
1611 } // namespace extensions | 1615 } // namespace extensions |
OLD | NEW |