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

Side by Side Diff: chrome/browser/chrome_content_browser_client.cc

Issue 237533008: Refactor GuestView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Solve conflicts. Created 6 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative/declarative_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/chrome_content_browser_client.h" 5 #include "chrome/browser/chrome_content_browser_client.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 23 matching lines...) Expand all
34 #include "chrome/browser/download/download_prefs.h" 34 #include "chrome/browser/download/download_prefs.h"
35 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 35 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" 36 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h"
37 #include "chrome/browser/extensions/extension_service.h" 37 #include "chrome/browser/extensions/extension_service.h"
38 #include "chrome/browser/extensions/extension_util.h" 38 #include "chrome/browser/extensions/extension_util.h"
39 #include "chrome/browser/extensions/extension_web_ui.h" 39 #include "chrome/browser/extensions/extension_web_ui.h"
40 #include "chrome/browser/extensions/extension_webkit_preferences.h" 40 #include "chrome/browser/extensions/extension_webkit_preferences.h"
41 #include "chrome/browser/extensions/suggest_permission_util.h" 41 #include "chrome/browser/extensions/suggest_permission_util.h"
42 #include "chrome/browser/geolocation/chrome_access_token_store.h" 42 #include "chrome/browser/geolocation/chrome_access_token_store.h"
43 #include "chrome/browser/google/google_util.h" 43 #include "chrome/browser/google/google_util.h"
44 #include "chrome/browser/guestview/adview/adview_guest.h" 44 #include "chrome/browser/guest_view/ad_view/ad_view_guest.h"
45 #include "chrome/browser/guestview/guestview.h" 45 #include "chrome/browser/guest_view/guest_view_base.h"
46 #include "chrome/browser/guestview/guestview_constants.h" 46 #include "chrome/browser/guest_view/guest_view_constants.h"
47 #include "chrome/browser/guestview/webview/webview_guest.h" 47 #include "chrome/browser/guest_view/web_view/web_view_guest.h"
48 #include "chrome/browser/media/cast_transport_host_filter.h" 48 #include "chrome/browser/media/cast_transport_host_filter.h"
49 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 49 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
50 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h" 50 #include "chrome/browser/metrics/chrome_browser_main_extra_parts_metrics.h"
51 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h" 51 #include "chrome/browser/nacl_host/nacl_browser_delegate_impl.h"
52 #include "chrome/browser/net/chrome_net_log.h" 52 #include "chrome/browser/net/chrome_net_log.h"
53 #include "chrome/browser/notifications/desktop_notification_service.h" 53 #include "chrome/browser/notifications/desktop_notification_service.h"
54 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 54 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
55 #include "chrome/browser/platform_util.h" 55 #include "chrome/browser/platform_util.h"
56 #include "chrome/browser/plugins/plugin_info_message_filter.h" 56 #include "chrome/browser/plugins/plugin_info_message_filter.h"
57 #include "chrome/browser/prerender/prerender_final_status.h" 57 #include "chrome/browser/prerender/prerender_final_status.h"
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 bool can_be_default, 764 bool can_be_default,
765 std::string* partition_domain, 765 std::string* partition_domain,
766 std::string* partition_name, 766 std::string* partition_name,
767 bool* in_memory) { 767 bool* in_memory) {
768 // Default to the browser-wide storage partition and override based on |site| 768 // Default to the browser-wide storage partition and override based on |site|
769 // below. 769 // below.
770 partition_domain->clear(); 770 partition_domain->clear();
771 partition_name->clear(); 771 partition_name->clear();
772 *in_memory = false; 772 *in_memory = false;
773 773
774 bool success = GuestView::GetGuestPartitionConfigForSite( 774 bool success = GuestViewBase::GetGuestPartitionConfigForSite(
775 site, partition_domain, partition_name, in_memory); 775 site, partition_domain, partition_name, in_memory);
776 776
777 if (!success && site.SchemeIs(extensions::kExtensionScheme)) { 777 if (!success && site.SchemeIs(extensions::kExtensionScheme)) {
778 // If |can_be_default| is false, the caller is stating that the |site| 778 // If |can_be_default| is false, the caller is stating that the |site|
779 // should be parsed as if it had isolated storage. In particular it is 779 // should be parsed as if it had isolated storage. In particular it is
780 // important to NOT check ExtensionService for the is_storage_isolated() 780 // important to NOT check ExtensionService for the is_storage_isolated()
781 // attribute because this code path is run during Extension uninstall 781 // attribute because this code path is run during Extension uninstall
782 // to do cleanup after the Extension has already been unloaded from the 782 // to do cleanup after the Extension has already been unloaded from the
783 // ExtensionService. 783 // ExtensionService.
784 bool is_isolated = !can_be_default; 784 bool is_isolated = !can_be_default;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 830
831 Profile* profile = Profile::FromBrowserContext( 831 Profile* profile = Profile::FromBrowserContext(
832 guest_web_contents->GetBrowserContext()); 832 guest_web_contents->GetBrowserContext());
833 ExtensionService* service = 833 ExtensionService* service =
834 extensions::ExtensionSystem::Get(profile)->extension_service(); 834 extensions::ExtensionSystem::Get(profile)->extension_service();
835 if (!service) { 835 if (!service) {
836 NOTREACHED(); 836 NOTREACHED();
837 return; 837 return;
838 } 838 }
839 839
840 /// TODO(fsamuel): In the future, certain types of GuestViews won't require 840 /// TODO(fsamuel): In the future, certain types of GuestViewBases won't
841 // extension bindings. At that point, we should clear |extension_id| instead 841 // require extension bindings. At that point, we should clear |extension_id|
842 // of exiting early. 842 // instead of exiting early.
843 if (!service->GetExtensionById(extension_id, false)) { 843 if (!extension_id.empty() &&
844 !service->GetExtensionById(extension_id, false)) {
844 NOTREACHED(); 845 NOTREACHED();
845 return; 846 return;
846 } 847 }
847 848
848 if (opener_web_contents) { 849 if (opener_web_contents) {
849 GuestView* guest = GuestView::FromWebContents(opener_web_contents); 850 GuestViewBase* guest = GuestViewBase::FromWebContents(opener_web_contents);
850 if (!guest) { 851 if (!guest) {
851 NOTREACHED(); 852 NOTREACHED();
852 return; 853 return;
853 } 854 }
854 855
855 // Create a new GuestView of the same type as the opener. 856 // Create a new GuestViewBase of the same type as the opener.
856 *guest_delegate = 857 *guest_delegate = GuestViewBase::Create(
857 GuestView::Create(guest_web_contents, 858 guest_web_contents, extension_id, guest->GetViewType());
858 extension_id,
859 guest->GetViewType());
860 return; 859 return;
861 } 860 }
862 861
863 if (!extra_params) { 862 if (!extra_params) {
864 NOTREACHED(); 863 NOTREACHED();
865 return; 864 return;
866 } 865 }
867 std::string api_type; 866 std::string api_type;
868 extra_params->GetString(guestview::kParameterApi, &api_type); 867 extra_params->GetString(guestview::kParameterApi, &api_type);
869 868
870 if (api_type.empty()) 869 if (api_type.empty())
871 return; 870 return;
872 871
873 *guest_delegate = 872 *guest_delegate =
874 GuestView::Create(guest_web_contents, 873 GuestViewBase::Create(guest_web_contents, extension_id, api_type);
875 extension_id,
876 GuestView::GetViewTypeFromString(api_type));
877 } 874 }
878 875
879 void ChromeContentBrowserClient::GuestWebContentsAttached( 876 void ChromeContentBrowserClient::GuestWebContentsAttached(
880 WebContents* guest_web_contents, 877 WebContents* guest_web_contents,
881 WebContents* embedder_web_contents, 878 WebContents* embedder_web_contents,
882 const base::DictionaryValue& extra_params) { 879 const base::DictionaryValue& extra_params) {
883 880 GuestViewBase* guest = GuestViewBase::FromWebContents(guest_web_contents);
884 GuestView* guest = GuestView::FromWebContents(guest_web_contents);
885 if (!guest) { 881 if (!guest) {
886 // It's ok to return here, since we could be running a browser plugin 882 // It's ok to return here, since we could be running a browser plugin
887 // outside an extension, and don't need to attach a 883 // outside an extension, and don't need to attach a
888 // BrowserPluginGuestDelegate in that case; 884 // BrowserPluginGuestDelegate in that case;
889 // e.g. running with flag --enable-browser-plugin-for-all-view-types. 885 // e.g. running with flag --enable-browser-plugin-for-all-view-types.
890 return; 886 return;
891 } 887 }
892 guest->Attach(embedder_web_contents, extra_params); 888 guest->Attach(embedder_web_contents, extra_params);
893 } 889 }
894 890
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 if (switches::IsNewProfileManagement()) 935 if (switches::IsNewProfileManagement())
940 host->AddFilter(new PrincipalsMessageFilter(id)); 936 host->AddFilter(new PrincipalsMessageFilter(id));
941 937
942 host->Send(new ChromeViewMsg_SetIsIncognitoProcess( 938 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
943 profile->IsOffTheRecord())); 939 profile->IsOffTheRecord()));
944 940
945 SendExtensionWebRequestStatusToHost(host); 941 SendExtensionWebRequestStatusToHost(host);
946 942
947 RendererContentSettingRules rules; 943 RendererContentSettingRules rules;
948 if (host->IsGuest()) { 944 if (host->IsGuest()) {
949 GuestView::GetDefaultContentSettingRules(&rules, profile->IsOffTheRecord()); 945 GuestViewBase::GetDefaultContentSettingRules(&rules,
946 profile->IsOffTheRecord());
950 } else { 947 } else {
951 GetRendererContentSettingRules( 948 GetRendererContentSettingRules(
952 profile->GetHostContentSettingsMap(), &rules); 949 profile->GetHostContentSettingsMap(), &rules);
953 } 950 }
954 host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); 951 host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
955 } 952 }
956 953
957 GURL ChromeContentBrowserClient::GetEffectiveURL( 954 GURL ChromeContentBrowserClient::GetEffectiveURL(
958 content::BrowserContext* browser_context, const GURL& url) { 955 content::BrowserContext* browser_context, const GURL& url) {
959 Profile* profile = Profile::FromBrowserContext(browser_context); 956 Profile* profile = Profile::FromBrowserContext(browser_context);
(...skipping 1717 matching lines...) Expand 10 before | Expand all | Expand 10 after
2677 switches::kDisableWebRtcEncryption, 2674 switches::kDisableWebRtcEncryption,
2678 }; 2675 };
2679 to_command_line->CopySwitchesFrom(from_command_line, 2676 to_command_line->CopySwitchesFrom(from_command_line,
2680 kWebRtcDevSwitchNames, 2677 kWebRtcDevSwitchNames,
2681 arraysize(kWebRtcDevSwitchNames)); 2678 arraysize(kWebRtcDevSwitchNames));
2682 } 2679 }
2683 } 2680 }
2684 #endif // defined(ENABLE_WEBRTC) 2681 #endif // defined(ENABLE_WEBRTC)
2685 2682
2686 } // namespace chrome 2683 } // namespace chrome
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative/declarative_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698