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

Side by Side Diff: chrome/common/extensions/extension_set.cc

Issue 10598006: Browser tag shim (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/common/extensions/extension_set.h" 5 #include "chrome/common/extensions/extension_set.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/common/extensions/extension.h" 8 #include "chrome/common/extensions/extension.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
10 12
11 using WebKit::WebSecurityOrigin; 13 using WebKit::WebSecurityOrigin;
14 using WebKit::WebString;
12 using extensions::Extension; 15 using extensions::Extension;
13 16
14 ExtensionURLInfo::ExtensionURLInfo(WebSecurityOrigin origin, const GURL& url) 17 ExtensionURLInfo::ExtensionURLInfo(WebSecurityOrigin origin, const GURL& url)
15 : origin_(origin), 18 : origin_(origin),
16 url_(url) { 19 url_(url) {
17 DCHECK(!origin_.isNull()); 20 DCHECK(!origin_.isNull());
18 } 21 }
19 22
20 ExtensionURLInfo::ExtensionURLInfo(const GURL& url) 23 ExtensionURLInfo::ExtensionURLInfo(const GURL& url)
21 : url_(url) { 24 : url_(url) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 72
70 const Extension* extension = GetExtensionOrAppByURL(info); 73 const Extension* extension = GetExtensionOrAppByURL(info);
71 if (!extension) 74 if (!extension)
72 return ""; 75 return "";
73 76
74 return extension->id(); 77 return extension->id();
75 } 78 }
76 79
77 const Extension* ExtensionSet::GetExtensionOrAppByURL( 80 const Extension* ExtensionSet::GetExtensionOrAppByURL(
78 const ExtensionURLInfo& info) const { 81 const ExtensionURLInfo& info) const {
79 // In the common case, the document's origin will correspond to its URL, 82 if (!info.origin().isNull()) {
80 // but in some rare cases involving sandboxing, the two will be different. 83 // In the common case, the document's origin will correspond to its URL,
81 // We catch those cases by checking whether the document's origin is unique. 84 // but in some rare cases involving sandboxing, the two will be different.
82 // If that's not the case, then we conclude that the document's security 85 // We catch those cases by checking whether the document's origin is unique.
83 // context is well-described by its URL and proceed to use only the URL. 86 if (info.origin().isUnique())
84 if (!info.origin().isNull() && info.origin().isUnique()) 87 return NULL;
85 return NULL; 88
89 // Additionally, the url will initialy be null during a window.open call
Mihai Parparita -not on Chrome 2012/06/21 01:30:11 Adam, you expressed a wish to always use the origi
90 // with an extension URL, but the origin will be set correctly. If we have
91 // an extension host origin, then that should be enough to determine which
92 // extension we need.
93 if (info.origin().protocol() ==
94 WebString::fromUTF8(chrome::kExtensionScheme))
95 return GetByID(info.origin().host().utf8().data());
96 }
86 97
87 if (info.url().SchemeIs(chrome::kExtensionScheme)) 98 if (info.url().SchemeIs(chrome::kExtensionScheme))
88 return GetByID(info.url().host()); 99 return GetByID(info.url().host());
89 100
90 return GetHostedAppByURL(info); 101 return GetHostedAppByURL(info);
91 } 102 }
92 103
93 const Extension* ExtensionSet::GetHostedAppByURL( 104 const Extension* ExtensionSet::GetHostedAppByURL(
94 const ExtensionURLInfo& info) const { 105 const ExtensionURLInfo& info) const {
95 for (ExtensionMap::const_iterator iter = extensions_.begin(); 106 for (ExtensionMap::const_iterator iter = extensions_.begin();
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return true; 160 return true;
150 161
151 if (info.url().SchemeIs(chrome::kExtensionScheme)) { 162 if (info.url().SchemeIs(chrome::kExtensionScheme)) {
152 const Extension* extension = GetByID(info.url().host()); 163 const Extension* extension = GetByID(info.url().host());
153 if (extension) { 164 if (extension) {
154 return extension->IsSandboxedPage(info.url().path()); 165 return extension->IsSandboxedPage(info.url().path());
155 } 166 }
156 } 167 }
157 return false; 168 return false;
158 } 169 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698