Chromium Code Reviews| Index: chrome_frame/utils.cc |
| =================================================================== |
| --- chrome_frame/utils.cc (revision 68604) |
| +++ chrome_frame/utils.cc (working copy) |
| @@ -29,6 +29,7 @@ |
| #include "chrome/common/chrome_paths_internal.h" |
| #include "chrome/common/url_constants.h" |
| #include "chrome/installer/util/chrome_frame_distribution.h" |
| +#include "chrome_frame/chrome_frame_delegate.h" |
| #include "chrome_frame/extra_system_apis.h" |
| #include "chrome_frame/html_utils.h" |
| #include "chrome_frame/policy_settings.h" |
| @@ -39,6 +40,9 @@ |
| #include "net/base/escape.h" |
| #include "net/http/http_util.h" |
| +// Include without path to make GYP build see it. |
| +#include "chrome_tab.h" // NOLINT |
| + |
| using base::win::RegKey; |
| using base::win::ScopedComPtr; |
| @@ -1423,44 +1427,30 @@ |
| profile_name_.clear(); |
| } |
| -bool CanNavigate(const GURL& url, IInternetSecurityManager* security_manager, |
| - bool is_privileged) { |
| +bool CanNavigate(const GURL& url, |
| + NavigationConstraints* navigation_constraints) { |
| if (!url.is_valid()) { |
| DLOG(ERROR) << "Invalid URL passed to InitiateNavigation: " << url; |
| return false; |
| } |
| + if (!navigation_constraints) |
|
amit
2010/12/10 23:56:17
We must have navigation_constraints, so crash if w
ananta
2010/12/11 02:11:11
Replaced with a NOTREACHED and return false.
|
| + return true; |
| + |
| // No sanity checks if unsafe URLs are allowed |
| - if (GetConfigBool(false, kAllowUnsafeURLs)) |
| + if (navigation_constraints->AllowUnsafeUrls()) |
| return true; |
| - if (!IsValidUrlScheme(url, is_privileged)) { |
| + if (!navigation_constraints->IsSchemeAllowed(url)) { |
| DLOG(WARNING) << __FUNCTION__ << " Disallowing navigation to url: " << url; |
| return false; |
| } |
| - // Allow only about:blank or about:version |
| - if (url.SchemeIs(chrome::kAboutScheme)) { |
| - if (!LowerCaseEqualsASCII(url.spec(), chrome::kAboutBlankURL) && |
| - !LowerCaseEqualsASCII(url.spec(), chrome::kAboutVersionURL)) { |
| - DLOG(WARNING) << __FUNCTION__ |
| - << " Disallowing navigation to about url: " << url; |
| - return false; |
| - } |
| + if (!navigation_constraints->IsZoneAllowed(url)) { |
| + DLOG(WARNING) << __FUNCTION__ |
| + << " Disallowing navigation to restricted url: " << url; |
| + return false; |
| } |
| - |
| - // Prevent navigations to URLs in untrusted zone, even in Firefox. |
| - if (security_manager) { |
| - DWORD zone = URLZONE_INVALID; |
| - std::wstring unicode_url = UTF8ToWide(url.spec()); |
| - security_manager->MapUrlToZone(unicode_url.c_str(), &zone, 0); |
| - if (zone == URLZONE_UNTRUSTED) { |
| - DLOG(WARNING) << __FUNCTION__ |
| - << " Disallowing navigation to restricted url: " << url; |
| - return false; |
| - } |
| - } |
| - |
| return true; |
| } |
| @@ -1576,3 +1566,14 @@ |
| ++url_list; |
| } |
| } |
| + |
| +bool IsChromeFrameDocument(IWebBrowser2* web_browser) { |
| + ScopedComPtr<IDispatch> doc; |
| + web_browser->get_Document(doc.Receive()); |
| + if (doc) { |
| + ScopedComPtr<IChromeFrame> chrome_frame; |
| + if (chrome_frame.QueryFrom(doc) == S_OK) |
| + return true; |
| + } |
| + return false; |
| +} |