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

Side by Side Diff: extensions/renderer/extension_frame_helper.cc

Issue 2925193002: NOT YET READY: UMA recording the kind of target frame when extensions pierce browsing instance.
Patch Set: Rebasing... Created 3 years, 6 months 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
« no previous file with comments | « extensions/renderer/extension_frame_helper.h ('k') | tools/metrics/histograms/enums.xml » ('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 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 <set>
8
7 #include "base/metrics/histogram_macros.h" 9 #include "base/metrics/histogram_macros.h"
8 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
9 #include "base/timer/elapsed_timer.h" 11 #include "base/timer/elapsed_timer.h"
10 #include "content/public/renderer/render_frame.h" 12 #include "content/public/renderer/render_frame.h"
11 #include "extensions/common/api/messaging/message.h" 13 #include "extensions/common/api/messaging/message.h"
12 #include "extensions/common/api/messaging/port_id.h" 14 #include "extensions/common/api/messaging/port_id.h"
13 #include "extensions/common/constants.h" 15 #include "extensions/common/constants.h"
14 #include "extensions/common/extension_messages.h" 16 #include "extensions/common/extension_messages.h"
15 #include "extensions/common/manifest_handlers/background_info.h" 17 #include "extensions/common/manifest_handlers/background_info.h"
16 #include "extensions/renderer/console.h" 18 #include "extensions/renderer/console.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 relative_to_frame->GetWebFrame(), 152 relative_to_frame->GetWebFrame(),
151 relative_to_frame->GetWebFrame()->GetDocument().Url(), true); 153 relative_to_frame->GetWebFrame()->GetDocument().Url(), true);
152 const Extension* extension = 154 const Extension* extension =
153 extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL( 155 extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL(
154 effective_url); 156 effective_url);
155 if (!extension) 157 if (!extension)
156 return nullptr; 158 return nullptr;
157 159
158 // Try to match all same-origin frames in this process. 160 // Try to match all same-origin frames in this process.
159 for (const ExtensionFrameHelper* helper : g_frame_helpers.Get()) { 161 for (const ExtensionFrameHelper* helper : g_frame_helpers.Get()) {
162 if (helper->render_frame()->GetWebFrame()->AssignedName().Utf8() != name)
163 continue;
164
160 if (!relative_to_frame->GetWebFrame()->GetSecurityOrigin().CanAccess( 165 if (!relative_to_frame->GetWebFrame()->GetSecurityOrigin().CanAccess(
161 helper->render_frame()->GetWebFrame()->GetSecurityOrigin())) 166 helper->render_frame()->GetWebFrame()->GetSecurityOrigin()))
162 continue; 167 continue;
163 168
164 if (helper->render_frame()->GetWebFrame()->AssignedName().Utf8() == name) 169 UMA_HISTOGRAM_ENUMERATION(
165 return helper->render_frame(); 170 "Extensions.BrowsingInstanceViolation.ExtensionViewType",
171 helper->view_type(), VIEW_TYPE_LAST);
172 GURL effective_target_url = ScriptContext::GetEffectiveDocumentURL(
173 helper->render_frame()->GetWebFrame(),
174 helper->render_frame()->GetWebFrame()->GetDocument().Url(), true);
175 const Extension* target_extension =
176 extensions::RendererExtensionRegistry::Get()->GetExtensionOrAppByURL(
177 effective_target_url);
178 UMA_HISTOGRAM_ENUMERATION(
179 "Extensions.BrowsingInstanceViolation.ExtensionType",
180 target_extension->GetType(), Manifest::TYPE_MAX);
181
182 return helper->render_frame();
166 } 183 }
167 184
168 return nullptr; 185 return nullptr;
169 } 186 }
170 187
171 // static 188 // static
172 bool ExtensionFrameHelper::IsContextForEventPage(const ScriptContext* context) { 189 bool ExtensionFrameHelper::IsContextForEventPage(const ScriptContext* context) {
173 content::RenderFrame* render_frame = context->GetRenderFrame(); 190 content::RenderFrame* render_frame = context->GetRenderFrame();
174 return context->extension() && render_frame && 191 return context->extension() && render_frame &&
175 BackgroundInfo::HasLazyBackgroundPage(context->extension()) && 192 BackgroundInfo::HasLazyBackgroundPage(context->extension()) &&
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 const base::ListValue& args) { 375 const base::ListValue& args) {
359 extension_dispatcher_->InvokeModuleSystemMethod( 376 extension_dispatcher_->InvokeModuleSystemMethod(
360 render_frame(), extension_id, module_name, function_name, args); 377 render_frame(), extension_id, module_name, function_name, args);
361 } 378 }
362 379
363 void ExtensionFrameHelper::OnDestruct() { 380 void ExtensionFrameHelper::OnDestruct() {
364 delete this; 381 delete this;
365 } 382 }
366 383
367 } // namespace extensions 384 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/extension_frame_helper.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698