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

Side by Side Diff: chrome/renderer/extensions/event_bindings.cc

Issue 3210007: Add support for a "split" incognito behavior for extensions. (Closed)
Patch Set: latest Created 10 years, 3 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/event_bindings.h" 5 #include "chrome/renderer/extensions/event_bindings.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/singleton.h" 8 #include "base/singleton.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } 136 }
137 }; 137 };
138 138
139 // Returns true if the extension running in the given |context| has sufficient 139 // Returns true if the extension running in the given |context| has sufficient
140 // permissions to access the data. 140 // permissions to access the data.
141 static bool HasSufficientPermissions(ContextInfo* context, 141 static bool HasSufficientPermissions(ContextInfo* context,
142 bool requires_incognito_access, 142 bool requires_incognito_access,
143 const GURL& event_url) { 143 const GURL& event_url) {
144 v8::Context::Scope context_scope(context->context); 144 v8::Context::Scope context_scope(context->context);
145 145
146 bool incognito_permissions_ok = (!requires_incognito_access || 146 bool cross_profile_ok = (!requires_incognito_access ||
147 ExtensionProcessBindings::HasIncognitoEnabled(context->extension_id)); 147 ExtensionProcessBindings::AllowCrossProfile(context->extension_id));
148 if (!incognito_permissions_ok) 148 if (!cross_profile_ok)
149 return false; 149 return false;
150 150
151 // During unit tests, we might be invoked without a v8 context. In these 151 // During unit tests, we might be invoked without a v8 context. In these
152 // cases, we only allow empty event_urls and short-circuit before retrieving 152 // cases, we only allow empty event_urls and short-circuit before retrieving
153 // the render view from the current context. 153 // the render view from the current context.
154 if (!event_url.is_valid()) 154 if (!event_url.is_valid())
155 return true; 155 return true;
156 156
157 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext(); 157 RenderView* renderview = bindings_utils::GetRenderViewForCurrentContext();
158 bool url_permissions_ok = (!event_url.is_valid() || 158 bool url_permissions_ok = (!event_url.is_valid() ||
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 // TODO(rafaelw): Consider only doing this check if function_name == 355 // TODO(rafaelw): Consider only doing this check if function_name ==
356 // "Event.dispatchJSON". 356 // "Event.dispatchJSON".
357 #ifdef _DEBUG 357 #ifdef _DEBUG
358 if (!retval.IsEmpty() && !retval->IsUndefined()) { 358 if (!retval.IsEmpty() && !retval->IsUndefined()) {
359 std::string error = *v8::String::AsciiValue(retval); 359 std::string error = *v8::String::AsciiValue(retval);
360 DCHECK(false) << error; 360 DCHECK(false) << error;
361 } 361 }
362 #endif 362 #endif
363 } 363 }
364 } 364 }
OLDNEW
« no previous file with comments | « chrome/common/render_messages_internal.h ('k') | chrome/renderer/extensions/extension_process_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698