| 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/web_view/web_view_guest.h" | 5 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/public/browser/browser_context.h" | 10 #include "content/public/browser/browser_context.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "content/public/browser/storage_partition.h" | 24 #include "content/public/browser/storage_partition.h" |
| 25 #include "content/public/browser/user_metrics.h" | 25 #include "content/public/browser/user_metrics.h" |
| 26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
| 27 #include "content/public/browser/web_contents_delegate.h" | 27 #include "content/public/browser/web_contents_delegate.h" |
| 28 #include "content/public/common/media_stream_request.h" | 28 #include "content/public/common/media_stream_request.h" |
| 29 #include "content/public/common/page_zoom.h" | 29 #include "content/public/common/page_zoom.h" |
| 30 #include "content/public/common/result_codes.h" | 30 #include "content/public/common/result_codes.h" |
| 31 #include "content/public/common/stop_find_action.h" | 31 #include "content/public/common/stop_find_action.h" |
| 32 #include "content/public/common/url_constants.h" | 32 #include "content/public/common/url_constants.h" |
| 33 #include "extensions/browser/api/extensions_api_client.h" | 33 #include "extensions/browser/api/extensions_api_client.h" |
| 34 #include "extensions/browser/api/web_request/web_request_api.h" | |
| 35 #include "extensions/browser/api/web_view/web_view_internal_api.h" | 34 #include "extensions/browser/api/web_view/web_view_internal_api.h" |
| 36 #include "extensions/browser/extension_system.h" | 35 #include "extensions/browser/extension_system.h" |
| 37 #include "extensions/browser/guest_view/guest_view_manager.h" | 36 #include "extensions/browser/guest_view/guest_view_manager.h" |
| 38 #include "extensions/browser/guest_view/web_view/web_view_constants.h" | 37 #include "extensions/browser/guest_view/web_view/web_view_constants.h" |
| 39 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" | 38 #include "extensions/browser/guest_view/web_view/web_view_permission_helper.h" |
| 40 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" | 39 #include "extensions/browser/guest_view/web_view/web_view_permission_types.h" |
| 41 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" | 40 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
| 42 #include "extensions/common/constants.h" | 41 #include "extensions/common/constants.h" |
| 43 #include "extensions/common/extension_messages.h" | 42 #include "extensions/common/extension_messages.h" |
| 44 #include "extensions/common/guest_view/guest_view_constants.h" | 43 #include "extensions/common/guest_view/guest_view_constants.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // TODO(lazyboy): Better way to deal with this error. | 125 // TODO(lazyboy): Better way to deal with this error. |
| 127 return; | 126 return; |
| 128 } | 127 } |
| 129 *persist_storage = true; | 128 *persist_storage = true; |
| 130 } else { | 129 } else { |
| 131 *storage_partition_id = partition_str; | 130 *storage_partition_id = partition_str; |
| 132 *persist_storage = false; | 131 *persist_storage = false; |
| 133 } | 132 } |
| 134 } | 133 } |
| 135 | 134 |
| 136 void RemoveWebViewEventListenersOnIOThread( | |
| 137 void* profile, | |
| 138 const std::string& extension_id, | |
| 139 int embedder_process_id, | |
| 140 int view_instance_id) { | |
| 141 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | |
| 142 ExtensionWebRequestEventRouter::GetInstance()->RemoveWebViewEventListeners( | |
| 143 profile, | |
| 144 extension_id, | |
| 145 embedder_process_id, | |
| 146 view_instance_id); | |
| 147 } | |
| 148 | |
| 149 } // namespace | 135 } // namespace |
| 150 | 136 |
| 151 // static | 137 // static |
| 152 GuestViewBase* WebViewGuest::Create(content::BrowserContext* browser_context, | 138 GuestViewBase* WebViewGuest::Create(content::BrowserContext* browser_context, |
| 153 int guest_instance_id) { | 139 int guest_instance_id) { |
| 154 return new WebViewGuest(browser_context, guest_instance_id); | 140 return new WebViewGuest(browser_context, guest_instance_id); |
| 155 } | 141 } |
| 156 | 142 |
| 157 // static | 143 // static |
| 158 bool WebViewGuest::GetGuestPartitionConfigForSite( | 144 bool WebViewGuest::GetGuestPartitionConfigForSite( |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 web_view_permission_helper_.reset(new WebViewPermissionHelper(this)); | 329 web_view_permission_helper_.reset(new WebViewPermissionHelper(this)); |
| 344 } | 330 } |
| 345 | 331 |
| 346 void WebViewGuest::DidStopLoading() { | 332 void WebViewGuest::DidStopLoading() { |
| 347 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 333 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 348 DispatchEventToEmbedder( | 334 DispatchEventToEmbedder( |
| 349 new GuestViewBase::Event(webview::kEventLoadStop, args.Pass())); | 335 new GuestViewBase::Event(webview::kEventLoadStop, args.Pass())); |
| 350 } | 336 } |
| 351 | 337 |
| 352 void WebViewGuest::EmbedderDestroyed() { | 338 void WebViewGuest::EmbedderDestroyed() { |
| 353 content::BrowserThread::PostTask( | 339 if (web_view_guest_delegate_) |
| 354 content::BrowserThread::IO, | 340 web_view_guest_delegate_->OnEmbedderDestroyed(); |
| 355 FROM_HERE, | |
| 356 base::Bind( | |
| 357 &RemoveWebViewEventListenersOnIOThread, | |
| 358 browser_context(), | |
| 359 embedder_extension_id(), | |
| 360 embedder_render_process_id(), | |
| 361 view_instance_id())); | |
| 362 } | 341 } |
| 363 | 342 |
| 364 void WebViewGuest::GuestDestroyed() { | 343 void WebViewGuest::GuestDestroyed() { |
| 365 // Clean up custom context menu items for this guest. | 344 // Clean up custom context menu items for this guest. |
| 366 if (web_view_guest_delegate_) | 345 if (web_view_guest_delegate_) |
| 367 web_view_guest_delegate_->OnGuestDestroyed(); | 346 web_view_guest_delegate_->OnGuestDestroyed(); |
| 368 RemoveWebViewStateFromIOThread(web_contents()); | 347 RemoveWebViewStateFromIOThread(web_contents()); |
| 369 } | 348 } |
| 370 | 349 |
| 371 void WebViewGuest::GuestReady() { | 350 void WebViewGuest::GuestReady() { |
| (...skipping 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1210 WebViewGuest* guest = | 1189 WebViewGuest* guest = |
| 1211 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); | 1190 WebViewGuest::From(embedder_render_process_id(), new_window_instance_id); |
| 1212 if (!guest) | 1191 if (!guest) |
| 1213 return; | 1192 return; |
| 1214 | 1193 |
| 1215 if (!allow) | 1194 if (!allow) |
| 1216 guest->Destroy(); | 1195 guest->Destroy(); |
| 1217 } | 1196 } |
| 1218 | 1197 |
| 1219 } // namespace extensions | 1198 } // namespace extensions |
| OLD | NEW |