Commit 9c765638 authored by hanxi@chromium.org's avatar hanxi@chromium.org

Remove dependency of chrome in GuestViewBase.

Use ExtensionsAPIClient to register guests.

BUG=352290

Review URL: https://codereview.chromium.org/444113003

Cr-Commit-Position: refs/heads/master@{#288427}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288427 0039d316-1c4b-4281-b951-d872f2087c98
parent 8b92eef6
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/env_vars.h" #include "chrome/common/env_vars.h"
#include "chrome/common/logging_chrome.h" #include "chrome/common/logging_chrome.h"
#include "chrome/common/pepper_permission_util.h" #include "chrome/common/pepper_permission_util.h"
...@@ -562,6 +563,27 @@ float GetDeviceScaleAdjustment() { ...@@ -562,6 +563,27 @@ float GetDeviceScaleAdjustment() {
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
#if defined(ENABLE_EXTENSIONS)
// By default, JavaScript and images are enabled in guest content.
void GetGuestViewDefaultContentSettingRules(
bool incognito,
RendererContentSettingRules* rules) {
rules->image_rules.push_back(
ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),
CONTENT_SETTING_ALLOW,
std::string(),
incognito));
rules->script_rules.push_back(
ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),
CONTENT_SETTING_ALLOW,
std::string(),
incognito));
}
#endif // defined(ENALBE_EXTENSIONS)
} // namespace } // namespace
namespace chrome { namespace chrome {
...@@ -822,8 +844,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch( ...@@ -822,8 +844,7 @@ void ChromeContentBrowserClient::RenderProcessWillLaunch(
RendererContentSettingRules rules; RendererContentSettingRules rules;
if (host->IsIsolatedGuest()) { if (host->IsIsolatedGuest()) {
#if defined(ENABLE_EXTENSIONS) #if defined(ENABLE_EXTENSIONS)
GuestViewBase::GetDefaultContentSettingRules(&rules, GetGuestViewDefaultContentSettingRules(profile->IsOffTheRecord(), &rules);
profile->IsOffTheRecord());
#else #else
NOTREACHED(); NOTREACHED();
#endif #endif
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "chrome/browser/extensions/api/storage/sync_value_store_cache.h" #include "chrome/browser/extensions/api/storage/sync_value_store_cache.h"
#include "chrome/browser/guest_view/app_view/app_view_guest.h" #include "chrome/browser/guest_view/app_view/app_view_guest.h"
#include "chrome/browser/guest_view/extension_options/extension_options_guest.h"
#include "chrome/browser/guest_view/web_view/web_view_guest.h"
#include "content/public/browser/browser_context.h" #include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "device/hid/hid_service.h" #include "device/hid/hid_service.h"
...@@ -67,4 +69,10 @@ device::HidService* ChromeExtensionsAPIClient::GetHidService() { ...@@ -67,4 +69,10 @@ device::HidService* ChromeExtensionsAPIClient::GetHidService() {
return hid_service_.get(); return hid_service_.get();
} }
void ChromeExtensionsAPIClient::RegisterGuestViewTypes() {
AppViewGuest::Register();
ExtensionOptionsGuest::Register();
WebViewGuest::Register();
}
} // namespace extensions } // namespace extensions
...@@ -34,6 +34,7 @@ class ChromeExtensionsAPIClient : public ExtensionsAPIClient { ...@@ -34,6 +34,7 @@ class ChromeExtensionsAPIClient : public ExtensionsAPIClient {
int guest_instance_id, int guest_instance_id,
const std::string& guest_extension_id) OVERRIDE; const std::string& guest_extension_id) OVERRIDE;
virtual device::HidService* GetHidService() OVERRIDE; virtual device::HidService* GetHidService() OVERRIDE;
virtual void RegisterGuestViewTypes() OVERRIDE;
private: private:
scoped_ptr<device::HidService> hid_service_; scoped_ptr<device::HidService> hid_service_;
......
...@@ -6,17 +6,14 @@ ...@@ -6,17 +6,14 @@
#include "base/lazy_instance.h" #include "base/lazy_instance.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/guest_view/app_view/app_view_guest.h"
#include "chrome/browser/guest_view/extension_options/extension_options_guest.h"
#include "chrome/browser/guest_view/guest_view_constants.h" #include "chrome/browser/guest_view/guest_view_constants.h"
#include "chrome/browser/guest_view/guest_view_manager.h" #include "chrome/browser/guest_view/guest_view_manager.h"
#include "chrome/browser/guest_view/web_view/web_view_guest.h"
#include "chrome/common/content_settings.h"
#include "content/public/browser/render_frame_host.h" #include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h" #include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h" #include "content/public/common/url_constants.h"
#include "extensions/browser/api/extensions_api_client.h"
#include "extensions/browser/event_router.h" #include "extensions/browser/event_router.h"
#include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_registry.h"
#include "extensions/browser/process_map.h" #include "extensions/browser/process_map.h"
...@@ -253,25 +250,6 @@ bool GuestViewBase::IsGuest(WebContents* web_contents) { ...@@ -253,25 +250,6 @@ bool GuestViewBase::IsGuest(WebContents* web_contents) {
return !!GuestViewBase::FromWebContents(web_contents); return !!GuestViewBase::FromWebContents(web_contents);
} }
// static
void GuestViewBase::GetDefaultContentSettingRules(
RendererContentSettingRules* rules,
bool incognito) {
rules->image_rules.push_back(
ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),
CONTENT_SETTING_ALLOW,
std::string(),
incognito));
rules->script_rules.push_back(
ContentSettingPatternSource(ContentSettingsPattern::Wildcard(),
ContentSettingsPattern::Wildcard(),
CONTENT_SETTING_ALLOW,
std::string(),
incognito));
}
base::WeakPtr<GuestViewBase> GuestViewBase::AsWeakPtr() { base::WeakPtr<GuestViewBase> GuestViewBase::AsWeakPtr() {
return weak_ptr_factory_.GetWeakPtr(); return weak_ptr_factory_.GetWeakPtr();
} }
...@@ -468,7 +446,5 @@ void GuestViewBase::CompleteInit(const std::string& embedder_extension_id, ...@@ -468,7 +446,5 @@ void GuestViewBase::CompleteInit(const std::string& embedder_extension_id,
// static // static
void GuestViewBase::RegisterGuestViewTypes() { void GuestViewBase::RegisterGuestViewTypes() {
AppViewGuest::Register(); extensions::ExtensionsAPIClient::Get()->RegisterGuestViewTypes();
ExtensionOptionsGuest::Register();
WebViewGuest::Register();
} }
...@@ -67,10 +67,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate, ...@@ -67,10 +67,6 @@ class GuestViewBase : public content::BrowserPluginGuestDelegate,
static bool IsGuest(content::WebContents* web_contents); static bool IsGuest(content::WebContents* web_contents);
// By default, JavaScript and images are enabled in guest content.
static void GetDefaultContentSettingRules(RendererContentSettingRules* rules,
bool incognito);
virtual const char* GetViewType() const = 0; virtual const char* GetViewType() const = 0;
// This method is called after the guest has been attached to an embedder and // This method is called after the guest has been attached to an embedder and
......
...@@ -71,6 +71,8 @@ class ExtensionsAPIClient { ...@@ -71,6 +71,8 @@ class ExtensionsAPIClient {
// Returns the HidService instance for this embedder. // Returns the HidService instance for this embedder.
virtual device::HidService* GetHidService(); virtual device::HidService* GetHidService();
virtual void RegisterGuestViewTypes() {}
// NOTE: If this interface gains too many methods (perhaps more than 20) it // NOTE: If this interface gains too many methods (perhaps more than 20) it
// should be split into one interface per API. // should be split into one interface per API.
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment