| 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/guest_view/guest_view_base.h" | 5 #include "chrome/browser/guest_view/guest_view_base.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/guest_view/app_view/app_view_guest.h" | |
| 10 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" | |
| 11 #include "chrome/browser/guest_view/guest_view_constants.h" | 9 #include "chrome/browser/guest_view/guest_view_constants.h" |
| 12 #include "chrome/browser/guest_view/guest_view_manager.h" | 10 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 13 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | |
| 14 #include "chrome/common/content_settings.h" | |
| 15 #include "content/public/browser/render_frame_host.h" | 11 #include "content/public/browser/render_frame_host.h" |
| 16 #include "content/public/browser/render_process_host.h" | 12 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 18 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
| 16 #include "extensions/browser/api/extensions_api_client.h" |
| 20 #include "extensions/browser/event_router.h" | 17 #include "extensions/browser/event_router.h" |
| 21 #include "third_party/WebKit/public/web/WebInputEvent.h" | 18 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 22 | 19 |
| 23 using content::WebContents; | 20 using content::WebContents; |
| 24 | 21 |
| 25 namespace { | 22 namespace { |
| 26 | 23 |
| 27 typedef std::map<std::string, GuestViewBase::GuestCreationCallback> | 24 typedef std::map<std::string, GuestViewBase::GuestCreationCallback> |
| 28 GuestViewCreationMap; | 25 GuestViewCreationMap; |
| 29 static base::LazyInstance<GuestViewCreationMap> guest_view_registry = | 26 static base::LazyInstance<GuestViewCreationMap> guest_view_registry = |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 return NULL; | 218 return NULL; |
| 222 | 219 |
| 223 return GuestViewBase::FromWebContents(guest_web_contents); | 220 return GuestViewBase::FromWebContents(guest_web_contents); |
| 224 } | 221 } |
| 225 | 222 |
| 226 // static | 223 // static |
| 227 bool GuestViewBase::IsGuest(WebContents* web_contents) { | 224 bool GuestViewBase::IsGuest(WebContents* web_contents) { |
| 228 return !!GuestViewBase::FromWebContents(web_contents); | 225 return !!GuestViewBase::FromWebContents(web_contents); |
| 229 } | 226 } |
| 230 | 227 |
| 231 // static | |
| 232 void GuestViewBase::GetDefaultContentSettingRules( | |
| 233 RendererContentSettingRules* rules, | |
| 234 bool incognito) { | |
| 235 rules->image_rules.push_back( | |
| 236 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), | |
| 237 ContentSettingsPattern::Wildcard(), | |
| 238 CONTENT_SETTING_ALLOW, | |
| 239 std::string(), | |
| 240 incognito)); | |
| 241 | |
| 242 rules->script_rules.push_back( | |
| 243 ContentSettingPatternSource(ContentSettingsPattern::Wildcard(), | |
| 244 ContentSettingsPattern::Wildcard(), | |
| 245 CONTENT_SETTING_ALLOW, | |
| 246 std::string(), | |
| 247 incognito)); | |
| 248 } | |
| 249 | |
| 250 base::WeakPtr<GuestViewBase> GuestViewBase::AsWeakPtr() { | 228 base::WeakPtr<GuestViewBase> GuestViewBase::AsWeakPtr() { |
| 251 return weak_ptr_factory_.GetWeakPtr(); | 229 return weak_ptr_factory_.GetWeakPtr(); |
| 252 } | 230 } |
| 253 | 231 |
| 254 bool GuestViewBase::IsAutoSizeSupported() const { | 232 bool GuestViewBase::IsAutoSizeSupported() const { |
| 255 return false; | 233 return false; |
| 256 } | 234 } |
| 257 | 235 |
| 258 bool GuestViewBase::IsDragAndDropEnabled() const { | 236 bool GuestViewBase::IsDragAndDropEnabled() const { |
| 259 return false; | 237 return false; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 return; | 414 return; |
| 437 } | 415 } |
| 438 InitWithWebContents(embedder_extension_id, | 416 InitWithWebContents(embedder_extension_id, |
| 439 embedder_render_process_id, | 417 embedder_render_process_id, |
| 440 guest_web_contents); | 418 guest_web_contents); |
| 441 callback.Run(guest_web_contents); | 419 callback.Run(guest_web_contents); |
| 442 } | 420 } |
| 443 | 421 |
| 444 // static | 422 // static |
| 445 void GuestViewBase::RegisterGuestViewTypes() { | 423 void GuestViewBase::RegisterGuestViewTypes() { |
| 446 AppViewGuest::Register(); | 424 extensions::ExtensionsAPIClient::Get()->RegisterGuestViewType(); |
| 447 ExtensionOptionsGuest::Register(); | |
| 448 WebViewGuest::Register(); | |
| 449 } | 425 } |
| OLD | NEW |