OLD | NEW |
1 // Copyright 2013 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/guestview/webview/webview_guest.h" | 5 #include "chrome/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 "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 10 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
11 #include "chrome/browser/extensions/api/webview/webview_api.h" | 11 #include "chrome/browser/extensions/api/webview/webview_api.h" |
12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
13 #include "chrome/browser/extensions/extension_renderer_state.h" | 13 #include "chrome/browser/extensions/extension_renderer_state.h" |
14 #include "chrome/browser/extensions/menu_manager.h" | 14 #include "chrome/browser/extensions/menu_manager.h" |
15 #include "chrome/browser/extensions/script_executor.h" | 15 #include "chrome/browser/extensions/script_executor.h" |
16 #include "chrome/browser/favicon/favicon_tab_helper.h" | 16 #include "chrome/browser/favicon/favicon_tab_helper.h" |
17 #include "chrome/browser/guestview/guestview_constants.h" | 17 #include "chrome/browser/guest_view/guest_view_constants.h" |
18 #include "chrome/browser/guestview/webview/webview_constants.h" | 18 #include "chrome/browser/guest_view/web_view/web_view_constants.h" |
19 #include "chrome/browser/guestview/webview/webview_permission_types.h" | 19 #include "chrome/browser/guest_view/web_view/web_view_permission_types.h" |
20 #include "chrome/common/chrome_version_info.h" | 20 #include "chrome/common/chrome_version_info.h" |
21 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
22 #include "content/public/browser/geolocation_permission_context.h" | 22 #include "content/public/browser/geolocation_permission_context.h" |
23 #include "content/public/browser/native_web_keyboard_event.h" | 23 #include "content/public/browser/native_web_keyboard_event.h" |
24 #include "content/public/browser/navigation_entry.h" | 24 #include "content/public/browser/navigation_entry.h" |
25 #include "content/public/browser/notification_details.h" | 25 #include "content/public/browser/notification_details.h" |
26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/notification_source.h" | 27 #include "content/public/browser/notification_source.h" |
28 #include "content/public/browser/notification_types.h" | 28 #include "content/public/browser/notification_types.h" |
29 #include "content/public/browser/render_process_host.h" | 29 #include "content/public/browser/render_process_host.h" |
30 #include "content/public/browser/resource_request_details.h" | 30 #include "content/public/browser/resource_request_details.h" |
31 #include "content/public/browser/site_instance.h" | 31 #include "content/public/browser/site_instance.h" |
32 #include "content/public/browser/storage_partition.h" | 32 #include "content/public/browser/storage_partition.h" |
33 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
34 #include "content/public/browser/web_contents.h" | 34 #include "content/public/browser/web_contents.h" |
35 #include "content/public/browser/web_contents_delegate.h" | 35 #include "content/public/browser/web_contents_delegate.h" |
36 #include "content/public/common/media_stream_request.h" | 36 #include "content/public/common/media_stream_request.h" |
37 #include "content/public/common/page_zoom.h" | 37 #include "content/public/common/page_zoom.h" |
38 #include "content/public/common/result_codes.h" | 38 #include "content/public/common/result_codes.h" |
39 #include "content/public/common/stop_find_action.h" | 39 #include "content/public/common/stop_find_action.h" |
40 #include "extensions/common/constants.h" | 40 #include "extensions/common/constants.h" |
41 #include "net/base/net_errors.h" | 41 #include "net/base/net_errors.h" |
42 #include "third_party/WebKit/public/web/WebFindOptions.h" | 42 #include "third_party/WebKit/public/web/WebFindOptions.h" |
43 | 43 |
44 #if defined(ENABLE_PLUGINS) | 44 #if defined(ENABLE_PLUGINS) |
45 #include "chrome/browser/guestview/webview/plugin_permission_helper.h" | 45 #include "chrome/browser/guest_view/web_view/plugin_permission_helper.h" |
46 #endif | 46 #endif |
47 | 47 |
48 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
49 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 49 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
50 #endif | 50 #endif |
51 | 51 |
52 using base::UserMetricsAction; | 52 using base::UserMetricsAction; |
53 using content::WebContents; | 53 using content::WebContents; |
54 | 54 |
55 namespace { | 55 namespace { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 contents); | 123 contents); |
124 #if defined(ENABLE_PLUGINS) | 124 #if defined(ENABLE_PLUGINS) |
125 PluginPermissionHelper::CreateForWebContents(contents); | 125 PluginPermissionHelper::CreateForWebContents(contents); |
126 #endif | 126 #endif |
127 } | 127 } |
128 | 128 |
129 } // namespace | 129 } // namespace |
130 | 130 |
131 WebViewGuest::WebViewGuest(WebContents* guest_web_contents, | 131 WebViewGuest::WebViewGuest(WebContents* guest_web_contents, |
132 const std::string& extension_id) | 132 const std::string& extension_id) |
133 : GuestView(guest_web_contents, extension_id), | 133 : GuestView<WebViewGuest>(guest_web_contents, extension_id), |
134 WebContentsObserver(guest_web_contents), | 134 WebContentsObserver(guest_web_contents), |
135 script_executor_(new extensions::ScriptExecutor(guest_web_contents, | 135 script_executor_(new extensions::ScriptExecutor(guest_web_contents, |
136 &script_observers_)), | 136 &script_observers_)), |
137 next_permission_request_id_(0), | 137 next_permission_request_id_(0), |
138 is_overriding_user_agent_(false), | 138 is_overriding_user_agent_(false), |
139 pending_reload_on_attachment_(false), | 139 pending_reload_on_attachment_(false), |
140 main_frame_id_(0), | 140 main_frame_id_(0), |
141 chromevox_injected_(false), | 141 chromevox_injected_(false), |
142 find_helper_(this), | 142 find_helper_(this), |
143 javascript_dialog_helper_(this) { | 143 javascript_dialog_helper_(this) { |
(...skipping 11 matching lines...) Expand all Loading... |
155 CHECK(accessibility_manager); | 155 CHECK(accessibility_manager); |
156 accessibility_subscription_ = accessibility_manager->RegisterCallback( | 156 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
157 base::Bind(&WebViewGuest::OnAccessibilityStatusChanged, | 157 base::Bind(&WebViewGuest::OnAccessibilityStatusChanged, |
158 base::Unretained(this))); | 158 base::Unretained(this))); |
159 #endif | 159 #endif |
160 | 160 |
161 AttachWebViewHelpers(guest_web_contents); | 161 AttachWebViewHelpers(guest_web_contents); |
162 } | 162 } |
163 | 163 |
164 // static | 164 // static |
165 WebViewGuest* WebViewGuest::From(int embedder_process_id, | 165 const std::string& WebViewGuest::Type = "webview"; |
166 int guest_instance_id) { | |
167 GuestView* guest = GuestView::From(embedder_process_id, guest_instance_id); | |
168 if (!guest) | |
169 return NULL; | |
170 return guest->AsWebView(); | |
171 } | |
172 | |
173 // static | |
174 WebViewGuest* WebViewGuest::FromWebContents(WebContents* contents) { | |
175 GuestView* guest = GuestView::FromWebContents(contents); | |
176 return guest ? guest->AsWebView() : NULL; | |
177 } | |
178 | 166 |
179 // static. | 167 // static. |
180 int WebViewGuest::GetViewInstanceId(WebContents* contents) { | 168 int WebViewGuest::GetViewInstanceId(WebContents* contents) { |
181 WebViewGuest* guest = FromWebContents(contents); | 169 WebViewGuest* guest = FromWebContents(contents); |
182 if (!guest) | 170 if (!guest) |
183 return guestview::kInstanceIDNone; | 171 return guestview::kInstanceIDNone; |
184 | 172 |
185 return guest->view_instance_id(); | 173 return guest->view_instance_id(); |
186 } | 174 } |
187 | 175 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 void WebViewGuest::Attach(WebContents* embedder_web_contents, | 266 void WebViewGuest::Attach(WebContents* embedder_web_contents, |
279 const base::DictionaryValue& args) { | 267 const base::DictionaryValue& args) { |
280 std::string user_agent_override; | 268 std::string user_agent_override; |
281 if (args.GetString(webview::kParameterUserAgentOverride, | 269 if (args.GetString(webview::kParameterUserAgentOverride, |
282 &user_agent_override)) { | 270 &user_agent_override)) { |
283 SetUserAgentOverride(user_agent_override); | 271 SetUserAgentOverride(user_agent_override); |
284 } else { | 272 } else { |
285 SetUserAgentOverride(""); | 273 SetUserAgentOverride(""); |
286 } | 274 } |
287 | 275 |
288 GuestView::Attach(embedder_web_contents, args); | 276 GuestViewBase::Attach(embedder_web_contents, args); |
289 | 277 |
290 AddWebViewToExtensionRendererState(); | 278 AddWebViewToExtensionRendererState(); |
291 } | 279 } |
292 | 280 |
293 GuestView::Type WebViewGuest::GetViewType() const { | |
294 return GuestView::WEBVIEW; | |
295 } | |
296 | |
297 WebViewGuest* WebViewGuest::AsWebView() { | |
298 return this; | |
299 } | |
300 | |
301 AdViewGuest* WebViewGuest::AsAdView() { | |
302 return NULL; | |
303 } | |
304 | |
305 void WebViewGuest::AddMessageToConsole(int32 level, | 281 void WebViewGuest::AddMessageToConsole(int32 level, |
306 const base::string16& message, | 282 const base::string16& message, |
307 int32 line_no, | 283 int32 line_no, |
308 const base::string16& source_id) { | 284 const base::string16& source_id) { |
309 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 285 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
310 // Log levels are from base/logging.h: LogSeverity. | 286 // Log levels are from base/logging.h: LogSeverity. |
311 args->SetInteger(webview::kLevel, level); | 287 args->SetInteger(webview::kLevel, level); |
312 args->SetString(webview::kMessage, message); | 288 args->SetString(webview::kMessage, message); |
313 args->SetInteger(webview::kLine, line_no); | 289 args->SetInteger(webview::kLine, line_no); |
314 args->SetString(webview::kSourceId, source_id); | 290 args->SetString(webview::kSourceId, source_id); |
315 DispatchEvent( | 291 DispatchEvent( |
316 new GuestView::Event(webview::kEventConsoleMessage, args.Pass())); | 292 new GuestViewBase::Event(webview::kEventConsoleMessage, args.Pass())); |
317 } | 293 } |
318 | 294 |
319 void WebViewGuest::Close() { | 295 void WebViewGuest::Close() { |
320 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 296 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
321 DispatchEvent(new GuestView::Event(webview::kEventClose, args.Pass())); | 297 DispatchEvent(new GuestViewBase::Event(webview::kEventClose, args.Pass())); |
322 } | 298 } |
323 | 299 |
324 void WebViewGuest::DidAttach() { | 300 void WebViewGuest::DidAttach() { |
325 if (pending_reload_on_attachment_) { | 301 if (pending_reload_on_attachment_) { |
326 pending_reload_on_attachment_ = false; | 302 pending_reload_on_attachment_ = false; |
327 guest_web_contents()->GetController().Reload(false); | 303 guest_web_contents()->GetController().Reload(false); |
328 } | 304 } |
329 } | 305 } |
330 | 306 |
331 void WebViewGuest::EmbedderDestroyed() { | 307 void WebViewGuest::EmbedderDestroyed() { |
(...skipping 24 matching lines...) Expand all Loading... |
356 } | 332 } |
357 | 333 |
358 void WebViewGuest::GuestProcessGone(base::TerminationStatus status) { | 334 void WebViewGuest::GuestProcessGone(base::TerminationStatus status) { |
359 // Cancel all find sessions in progress. | 335 // Cancel all find sessions in progress. |
360 find_helper_.CancelAllFindSessions(); | 336 find_helper_.CancelAllFindSessions(); |
361 | 337 |
362 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 338 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
363 args->SetInteger(webview::kProcessId, | 339 args->SetInteger(webview::kProcessId, |
364 guest_web_contents()->GetRenderProcessHost()->GetID()); | 340 guest_web_contents()->GetRenderProcessHost()->GetID()); |
365 args->SetString(webview::kReason, TerminationStatusToString(status)); | 341 args->SetString(webview::kReason, TerminationStatusToString(status)); |
366 DispatchEvent( | 342 DispatchEvent(new GuestViewBase::Event(webview::kEventExit, args.Pass())); |
367 new GuestView::Event(webview::kEventExit, args.Pass())); | |
368 } | 343 } |
369 | 344 |
370 bool WebViewGuest::HandleKeyboardEvent( | 345 bool WebViewGuest::HandleKeyboardEvent( |
371 const content::NativeWebKeyboardEvent& event) { | 346 const content::NativeWebKeyboardEvent& event) { |
372 if (event.type != blink::WebInputEvent::RawKeyDown) | 347 if (event.type != blink::WebInputEvent::RawKeyDown) |
373 return false; | 348 return false; |
374 | 349 |
375 #if defined(OS_MACOSX) | 350 #if defined(OS_MACOSX) |
376 if (event.modifiers != blink::WebInputEvent::MetaKey) | 351 if (event.modifiers != blink::WebInputEvent::MetaKey) |
377 return false; | 352 return false; |
(...skipping 26 matching lines...) Expand all Loading... |
404 } | 379 } |
405 | 380 |
406 bool WebViewGuest::IsOverridingUserAgent() const { | 381 bool WebViewGuest::IsOverridingUserAgent() const { |
407 return is_overriding_user_agent_; | 382 return is_overriding_user_agent_; |
408 } | 383 } |
409 | 384 |
410 void WebViewGuest::LoadProgressed(double progress) { | 385 void WebViewGuest::LoadProgressed(double progress) { |
411 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 386 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
412 args->SetString(guestview::kUrl, guest_web_contents()->GetURL().spec()); | 387 args->SetString(guestview::kUrl, guest_web_contents()->GetURL().spec()); |
413 args->SetDouble(webview::kProgress, progress); | 388 args->SetDouble(webview::kProgress, progress); |
414 DispatchEvent(new GuestView::Event(webview::kEventLoadProgress, args.Pass())); | 389 DispatchEvent( |
| 390 new GuestViewBase::Event(webview::kEventLoadProgress, args.Pass())); |
415 } | 391 } |
416 | 392 |
417 void WebViewGuest::LoadAbort(bool is_top_level, | 393 void WebViewGuest::LoadAbort(bool is_top_level, |
418 const GURL& url, | 394 const GURL& url, |
419 const std::string& error_type) { | 395 const std::string& error_type) { |
420 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 396 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
421 args->SetBoolean(guestview::kIsTopLevel, is_top_level); | 397 args->SetBoolean(guestview::kIsTopLevel, is_top_level); |
422 args->SetString(guestview::kUrl, url.possibly_invalid_spec()); | 398 args->SetString(guestview::kUrl, url.possibly_invalid_spec()); |
423 args->SetString(guestview::kReason, error_type); | 399 args->SetString(guestview::kReason, error_type); |
424 DispatchEvent(new GuestView::Event(webview::kEventLoadAbort, args.Pass())); | 400 DispatchEvent( |
| 401 new GuestViewBase::Event(webview::kEventLoadAbort, args.Pass())); |
425 } | 402 } |
426 | 403 |
427 // TODO(fsamuel): Find a reliable way to test the 'responsive' and | 404 // TODO(fsamuel): Find a reliable way to test the 'responsive' and |
428 // 'unresponsive' events. | 405 // 'unresponsive' events. |
429 void WebViewGuest::RendererResponsive() { | 406 void WebViewGuest::RendererResponsive() { |
430 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 407 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
431 args->SetInteger(webview::kProcessId, | 408 args->SetInteger(webview::kProcessId, |
432 guest_web_contents()->GetRenderProcessHost()->GetID()); | 409 guest_web_contents()->GetRenderProcessHost()->GetID()); |
433 DispatchEvent(new GuestView::Event(webview::kEventResponsive, args.Pass())); | 410 DispatchEvent( |
| 411 new GuestViewBase::Event(webview::kEventResponsive, args.Pass())); |
434 } | 412 } |
435 | 413 |
436 void WebViewGuest::RendererUnresponsive() { | 414 void WebViewGuest::RendererUnresponsive() { |
437 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 415 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
438 args->SetInteger(webview::kProcessId, | 416 args->SetInteger(webview::kProcessId, |
439 guest_web_contents()->GetRenderProcessHost()->GetID()); | 417 guest_web_contents()->GetRenderProcessHost()->GetID()); |
440 DispatchEvent(new GuestView::Event(webview::kEventUnresponsive, args.Pass())); | 418 DispatchEvent( |
| 419 new GuestViewBase::Event(webview::kEventUnresponsive, args.Pass())); |
441 } | 420 } |
442 | 421 |
443 void WebViewGuest::RequestPermission( | 422 void WebViewGuest::RequestPermission( |
444 BrowserPluginPermissionType permission_type, | 423 BrowserPluginPermissionType permission_type, |
445 const base::DictionaryValue& request_info, | 424 const base::DictionaryValue& request_info, |
446 const PermissionResponseCallback& callback, | 425 const PermissionResponseCallback& callback, |
447 bool allowed_by_default) { | 426 bool allowed_by_default) { |
448 RequestPermissionInternal(permission_type, | 427 RequestPermissionInternal(permission_type, |
449 request_info, | 428 request_info, |
450 callback, | 429 callback, |
(...skipping 29 matching lines...) Expand all Loading... |
480 } | 459 } |
481 } | 460 } |
482 | 461 |
483 void WebViewGuest::SetZoom(double zoom_factor) { | 462 void WebViewGuest::SetZoom(double zoom_factor) { |
484 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); | 463 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); |
485 guest_web_contents()->SetZoomLevel(zoom_level); | 464 guest_web_contents()->SetZoomLevel(zoom_level); |
486 | 465 |
487 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 466 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
488 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); | 467 args->SetDouble(webview::kOldZoomFactor, current_zoom_factor_); |
489 args->SetDouble(webview::kNewZoomFactor, zoom_factor); | 468 args->SetDouble(webview::kNewZoomFactor, zoom_factor); |
490 DispatchEvent(new GuestView::Event(webview::kEventZoomChange, args.Pass())); | 469 DispatchEvent( |
| 470 new GuestViewBase::Event(webview::kEventZoomChange, args.Pass())); |
491 | 471 |
492 current_zoom_factor_ = zoom_factor; | 472 current_zoom_factor_ = zoom_factor; |
493 } | 473 } |
494 | 474 |
495 double WebViewGuest::GetZoom() { | 475 double WebViewGuest::GetZoom() { |
496 return current_zoom_factor_; | 476 return current_zoom_factor_; |
497 } | 477 } |
498 | 478 |
499 void WebViewGuest::Find( | 479 void WebViewGuest::Find( |
500 const base::string16& search_text, | 480 const base::string16& search_text, |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 | 687 |
708 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 688 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
709 args->SetString(guestview::kUrl, url.spec()); | 689 args->SetString(guestview::kUrl, url.spec()); |
710 args->SetBoolean(guestview::kIsTopLevel, is_main_frame); | 690 args->SetBoolean(guestview::kIsTopLevel, is_main_frame); |
711 args->SetInteger(webview::kInternalCurrentEntryIndex, | 691 args->SetInteger(webview::kInternalCurrentEntryIndex, |
712 guest_web_contents()->GetController().GetCurrentEntryIndex()); | 692 guest_web_contents()->GetController().GetCurrentEntryIndex()); |
713 args->SetInteger(webview::kInternalEntryCount, | 693 args->SetInteger(webview::kInternalEntryCount, |
714 guest_web_contents()->GetController().GetEntryCount()); | 694 guest_web_contents()->GetController().GetEntryCount()); |
715 args->SetInteger(webview::kInternalProcessId, | 695 args->SetInteger(webview::kInternalProcessId, |
716 guest_web_contents()->GetRenderProcessHost()->GetID()); | 696 guest_web_contents()->GetRenderProcessHost()->GetID()); |
717 DispatchEvent(new GuestView::Event(webview::kEventLoadCommit, args.Pass())); | 697 DispatchEvent( |
| 698 new GuestViewBase::Event(webview::kEventLoadCommit, args.Pass())); |
718 | 699 |
719 // Update the current zoom factor for the new page. | 700 // Update the current zoom factor for the new page. |
720 current_zoom_factor_ = content::ZoomLevelToZoomFactor( | 701 current_zoom_factor_ = content::ZoomLevelToZoomFactor( |
721 guest_web_contents()->GetZoomLevel()); | 702 guest_web_contents()->GetZoomLevel()); |
722 | 703 |
723 if (is_main_frame) { | 704 if (is_main_frame) { |
724 chromevox_injected_ = false; | 705 chromevox_injected_ = false; |
725 main_frame_id_ = frame_id; | 706 main_frame_id_ = frame_id; |
726 } | 707 } |
727 } | 708 } |
(...skipping 16 matching lines...) Expand all Loading... |
744 int64 frame_id, | 725 int64 frame_id, |
745 int64 parent_frame_id, | 726 int64 parent_frame_id, |
746 bool is_main_frame, | 727 bool is_main_frame, |
747 const GURL& validated_url, | 728 const GURL& validated_url, |
748 bool is_error_page, | 729 bool is_error_page, |
749 bool is_iframe_srcdoc, | 730 bool is_iframe_srcdoc, |
750 content::RenderViewHost* render_view_host) { | 731 content::RenderViewHost* render_view_host) { |
751 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 732 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
752 args->SetString(guestview::kUrl, validated_url.spec()); | 733 args->SetString(guestview::kUrl, validated_url.spec()); |
753 args->SetBoolean(guestview::kIsTopLevel, is_main_frame); | 734 args->SetBoolean(guestview::kIsTopLevel, is_main_frame); |
754 DispatchEvent(new GuestView::Event(webview::kEventLoadStart, args.Pass())); | 735 DispatchEvent( |
| 736 new GuestViewBase::Event(webview::kEventLoadStart, args.Pass())); |
755 } | 737 } |
756 | 738 |
757 void WebViewGuest::DocumentLoadedInFrame( | 739 void WebViewGuest::DocumentLoadedInFrame( |
758 int64 frame_id, | 740 int64 frame_id, |
759 content::RenderViewHost* render_view_host) { | 741 content::RenderViewHost* render_view_host) { |
760 if (frame_id == main_frame_id_) | 742 if (frame_id == main_frame_id_) |
761 InjectChromeVoxIfNeeded(render_view_host); | 743 InjectChromeVoxIfNeeded(render_view_host); |
762 } | 744 } |
763 | 745 |
764 void WebViewGuest::DidStopLoading(content::RenderViewHost* render_view_host) { | 746 void WebViewGuest::DidStopLoading(content::RenderViewHost* render_view_host) { |
765 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 747 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
766 DispatchEvent(new GuestView::Event(webview::kEventLoadStop, args.Pass())); | 748 DispatchEvent(new GuestViewBase::Event(webview::kEventLoadStop, args.Pass())); |
767 } | 749 } |
768 | 750 |
769 void WebViewGuest::WebContentsDestroyed(WebContents* web_contents) { | 751 void WebViewGuest::WebContentsDestroyed(WebContents* web_contents) { |
770 // Clean up custom context menu items for this guest. | 752 // Clean up custom context menu items for this guest. |
771 extensions::MenuManager* menu_manager = extensions::MenuManager::Get( | 753 extensions::MenuManager* menu_manager = extensions::MenuManager::Get( |
772 Profile::FromBrowserContext(browser_context())); | 754 Profile::FromBrowserContext(browser_context())); |
773 menu_manager->RemoveAllContextItems(extensions::MenuItem::ExtensionKey( | 755 menu_manager->RemoveAllContextItems(extensions::MenuItem::ExtensionKey( |
774 embedder_extension_id(), view_instance_id())); | 756 embedder_extension_id(), view_instance_id())); |
775 | 757 |
776 RemoveWebViewFromExtensionRendererState(web_contents); | 758 RemoveWebViewFromExtensionRendererState(web_contents); |
(...skipping 10 matching lines...) Expand all Loading... |
787 // We cannot reload now because all resource loads are suspended until | 769 // We cannot reload now because all resource loads are suspended until |
788 // attachment. | 770 // attachment. |
789 pending_reload_on_attachment_ = true; | 771 pending_reload_on_attachment_ = true; |
790 return; | 772 return; |
791 } | 773 } |
792 guest_web_contents()->GetController().Reload(false); | 774 guest_web_contents()->GetController().Reload(false); |
793 } | 775 } |
794 | 776 |
795 void WebViewGuest::LoadHandlerCalled() { | 777 void WebViewGuest::LoadHandlerCalled() { |
796 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 778 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
797 DispatchEvent(new GuestView::Event(webview::kEventContentLoad, args.Pass())); | 779 DispatchEvent( |
| 780 new GuestViewBase::Event(webview::kEventContentLoad, args.Pass())); |
798 } | 781 } |
799 | 782 |
800 void WebViewGuest::LoadRedirect(const GURL& old_url, | 783 void WebViewGuest::LoadRedirect(const GURL& old_url, |
801 const GURL& new_url, | 784 const GURL& new_url, |
802 bool is_top_level) { | 785 bool is_top_level) { |
803 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 786 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
804 args->SetBoolean(guestview::kIsTopLevel, is_top_level); | 787 args->SetBoolean(guestview::kIsTopLevel, is_top_level); |
805 args->SetString(webview::kNewURL, new_url.spec()); | 788 args->SetString(webview::kNewURL, new_url.spec()); |
806 args->SetString(webview::kOldURL, old_url.spec()); | 789 args->SetString(webview::kOldURL, old_url.spec()); |
807 DispatchEvent(new GuestView::Event(webview::kEventLoadRedirect, args.Pass())); | 790 DispatchEvent( |
| 791 new GuestViewBase::Event(webview::kEventLoadRedirect, args.Pass())); |
808 } | 792 } |
809 | 793 |
810 void WebViewGuest::AddWebViewToExtensionRendererState() { | 794 void WebViewGuest::AddWebViewToExtensionRendererState() { |
811 const GURL& site_url = guest_web_contents()->GetSiteInstance()->GetSiteURL(); | 795 const GURL& site_url = guest_web_contents()->GetSiteInstance()->GetSiteURL(); |
812 std::string partition_domain; | 796 std::string partition_domain; |
813 std::string partition_id; | 797 std::string partition_id; |
814 bool in_memory; | 798 bool in_memory; |
815 if (!GetGuestPartitionConfigForSite( | 799 if (!GetGuestPartitionConfigForSite( |
816 site_url, &partition_domain, &partition_id, &in_memory)) { | 800 site_url, &partition_domain, &partition_id, &in_memory)) { |
817 NOTREACHED(); | 801 NOTREACHED(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 return default_url.Resolve(src); | 843 return default_url.Resolve(src); |
860 } | 844 } |
861 | 845 |
862 void WebViewGuest::SizeChanged(const gfx::Size& old_size, | 846 void WebViewGuest::SizeChanged(const gfx::Size& old_size, |
863 const gfx::Size& new_size) { | 847 const gfx::Size& new_size) { |
864 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 848 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
865 args->SetInteger(webview::kOldHeight, old_size.height()); | 849 args->SetInteger(webview::kOldHeight, old_size.height()); |
866 args->SetInteger(webview::kOldWidth, old_size.width()); | 850 args->SetInteger(webview::kOldWidth, old_size.width()); |
867 args->SetInteger(webview::kNewHeight, new_size.height()); | 851 args->SetInteger(webview::kNewHeight, new_size.height()); |
868 args->SetInteger(webview::kNewWidth, new_size.width()); | 852 args->SetInteger(webview::kNewWidth, new_size.width()); |
869 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); | 853 DispatchEvent( |
| 854 new GuestViewBase::Event(webview::kEventSizeChanged, args.Pass())); |
870 } | 855 } |
871 | 856 |
872 void WebViewGuest::RequestMediaAccessPermission( | 857 void WebViewGuest::RequestMediaAccessPermission( |
873 const content::MediaStreamRequest& request, | 858 const content::MediaStreamRequest& request, |
874 const content::MediaResponseCallback& callback) { | 859 const content::MediaResponseCallback& callback) { |
875 base::DictionaryValue request_info; | 860 base::DictionaryValue request_info; |
876 request_info.Set( | 861 request_info.Set( |
877 guestview::kUrl, | 862 guestview::kUrl, |
878 base::Value::CreateStringValue(request.security_origin.spec())); | 863 base::Value::CreateStringValue(request.security_origin.spec())); |
879 RequestPermission(static_cast<BrowserPluginPermissionType>( | 864 RequestPermission(static_cast<BrowserPluginPermissionType>( |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 return webview::kInvalidPermissionRequestID; | 978 return webview::kInvalidPermissionRequestID; |
994 } | 979 } |
995 | 980 |
996 int request_id = next_permission_request_id_++; | 981 int request_id = next_permission_request_id_++; |
997 pending_permission_requests_[request_id] = | 982 pending_permission_requests_[request_id] = |
998 PermissionResponseInfo(callback, permission_type, allowed_by_default); | 983 PermissionResponseInfo(callback, permission_type, allowed_by_default); |
999 scoped_ptr<base::DictionaryValue> args(request_info.DeepCopy()); | 984 scoped_ptr<base::DictionaryValue> args(request_info.DeepCopy()); |
1000 args->SetInteger(webview::kRequestId, request_id); | 985 args->SetInteger(webview::kRequestId, request_id); |
1001 switch (static_cast<int>(permission_type)) { | 986 switch (static_cast<int>(permission_type)) { |
1002 case BROWSER_PLUGIN_PERMISSION_TYPE_NEW_WINDOW: { | 987 case BROWSER_PLUGIN_PERMISSION_TYPE_NEW_WINDOW: { |
1003 DispatchEvent(new GuestView::Event(webview::kEventNewWindow, | 988 DispatchEvent( |
1004 args.Pass())); | 989 new GuestViewBase::Event(webview::kEventNewWindow, args.Pass())); |
1005 break; | 990 break; |
1006 } | 991 } |
1007 case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: { | 992 case WEB_VIEW_PERMISSION_TYPE_JAVASCRIPT_DIALOG: { |
1008 DispatchEvent(new GuestView::Event(webview::kEventDialog, | 993 DispatchEvent( |
1009 args.Pass())); | 994 new GuestViewBase::Event(webview::kEventDialog, args.Pass())); |
1010 break; | 995 break; |
1011 } | 996 } |
1012 default: { | 997 default: { |
1013 args->SetString(webview::kPermission, | 998 args->SetString(webview::kPermission, |
1014 PermissionTypeToString(permission_type)); | 999 PermissionTypeToString(permission_type)); |
1015 DispatchEvent(new GuestView::Event(webview::kEventPermissionRequest, | 1000 DispatchEvent(new GuestViewBase::Event(webview::kEventPermissionRequest, |
1016 args.Pass())); | 1001 args.Pass())); |
1017 break; | 1002 break; |
1018 } | 1003 } |
1019 } | 1004 } |
1020 return request_id; | 1005 return request_id; |
1021 } | 1006 } |
1022 | 1007 |
1023 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo() | 1008 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo() |
1024 : permission_type(BROWSER_PLUGIN_PERMISSION_TYPE_UNKNOWN), | 1009 : permission_type(BROWSER_PLUGIN_PERMISSION_TYPE_UNKNOWN), |
1025 allowed_by_default(false) { | 1010 allowed_by_default(false) { |
1026 } | 1011 } |
1027 | 1012 |
1028 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo( | 1013 WebViewGuest::PermissionResponseInfo::PermissionResponseInfo( |
1029 const PermissionResponseCallback& callback, | 1014 const PermissionResponseCallback& callback, |
1030 BrowserPluginPermissionType permission_type, | 1015 BrowserPluginPermissionType permission_type, |
1031 bool allowed_by_default) | 1016 bool allowed_by_default) |
1032 : callback(callback), | 1017 : callback(callback), |
1033 permission_type(permission_type), | 1018 permission_type(permission_type), |
1034 allowed_by_default(allowed_by_default) { | 1019 allowed_by_default(allowed_by_default) { |
1035 } | 1020 } |
1036 | 1021 |
1037 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { | 1022 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { |
1038 } | 1023 } |
OLD | NEW |