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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 | 318 |
319 context->DispatchOnUnloadEvent(); | 319 context->DispatchOnUnloadEvent(); |
320 // TODO(kalman): add an invalidation observer interface to ScriptContext. | 320 // TODO(kalman): add an invalidation observer interface to ScriptContext. |
321 request_sender_->InvalidateSource(context); | 321 request_sender_->InvalidateSource(context); |
322 | 322 |
323 script_context_set_.Remove(context); | 323 script_context_set_.Remove(context); |
324 VLOG(1) << "Num tracked contexts: " << script_context_set_.size(); | 324 VLOG(1) << "Num tracked contexts: " << script_context_set_.size(); |
325 } | 325 } |
326 | 326 |
327 void Dispatcher::DidCreateDocumentElement(blink::WebFrame* frame) { | 327 void Dispatcher::DidCreateDocumentElement(blink::WebFrame* frame) { |
328 if (IsWithinPlatformApp()) { | 328 if (IsWithinPlatformApp() || IsWithinExtension()) { |
not at google - send to devlin
2014/07/19 00:08:10
I don't think (looking at IsWithinExtension) this
not at google - send to devlin
2014/07/19 00:19:24
The URL shouldn't come from frame->document()->url
ericzeng
2014/07/19 01:48:59
Done.
| |
329 // WebKit doesn't let us define an additional user agent stylesheet, so we | 329 std::string stylesheet; |
330 // insert the default platform app stylesheet into all documents that are | 330 if (IsWithinPlatformApp()) |
331 // loaded in each app. | 331 // WebKit doesn't let us define an additional user agent stylesheet, so we |
332 std::string stylesheet = ResourceBundle::GetSharedInstance() | 332 // insert the default platform app stylesheet into all documents that are |
333 .GetRawDataResource(IDR_PLATFORM_APP_CSS) | 333 // loaded in each app. |
334 .as_string(); | 334 stylesheet = ResourceBundle::GetSharedInstance() |
335 .GetRawDataResource(IDR_PLATFORM_APP_CSS) | |
336 .as_string(); | |
337 else if (IsWithinExtension()) | |
338 stylesheet = ResourceBundle::GetSharedInstance() | |
339 .GetRawDataResource(IDR_EXTENSION_CSS) | |
340 .as_string(); | |
not at google - send to devlin
2014/07/19 00:08:10
each of these has multi-line bodies; use {}.
thou
ericzeng
2014/07/19 01:48:59
Is there a case where the renderer could host some
not at google - send to devlin
2014/07/19 01:54:16
oh, right. yes :) good point.
| |
335 ReplaceFirstSubstringAfterOffset( | 341 ReplaceFirstSubstringAfterOffset( |
336 &stylesheet, 0, "$FONTFAMILY", system_font_family_); | 342 &stylesheet, 0, "$FONTFAMILY", system_font_family_); |
337 ReplaceFirstSubstringAfterOffset( | 343 ReplaceFirstSubstringAfterOffset( |
338 &stylesheet, 0, "$FONTSIZE", system_font_size_); | 344 &stylesheet, 0, "$FONTSIZE", system_font_size_); |
339 frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet)); | 345 frame->document().insertStyleSheet(WebString::fromUTF8(stylesheet)); |
340 } | 346 } |
341 | |
342 content_watcher_->DidCreateDocumentElement(frame); | 347 content_watcher_->DidCreateDocumentElement(frame); |
343 } | 348 } |
344 | 349 |
345 void Dispatcher::DidMatchCSS( | 350 void Dispatcher::DidMatchCSS( |
346 blink::WebFrame* frame, | 351 blink::WebFrame* frame, |
347 const blink::WebVector<blink::WebString>& newly_matching_selectors, | 352 const blink::WebVector<blink::WebString>& newly_matching_selectors, |
348 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { | 353 const blink::WebVector<blink::WebString>& stopped_matching_selectors) { |
349 content_watcher_->DidMatchCSS( | 354 content_watcher_->DidMatchCSS( |
350 frame, newly_matching_selectors, stopped_matching_selectors); | 355 frame, newly_matching_selectors, stopped_matching_selectors); |
351 } | 356 } |
(...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1061 for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); | 1066 for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); |
1062 iter != active_extension_ids_.end(); | 1067 iter != active_extension_ids_.end(); |
1063 ++iter) { | 1068 ++iter) { |
1064 const Extension* extension = extensions_.GetByID(*iter); | 1069 const Extension* extension = extensions_.GetByID(*iter); |
1065 if (extension && extension->is_platform_app()) | 1070 if (extension && extension->is_platform_app()) |
1066 return true; | 1071 return true; |
1067 } | 1072 } |
1068 return false; | 1073 return false; |
1069 } | 1074 } |
1070 | 1075 |
1076 bool Dispatcher::IsWithinExtension() { | |
1077 for (std::set<std::string>::iterator iter = active_extension_ids_.begin(); | |
1078 iter != active_extension_ids_.end(); | |
1079 ++iter) { | |
1080 const Extension* extension = extensions_.GetByID(*iter); | |
1081 if (extension && extension->is_extension()) | |
1082 return true; | |
1083 } | |
1084 return false; | |
1085 } | |
1086 | |
1071 // TODO(kalman): This is checking for the wrong thing, it should be checking if | 1087 // TODO(kalman): This is checking for the wrong thing, it should be checking if |
1072 // the frame's security origin is unique. The extension sandbox directive is | 1088 // the frame's security origin is unique. The extension sandbox directive is |
1073 // checked for in extensions/common/manifest_handlers/csp_info.cc. | 1089 // checked for in extensions/common/manifest_handlers/csp_info.cc. |
1074 bool Dispatcher::IsSandboxedPage(const GURL& url) const { | 1090 bool Dispatcher::IsSandboxedPage(const GURL& url) const { |
1075 if (url.SchemeIs(kExtensionScheme)) { | 1091 if (url.SchemeIs(kExtensionScheme)) { |
1076 const Extension* extension = extensions_.GetByID(url.host()); | 1092 const Extension* extension = extensions_.GetByID(url.host()); |
1077 if (extension) { | 1093 if (extension) { |
1078 return SandboxedPageInfo::IsSandboxedPage(extension, url.path()); | 1094 return SandboxedPageInfo::IsSandboxedPage(extension, url.path()); |
1079 } | 1095 } |
1080 } | 1096 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1197 return v8::Handle<v8::Object>(); | 1213 return v8::Handle<v8::Object>(); |
1198 | 1214 |
1199 if (bind_name) | 1215 if (bind_name) |
1200 *bind_name = split.back(); | 1216 *bind_name = split.back(); |
1201 | 1217 |
1202 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) | 1218 return bind_object.IsEmpty() ? AsObjectOrEmpty(GetOrCreateChrome(context)) |
1203 : bind_object; | 1219 : bind_object; |
1204 } | 1220 } |
1205 | 1221 |
1206 } // namespace extensions | 1222 } // namespace extensions |
OLD | NEW |