OLD | NEW |
---|---|
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_frame/utils.h" | 5 #include "chrome_frame/utils.h" |
6 | 6 |
7 #include <htiframe.h> | 7 #include <htiframe.h> |
8 #include <mshtml.h> | 8 #include <mshtml.h> |
9 #include <shlobj.h> | 9 #include <shlobj.h> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "base/stringprintf.h" | 22 #include "base/stringprintf.h" |
23 #include "base/thread_local.h" | 23 #include "base/thread_local.h" |
24 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
25 #include "base/win/registry.h" | 25 #include "base/win/registry.h" |
26 #include "base/win/scoped_bstr.h" | 26 #include "base/win/scoped_bstr.h" |
27 #include "base/win/scoped_comptr.h" | 27 #include "base/win/scoped_comptr.h" |
28 #include "base/win/scoped_variant.h" | 28 #include "base/win/scoped_variant.h" |
29 #include "chrome/common/chrome_paths_internal.h" | 29 #include "chrome/common/chrome_paths_internal.h" |
30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
31 #include "chrome/installer/util/chrome_frame_distribution.h" | 31 #include "chrome/installer/util/chrome_frame_distribution.h" |
32 #include "chrome_frame/chrome_frame_delegate.h" | |
32 #include "chrome_frame/extra_system_apis.h" | 33 #include "chrome_frame/extra_system_apis.h" |
33 #include "chrome_frame/html_utils.h" | 34 #include "chrome_frame/html_utils.h" |
34 #include "chrome_frame/policy_settings.h" | 35 #include "chrome_frame/policy_settings.h" |
35 #include "chrome_frame/simple_resource_loader.h" | 36 #include "chrome_frame/simple_resource_loader.h" |
36 #include "googleurl/src/gurl.h" | 37 #include "googleurl/src/gurl.h" |
37 #include "googleurl/src/url_canon.h" | 38 #include "googleurl/src/url_canon.h" |
38 #include "grit/chromium_strings.h" | 39 #include "grit/chromium_strings.h" |
39 #include "net/base/escape.h" | 40 #include "net/base/escape.h" |
40 #include "net/http/http_util.h" | 41 #include "net/http/http_util.h" |
41 | 42 |
43 // Include without path to make GYP build see it. | |
44 #include "chrome_tab.h" // NOLINT | |
45 | |
42 using base::win::RegKey; | 46 using base::win::RegKey; |
43 using base::win::ScopedComPtr; | 47 using base::win::ScopedComPtr; |
44 | 48 |
45 // Note that these values are all lower case and are compared to | 49 // Note that these values are all lower case and are compared to |
46 // lower-case-transformed values. | 50 // lower-case-transformed values. |
47 const wchar_t kMetaTag[] = L"meta"; | 51 const wchar_t kMetaTag[] = L"meta"; |
48 const wchar_t kHttpEquivAttribName[] = L"http-equiv"; | 52 const wchar_t kHttpEquivAttribName[] = L"http-equiv"; |
49 const wchar_t kContentAttribName[] = L"content"; | 53 const wchar_t kContentAttribName[] = L"content"; |
50 const wchar_t kXUACompatValue[] = L"x-ua-compatible"; | 54 const wchar_t kXUACompatValue[] = L"x-ua-compatible"; |
51 const wchar_t kBodyTag[] = L"body"; | 55 const wchar_t kBodyTag[] = L"body"; |
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1416 | 1420 |
1417 void ChromeFrameUrl::Reset() { | 1421 void ChromeFrameUrl::Reset() { |
1418 attach_to_external_tab_ = false; | 1422 attach_to_external_tab_ = false; |
1419 is_chrome_protocol_ = false; | 1423 is_chrome_protocol_ = false; |
1420 cookie_ = 0; | 1424 cookie_ = 0; |
1421 dimensions_.SetRect(0, 0, 0, 0); | 1425 dimensions_.SetRect(0, 0, 0, 0); |
1422 disposition_ = 0; | 1426 disposition_ = 0; |
1423 profile_name_.clear(); | 1427 profile_name_.clear(); |
1424 } | 1428 } |
1425 | 1429 |
1426 bool CanNavigate(const GURL& url, IInternetSecurityManager* security_manager, | 1430 bool CanNavigate(const GURL& url, |
1427 bool is_privileged) { | 1431 NavigationConstraints* navigation_constraints) { |
1428 if (!url.is_valid()) { | 1432 if (!url.is_valid()) { |
1429 DLOG(ERROR) << "Invalid URL passed to InitiateNavigation: " << url; | 1433 DLOG(ERROR) << "Invalid URL passed to InitiateNavigation: " << url; |
1430 return false; | 1434 return false; |
1431 } | 1435 } |
1432 | 1436 |
1433 // No sanity checks if unsafe URLs are allowed | 1437 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.
| |
1434 if (GetConfigBool(false, kAllowUnsafeURLs)) | |
1435 return true; | 1438 return true; |
1436 | 1439 |
1437 if (!IsValidUrlScheme(url, is_privileged)) { | 1440 // No sanity checks if unsafe URLs are allowed |
1441 if (navigation_constraints->AllowUnsafeUrls()) | |
1442 return true; | |
1443 | |
1444 if (!navigation_constraints->IsSchemeAllowed(url)) { | |
1438 DLOG(WARNING) << __FUNCTION__ << " Disallowing navigation to url: " << url; | 1445 DLOG(WARNING) << __FUNCTION__ << " Disallowing navigation to url: " << url; |
1439 return false; | 1446 return false; |
1440 } | 1447 } |
1441 | 1448 |
1442 // Allow only about:blank or about:version | 1449 if (!navigation_constraints->IsZoneAllowed(url)) { |
1443 if (url.SchemeIs(chrome::kAboutScheme)) { | 1450 DLOG(WARNING) << __FUNCTION__ |
1444 if (!LowerCaseEqualsASCII(url.spec(), chrome::kAboutBlankURL) && | 1451 << " Disallowing navigation to restricted url: " << url; |
1445 !LowerCaseEqualsASCII(url.spec(), chrome::kAboutVersionURL)) { | 1452 return false; |
1446 DLOG(WARNING) << __FUNCTION__ | |
1447 << " Disallowing navigation to about url: " << url; | |
1448 return false; | |
1449 } | |
1450 } | 1453 } |
1451 | |
1452 // Prevent navigations to URLs in untrusted zone, even in Firefox. | |
1453 if (security_manager) { | |
1454 DWORD zone = URLZONE_INVALID; | |
1455 std::wstring unicode_url = UTF8ToWide(url.spec()); | |
1456 security_manager->MapUrlToZone(unicode_url.c_str(), &zone, 0); | |
1457 if (zone == URLZONE_UNTRUSTED) { | |
1458 DLOG(WARNING) << __FUNCTION__ | |
1459 << " Disallowing navigation to restricted url: " << url; | |
1460 return false; | |
1461 } | |
1462 } | |
1463 | |
1464 return true; | 1454 return true; |
1465 } | 1455 } |
1466 | 1456 |
1467 void PinModule() { | 1457 void PinModule() { |
1468 static bool s_pinned = false; | 1458 static bool s_pinned = false; |
1469 if (!s_pinned && !IsUnpinnedMode()) { | 1459 if (!s_pinned && !IsUnpinnedMode()) { |
1470 FilePath module_path; | 1460 FilePath module_path; |
1471 if (PathService::Get(base::FILE_MODULE, &module_path)) { | 1461 if (PathService::Get(base::FILE_MODULE, &module_path)) { |
1472 HMODULE unused; | 1462 HMODULE unused; |
1473 if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN, | 1463 if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_PIN, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1569 | 1559 |
1570 void EnumerateKeyValues(HKEY parent_key, const wchar_t* sub_key_name, | 1560 void EnumerateKeyValues(HKEY parent_key, const wchar_t* sub_key_name, |
1571 std::vector<std::wstring>* values) { | 1561 std::vector<std::wstring>* values) { |
1572 DCHECK(values); | 1562 DCHECK(values); |
1573 base::win::RegistryValueIterator url_list(parent_key, sub_key_name); | 1563 base::win::RegistryValueIterator url_list(parent_key, sub_key_name); |
1574 while (url_list.Valid()) { | 1564 while (url_list.Valid()) { |
1575 values->push_back(url_list.Value()); | 1565 values->push_back(url_list.Value()); |
1576 ++url_list; | 1566 ++url_list; |
1577 } | 1567 } |
1578 } | 1568 } |
1569 | |
1570 bool IsChromeFrameDocument(IWebBrowser2* web_browser) { | |
1571 ScopedComPtr<IDispatch> doc; | |
1572 web_browser->get_Document(doc.Receive()); | |
1573 if (doc) { | |
1574 ScopedComPtr<IChromeFrame> chrome_frame; | |
1575 if (chrome_frame.QueryFrom(doc) == S_OK) | |
1576 return true; | |
1577 } | |
1578 return false; | |
1579 } | |
OLD | NEW |