OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/extensions/chrome_content_browser_client_extensions_par t.h" | 5 #include "chrome/browser/extensions/chrome_content_browser_client_extensions_par t.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/extensions/extension_web_ui.h" | 14 #include "chrome/browser/extensions/extension_web_ui.h" |
15 #include "chrome/browser/extensions/extension_webkit_preferences.h" | 15 #include "chrome/browser/extensions/extension_webkit_preferences.h" |
16 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" | 16 #include "chrome/browser/media_galleries/fileapi/media_file_system_backend.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/profiles/profile_io_data.h" | 18 #include "chrome/browser/profiles/profile_io_data.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/renderer_host/chrome_extension_message_filter.h" | 20 #include "chrome/browser/renderer_host/chrome_extension_message_filter.h" |
21 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 21 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
22 #include "chrome/common/chrome_constants.h" | 22 #include "chrome/common/chrome_constants.h" |
23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
24 #include "chrome/common/extensions/extension_constants.h" | |
24 #include "chrome/common/extensions/extension_process_policy.h" | 25 #include "chrome/common/extensions/extension_process_policy.h" |
25 #include "components/guest_view/browser/guest_view_message_filter.h" | 26 #include "components/guest_view/browser/guest_view_message_filter.h" |
26 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
27 #include "content/public/browser/browser_url_handler.h" | 28 #include "content/public/browser/browser_url_handler.h" |
29 #include "content/public/browser/page_navigator.h" | |
28 #include "content/public/browser/render_process_host.h" | 30 #include "content/public/browser/render_process_host.h" |
29 #include "content/public/browser/render_view_host.h" | 31 #include "content/public/browser/render_view_host.h" |
30 #include "content/public/browser/resource_dispatcher_host.h" | 32 #include "content/public/browser/resource_dispatcher_host.h" |
31 #include "content/public/browser/site_instance.h" | 33 #include "content/public/browser/site_instance.h" |
32 #include "content/public/browser/storage_partition.h" | 34 #include "content/public/browser/storage_partition.h" |
33 #include "content/public/browser/vpn_service_proxy.h" | 35 #include "content/public/browser/vpn_service_proxy.h" |
34 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
35 #include "content/public/common/content_switches.h" | 37 #include "content/public/common/content_switches.h" |
36 #include "extensions/browser/api/web_request/web_request_api.h" | 38 #include "extensions/browser/api/web_request/web_request_api.h" |
37 #include "extensions/browser/api/web_request/web_request_api_helpers.h" | 39 #include "extensions/browser/api/web_request/web_request_api_helpers.h" |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 | 530 |
529 if (!WebAccessibleResourcesInfo::IsResourceWebAccessible( | 531 if (!WebAccessibleResourcesInfo::IsResourceWebAccessible( |
530 extension, to_url.path())) { | 532 extension, to_url.path())) { |
531 *result = false; | 533 *result = false; |
532 return true; | 534 return true; |
533 } | 535 } |
534 } | 536 } |
535 return false; | 537 return false; |
536 } | 538 } |
537 | 539 |
540 void ChromeContentBrowserClientExtensionsPart::OverrideOpenURLParams( | |
541 content::SiteInstance* site_instance, | |
542 content::OpenURLParams* params) { | |
543 const Extension* extension = | |
544 ExtensionRegistry::Get(site_instance->GetBrowserContext()) | |
545 ->enabled_extensions() | |
546 .GetExtensionOrAppByURL(site_instance->GetSiteURL()); | |
547 if (!extension) | |
548 return; | |
549 | |
550 if (extension->id() == extension_misc::kBookmarkManagerId && | |
551 ui::PageTransitionCoreTypeIs(params->transition, | |
552 ui::PAGE_TRANSITION_LINK)) { | |
553 // Link clicks in the bookmark manager count as bookmarks and as browser- | |
554 // initiated navigations. | |
555 params->transition = ui::PAGE_TRANSITION_AUTO_BOOKMARK; | |
556 params->is_renderer_initiated = false; | |
557 } | |
558 | |
559 // Hide the referrer for extension pages. We don't want sites to see a | |
560 // referrer of chrome-extension://<...>. | |
561 if (extension->is_extension()) | |
Devlin
2016/11/02 22:01:43
Note: this was the behavior prior to https://chrom
Charlie Reis
2016/11/04 23:31:59
Agreed.
| |
562 params->referrer = content::Referrer(); | |
563 } | |
564 | |
538 // static | 565 // static |
539 std::unique_ptr<content::VpnServiceProxy> | 566 std::unique_ptr<content::VpnServiceProxy> |
540 ChromeContentBrowserClientExtensionsPart::GetVpnServiceProxy( | 567 ChromeContentBrowserClientExtensionsPart::GetVpnServiceProxy( |
541 content::BrowserContext* browser_context) { | 568 content::BrowserContext* browser_context) { |
542 #if defined(OS_CHROMEOS) | 569 #if defined(OS_CHROMEOS) |
543 chromeos::VpnService* vpn_service = | 570 chromeos::VpnService* vpn_service = |
544 chromeos::VpnServiceFactory::GetForBrowserContext(browser_context); | 571 chromeos::VpnServiceFactory::GetForBrowserContext(browser_context); |
545 if (!vpn_service) | 572 if (!vpn_service) |
546 return nullptr; | 573 return nullptr; |
547 return vpn_service->GetVpnServiceProxy(); | 574 return vpn_service->GetVpnServiceProxy(); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
687 command_line->AppendSwitch(switches::kExtensionProcess); | 714 command_line->AppendSwitch(switches::kExtensionProcess); |
688 } | 715 } |
689 } | 716 } |
690 | 717 |
691 void ChromeContentBrowserClientExtensionsPart::ResourceDispatcherHostCreated() { | 718 void ChromeContentBrowserClientExtensionsPart::ResourceDispatcherHostCreated() { |
692 content::ResourceDispatcherHost::Get()->RegisterInterceptor( | 719 content::ResourceDispatcherHost::Get()->RegisterInterceptor( |
693 "Origin", kExtensionScheme, base::Bind(&OnHttpHeaderReceived)); | 720 "Origin", kExtensionScheme, base::Bind(&OnHttpHeaderReceived)); |
694 } | 721 } |
695 | 722 |
696 } // namespace extensions | 723 } // namespace extensions |
OLD | NEW |