OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extension_frame_helper.h" | 5 #include "extensions/renderer/extension_frame_helper.h" |
6 | 6 |
7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/timer/elapsed_timer.h" | 9 #include "base/timer/elapsed_timer.h" |
10 #include "content/public/renderer/render_frame.h" | 10 #include "content/public/renderer/render_frame.h" |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 effective_url); | 154 effective_url); |
155 if (!extension) | 155 if (!extension) |
156 return nullptr; | 156 return nullptr; |
157 | 157 |
158 // Try to match all same-origin frames in this process. | 158 // Try to match all same-origin frames in this process. |
159 for (const ExtensionFrameHelper* helper : g_frame_helpers.Get()) { | 159 for (const ExtensionFrameHelper* helper : g_frame_helpers.Get()) { |
160 if (!relative_to_frame->GetWebFrame()->GetSecurityOrigin().CanAccess( | 160 if (!relative_to_frame->GetWebFrame()->GetSecurityOrigin().CanAccess( |
161 helper->render_frame()->GetWebFrame()->GetSecurityOrigin())) | 161 helper->render_frame()->GetWebFrame()->GetSecurityOrigin())) |
162 continue; | 162 continue; |
163 | 163 |
164 if (helper->render_frame()->GetWebFrame()->AssignedName().Utf8() == name) | 164 if (helper->render_frame()->GetWebFrame()->AssignedName().Utf8() == name) { |
| 165 UMA_HISTOGRAM_ENUMERATION( |
| 166 "Extensions.BrowsingInstanceViolation.ExtensionViewType", |
| 167 helper->view_type(), VIEW_TYPE_LAST); |
| 168 |
| 169 GURL effective_target_url = ScriptContext::GetEffectiveDocumentURL( |
| 170 helper->render_frame()->GetWebFrame(), |
| 171 helper->render_frame()->GetWebFrame()->GetDocument().Url(), true); |
| 172 const Extension* target_extension = |
| 173 extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL( |
| 174 effective_target_url); |
| 175 UMA_HISTOGRAM_ENUMERATION( |
| 176 "Extensions.BrowsingInstanceViolation.ExtensionType", |
| 177 target_extension->GetType(), Manifest::TYPE_MAX); |
| 178 |
| 179 // DO NOT SUBMIT - remove the ad-hoc logging before landing this CL. The |
| 180 // log just shows that the UMA recording code is getting hit (despite |
| 181 // seeing no samples via base::HistogramTester in the browser test). |
| 182 LOG(ERROR) << "ExtensionFrameHelper::FindFrame" |
| 183 << "; target_extension->GetType() = " |
| 184 << target_extension->GetType() |
| 185 << "; helper->view_type() = " << helper->view_type(); |
| 186 |
165 return helper->render_frame(); | 187 return helper->render_frame(); |
| 188 } |
166 } | 189 } |
167 | 190 |
168 return nullptr; | 191 return nullptr; |
169 } | 192 } |
170 | 193 |
171 // static | 194 // static |
172 bool ExtensionFrameHelper::IsContextForEventPage(const ScriptContext* context) { | 195 bool ExtensionFrameHelper::IsContextForEventPage(const ScriptContext* context) { |
173 content::RenderFrame* render_frame = context->GetRenderFrame(); | 196 content::RenderFrame* render_frame = context->GetRenderFrame(); |
174 return context->extension() && render_frame && | 197 return context->extension() && render_frame && |
175 BackgroundInfo::HasLazyBackgroundPage(context->extension()) && | 198 BackgroundInfo::HasLazyBackgroundPage(context->extension()) && |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 const base::ListValue& args) { | 381 const base::ListValue& args) { |
359 extension_dispatcher_->InvokeModuleSystemMethod( | 382 extension_dispatcher_->InvokeModuleSystemMethod( |
360 render_frame(), extension_id, module_name, function_name, args); | 383 render_frame(), extension_id, module_name, function_name, args); |
361 } | 384 } |
362 | 385 |
363 void ExtensionFrameHelper::OnDestruct() { | 386 void ExtensionFrameHelper::OnDestruct() { |
364 delete this; | 387 delete this; |
365 } | 388 } |
366 | 389 |
367 } // namespace extensions | 390 } // namespace extensions |
OLD | NEW |