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 "extensions/browser/guest_view/app_view/app_view_guest.h" | 5 #include "extensions/browser/guest_view/app_view/app_view_guest.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "components/guest_view/browser/guest_view_manager.h" | 8 #include "components/guest_view/browser/guest_view_manager.h" |
9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
10 #include "content/public/common/renderer_preferences.h" | 10 #include "content/public/common/renderer_preferences.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 } | 89 } |
90 | 90 |
91 response_info->app_view_guest->CompleteCreateWebContents( | 91 response_info->app_view_guest->CompleteCreateWebContents( |
92 url, response_info->guest_extension.get(), response_info->callback); | 92 url, response_info->guest_extension.get(), response_info->callback); |
93 | 93 |
94 response_map->erase(guest_instance_id); | 94 response_map->erase(guest_instance_id); |
95 return true; | 95 return true; |
96 } | 96 } |
97 | 97 |
98 // static | 98 // static |
99 GuestViewBase* AppViewGuest::Create(content::WebContents* owner_web_contents) { | 99 GuestViewBase* AppViewGuest::Create(WebContents* owner_web_contents) { |
100 return new AppViewGuest(owner_web_contents); | 100 return new AppViewGuest(owner_web_contents); |
101 } | 101 } |
102 | 102 |
103 AppViewGuest::AppViewGuest(content::WebContents* owner_web_contents) | 103 AppViewGuest::AppViewGuest(WebContents* owner_web_contents) |
104 : GuestView<AppViewGuest>(owner_web_contents), | 104 : GuestView<AppViewGuest>(owner_web_contents), |
105 app_view_guest_delegate_( | 105 app_view_guest_delegate_(ExtensionsAPIClient::Get() |
106 ExtensionsAPIClient::Get()->CreateAppViewGuestDelegate()), | 106 ->CreateAppViewGuestDelegate()), |
107 weak_ptr_factory_(this) { | 107 weak_ptr_factory_(this) { |
108 if (app_view_guest_delegate_) | 108 if (app_view_guest_delegate_) |
109 app_delegate_.reset(app_view_guest_delegate_->CreateAppDelegate()); | 109 app_delegate_.reset(app_view_guest_delegate_->CreateAppDelegate()); |
110 } | 110 } |
111 | 111 |
112 AppViewGuest::~AppViewGuest() { | 112 AppViewGuest::~AppViewGuest() { |
113 } | 113 } |
114 | 114 |
115 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { | 115 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { |
116 if (app_view_guest_delegate_) { | 116 if (app_view_guest_delegate_) { |
117 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params); | 117 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params); |
118 } | 118 } |
119 return false; | 119 return false; |
120 } | 120 } |
121 | 121 |
122 void AppViewGuest::RequestMediaAccessPermission( | 122 void AppViewGuest::RequestMediaAccessPermission( |
123 content::WebContents* web_contents, | 123 WebContents* web_contents, |
124 const content::MediaStreamRequest& request, | 124 const content::MediaStreamRequest& request, |
125 const content::MediaResponseCallback& callback) { | 125 const content::MediaResponseCallback& callback) { |
126 if (!app_delegate_) { | 126 if (!app_delegate_) { |
127 WebContentsDelegate::RequestMediaAccessPermission(web_contents, request, | 127 WebContentsDelegate::RequestMediaAccessPermission(web_contents, request, |
128 callback); | 128 callback); |
129 return; | 129 return; |
130 } | 130 } |
131 const ExtensionSet& enabled_extensions = | 131 const ExtensionSet& enabled_extensions = |
132 ExtensionRegistry::Get(browser_context())->enabled_extensions(); | 132 ExtensionRegistry::Get(browser_context())->enabled_extensions(); |
133 const Extension* guest_extension = | 133 const Extension* guest_extension = |
134 enabled_extensions.GetByID(guest_extension_id_); | 134 enabled_extensions.GetByID(guest_extension_id_); |
135 | 135 |
136 app_delegate_->RequestMediaAccessPermission(web_contents, request, callback, | 136 app_delegate_->RequestMediaAccessPermission(web_contents, request, callback, |
137 guest_extension); | 137 guest_extension); |
138 } | 138 } |
139 | 139 |
140 bool AppViewGuest::CheckMediaAccessPermission( | 140 bool AppViewGuest::CheckMediaAccessPermission(WebContents* web_contents, |
141 content::WebContents* web_contents, | 141 const GURL& security_origin, |
142 const GURL& security_origin, | 142 content::MediaStreamType type) { |
143 content::MediaStreamType type) { | |
144 if (!app_delegate_) { | 143 if (!app_delegate_) { |
145 return WebContentsDelegate::CheckMediaAccessPermission( | 144 return WebContentsDelegate::CheckMediaAccessPermission( |
146 web_contents, security_origin, type); | 145 web_contents, security_origin, type); |
147 } | 146 } |
148 const ExtensionSet& enabled_extensions = | 147 const ExtensionSet& enabled_extensions = |
149 ExtensionRegistry::Get(browser_context())->enabled_extensions(); | 148 ExtensionRegistry::Get(browser_context())->enabled_extensions(); |
150 const Extension* guest_extension = | 149 const Extension* guest_extension = |
151 enabled_extensions.GetByID(guest_extension_id_); | 150 enabled_extensions.GetByID(guest_extension_id_); |
152 | 151 |
153 return app_delegate_->CheckMediaAccessPermission( | 152 return app_delegate_->CheckMediaAccessPermission( |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 279 |
281 std::vector<int> AppViewGuest::GetAllRegisteredInstanceIdsForTesting() { | 280 std::vector<int> AppViewGuest::GetAllRegisteredInstanceIdsForTesting() { |
282 std::vector<int> instances; | 281 std::vector<int> instances; |
283 for (const auto& key_value : pending_response_map.Get()) { | 282 for (const auto& key_value : pending_response_map.Get()) { |
284 instances.push_back(key_value.first); | 283 instances.push_back(key_value.first); |
285 } | 284 } |
286 return instances; | 285 return instances; |
287 } | 286 } |
288 | 287 |
289 } // namespace extensions | 288 } // namespace extensions |
OLD | NEW |