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

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: Remove static iniitalizer by chaning static constent string to char[]. 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
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 !CommandLine::ForCurrentProcess()->HasSwitch( 845 !CommandLine::ForCurrentProcess()->HasSwitch(
845 switches::kEnableBrowserPluginForAllViewTypes)) { 846 switches::kEnableBrowserPluginForAllViewTypes)) {
846 NOTREACHED(); 847 NOTREACHED();
847 return; 848 return;
848 } 849 }
849 850
850 if (opener_web_contents) { 851 if (opener_web_contents) {
851 GuestView* guest = GuestView::FromWebContents(opener_web_contents); 852 GuestViewBase* guest = GuestViewBase::FromWebContents(opener_web_contents);
852 if (!guest) { 853 if (!guest) {
853 NOTREACHED(); 854 NOTREACHED();
854 return; 855 return;
855 } 856 }
856 857
857 // Create a new GuestView of the same type as the opener. 858 // Create a new GuestViewBase of the same type as the opener.
858 *guest_delegate = 859 *guest_delegate = GuestViewBase::Create(
859 GuestView::Create(guest_web_contents, 860 guest_web_contents, extension_id, guest->GetViewType());
860 extension_id,
861 guest->GetViewType());
862 return; 861 return;
863 } 862 }
864 863
865 if (!extra_params) { 864 if (!extra_params) {
866 NOTREACHED(); 865 NOTREACHED();
867 return; 866 return;
868 } 867 }
869 std::string api_type; 868 std::string api_type;
870 extra_params->GetString(guestview::kParameterApi, &api_type); 869 extra_params->GetString(guestview::kParameterApi, &api_type);
871 870
872 if (api_type.empty()) 871 if (api_type.empty())
873 return; 872 return;
874 873
875 *guest_delegate = 874 *guest_delegate =
876 GuestView::Create(guest_web_contents, 875 GuestViewBase::Create(guest_web_contents, extension_id, api_type);
877 extension_id,
878 GuestView::GetViewTypeFromString(api_type));
879 } 876 }
880 877
881 void ChromeContentBrowserClient::GuestWebContentsAttached( 878 void ChromeContentBrowserClient::GuestWebContentsAttached(
882 WebContents* guest_web_contents, 879 WebContents* guest_web_contents,
883 WebContents* embedder_web_contents, 880 WebContents* embedder_web_contents,
884 const base::DictionaryValue& extra_params) { 881 const base::DictionaryValue& extra_params) {
885 882 GuestViewBase* guest = GuestViewBase::FromWebContents(guest_web_contents);
886 GuestView* guest = GuestView::FromWebContents(guest_web_contents);
887 if (!guest) { 883 if (!guest) {
888 // It's ok to return here, since we could be running a browser plugin 884 // It's ok to return here, since we could be running a browser plugin
889 // outside an extension, and don't need to attach a 885 // outside an extension, and don't need to attach a
890 // BrowserPluginGuestDelegate in that case; 886 // BrowserPluginGuestDelegate in that case;
891 // e.g. running with flag --enable-browser-plugin-for-all-view-types. 887 // e.g. running with flag --enable-browser-plugin-for-all-view-types.
892 return; 888 return;
893 } 889 }
894 guest->Attach(embedder_web_contents, extra_params); 890 guest->Attach(embedder_web_contents, extra_params);
895 } 891 }
896 892
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 if (switches::IsNewProfileManagement()) 937 if (switches::IsNewProfileManagement())
942 host->AddFilter(new PrincipalsMessageFilter(id)); 938 host->AddFilter(new PrincipalsMessageFilter(id));
943 939
944 host->Send(new ChromeViewMsg_SetIsIncognitoProcess( 940 host->Send(new ChromeViewMsg_SetIsIncognitoProcess(
945 profile->IsOffTheRecord())); 941 profile->IsOffTheRecord()));
946 942
947 SendExtensionWebRequestStatusToHost(host); 943 SendExtensionWebRequestStatusToHost(host);
948 944
949 RendererContentSettingRules rules; 945 RendererContentSettingRules rules;
950 if (host->IsGuest()) { 946 if (host->IsGuest()) {
951 GuestView::GetDefaultContentSettingRules(&rules, profile->IsOffTheRecord()); 947 GuestViewBase::GetDefaultContentSettingRules(&rules,
948 profile->IsOffTheRecord());
952 } else { 949 } else {
953 GetRendererContentSettingRules( 950 GetRendererContentSettingRules(
954 profile->GetHostContentSettingsMap(), &rules); 951 profile->GetHostContentSettingsMap(), &rules);
955 } 952 }
956 host->Send(new ChromeViewMsg_SetContentSettingRules(rules)); 953 host->Send(new ChromeViewMsg_SetContentSettingRules(rules));
957 } 954 }
958 955
959 GURL ChromeContentBrowserClient::GetEffectiveURL( 956 GURL ChromeContentBrowserClient::GetEffectiveURL(
960 content::BrowserContext* browser_context, const GURL& url) { 957 content::BrowserContext* browser_context, const GURL& url) {
961 Profile* profile = Profile::FromBrowserContext(browser_context); 958 Profile* profile = Profile::FromBrowserContext(browser_context);
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after
2668 switches::kDisableWebRtcEncryption, 2665 switches::kDisableWebRtcEncryption,
2669 }; 2666 };
2670 to_command_line->CopySwitchesFrom(from_command_line, 2667 to_command_line->CopySwitchesFrom(from_command_line,
2671 kWebRtcDevSwitchNames, 2668 kWebRtcDevSwitchNames,
2672 arraysize(kWebRtcDevSwitchNames)); 2669 arraysize(kWebRtcDevSwitchNames));
2673 } 2670 }
2674 } 2671 }
2675 #endif // defined(ENABLE_WEBRTC) 2672 #endif // defined(ENABLE_WEBRTC)
2676 2673
2677 } // namespace chrome 2674 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698