Chromium Code Reviews| 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" | 9 #include "chrome/browser/guest_view/app_view/app_view_guest.h" |
| 10 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" | 10 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h" |
| 11 #include "chrome/browser/guest_view/guest_view_constants.h" | 11 #include "chrome/browser/guest_view/guest_view_constants.h" |
| 12 #include "chrome/browser/guest_view/guest_view_manager.h" | 12 #include "chrome/browser/guest_view/guest_view_manager.h" |
| 13 #include "chrome/browser/guest_view/web_view/web_view_guest.h" | 13 #include "chrome/browser/guest_view/web_view/web_view_guest.h" |
| 14 #include "chrome/common/content_settings.h" | 14 #include "chrome/common/content_settings.h" |
| 15 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
| 16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 19 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 20 #include "extensions/browser/event_router.h" | 20 #include "extensions/browser/event_router.h" |
| 21 #include "extensions/browser/extension_registry.h" | |
| 22 #include "extensions/common/features/feature.h" | |
| 21 #include "third_party/WebKit/public/web/WebInputEvent.h" | 23 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 22 | 24 |
| 23 using content::WebContents; | 25 using content::WebContents; |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 27 typedef std::map<std::string, GuestViewBase::GuestCreationCallback> | 29 typedef std::map<std::string, GuestViewBase::GuestCreationCallback> |
| 28 GuestViewCreationMap; | 30 GuestViewCreationMap; |
| 29 static base::LazyInstance<GuestViewCreationMap> guest_view_registry = | 31 static base::LazyInstance<GuestViewCreationMap> guest_view_registry = |
| 30 LAZY_INSTANCE_INITIALIZER; | 32 LAZY_INSTANCE_INITIALIZER; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 int guest_instance_id) | 91 int guest_instance_id) |
| 90 : embedder_web_contents_(NULL), | 92 : embedder_web_contents_(NULL), |
| 91 embedder_render_process_id_(0), | 93 embedder_render_process_id_(0), |
| 92 browser_context_(browser_context), | 94 browser_context_(browser_context), |
| 93 guest_instance_id_(guest_instance_id), | 95 guest_instance_id_(guest_instance_id), |
| 94 view_instance_id_(guestview::kInstanceIDNone), | 96 view_instance_id_(guestview::kInstanceIDNone), |
| 95 initialized_(false), | 97 initialized_(false), |
| 96 weak_ptr_factory_(this) { | 98 weak_ptr_factory_(this) { |
| 97 } | 99 } |
| 98 | 100 |
| 99 void GuestViewBase::Init( | 101 void GuestViewBase::Init(const std::string& embedder_extension_id, |
| 100 const std::string& embedder_extension_id, | 102 int embedder_render_process_id, |
| 101 int embedder_render_process_id, | 103 content::WebContents* web_contents, |
| 102 const base::DictionaryValue& create_params, | 104 const base::DictionaryValue& create_params, |
| 103 const WebContentsCreatedCallback& callback) { | 105 const WebContentsCreatedCallback& callback) { |
| 104 if (initialized_) | 106 if (initialized_) |
| 105 return; | 107 return; |
| 106 initialized_ = true; | 108 initialized_ = true; |
| 107 | 109 |
| 108 if (!CanEmbedderUseGuestView(embedder_extension_id)) { | 110 extensions::Feature* feature = GetFeature(); |
| 111 CHECK(feature); | |
| 112 | |
| 113 const extensions::Extension* embedder_extension = | |
| 114 extensions::ExtensionRegistry::Get(browser_context_) | |
| 115 ->enabled_extensions() | |
| 116 .GetByID(embedder_extension_id); | |
| 117 | |
| 118 extensions::Feature::Availability availability = | |
| 119 feature->IsAvailableToContext( | |
| 120 embedder_extension, | |
| 121 // TODO: determine the correct context type from the process ID. | |
|
not at google - send to devlin
2014/07/31 22:07:45
There is a CL I need to write before being able to
| |
| 122 extensions::Feature::BLESSED_EXTENSION_CONTEXT, | |
| 123 web_contents->GetLastCommittedURL()); | |
| 124 if (!availability.is_available()) { | |
| 109 callback.Run(NULL); | 125 callback.Run(NULL); |
| 110 return; | 126 return; |
| 111 } | 127 } |
| 112 | 128 |
| 113 CreateWebContents(embedder_extension_id, | 129 CreateWebContents(embedder_extension_id, |
| 114 embedder_render_process_id, | 130 embedder_render_process_id, |
| 115 create_params, | 131 create_params, |
| 116 base::Bind(&GuestViewBase::CompleteInit, | 132 base::Bind(&GuestViewBase::CompleteInit, |
| 117 AsWeakPtr(), | 133 AsWeakPtr(), |
| 118 embedder_extension_id, | 134 embedder_extension_id, |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 384 guest_web_contents); | 400 guest_web_contents); |
| 385 callback.Run(guest_web_contents); | 401 callback.Run(guest_web_contents); |
| 386 } | 402 } |
| 387 | 403 |
| 388 // static | 404 // static |
| 389 void GuestViewBase::RegisterGuestViewTypes() { | 405 void GuestViewBase::RegisterGuestViewTypes() { |
| 390 AppViewGuest::Register(); | 406 AppViewGuest::Register(); |
| 391 ExtensionOptionsGuest::Register(); | 407 ExtensionOptionsGuest::Register(); |
| 392 WebViewGuest::Register(); | 408 WebViewGuest::Register(); |
| 393 } | 409 } |
| OLD | NEW |