| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/guestview/webview/webview_guest.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 9 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 10 #include "chrome/browser/extensions/extension_renderer_state.h" | 10 #include "chrome/browser/extensions/extension_renderer_state.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 chromevox_injected_(false) { | 132 chromevox_injected_(false) { |
| 133 notification_registrar_.Add( | 133 notification_registrar_.Add( |
| 134 this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 134 this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 135 content::Source<WebContents>(guest_web_contents)); | 135 content::Source<WebContents>(guest_web_contents)); |
| 136 | 136 |
| 137 notification_registrar_.Add( | 137 notification_registrar_.Add( |
| 138 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, | 138 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, |
| 139 content::Source<WebContents>(guest_web_contents)); | 139 content::Source<WebContents>(guest_web_contents)); |
| 140 | 140 |
| 141 #if defined(OS_CHROMEOS) | 141 #if defined(OS_CHROMEOS) |
| 142 notification_registrar_.Add(this, | 142 chromeos::AccessibilityManager* accessibility_manager = |
| 143 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, | 143 chromeos::AccessibilityManager::Get(); |
| 144 content::NotificationService::AllSources()); | 144 CHECK(accessibility_manager); |
| 145 accessibility_subscription_ = accessibility_manager->RegisterCallback( |
| 146 base::Bind(&WebViewGuest::OnAccessibilityStatusChanged, |
| 147 base::Unretained(this))); |
| 145 #endif | 148 #endif |
| 146 | 149 |
| 147 AttachWebViewHelpers(guest_web_contents); | 150 AttachWebViewHelpers(guest_web_contents); |
| 148 } | 151 } |
| 149 | 152 |
| 150 // static | 153 // static |
| 151 WebViewGuest* WebViewGuest::From(int embedder_process_id, | 154 WebViewGuest* WebViewGuest::From(int embedder_process_id, |
| 152 int guest_instance_id) { | 155 int guest_instance_id) { |
| 153 GuestView* guest = GuestView::From(embedder_process_id, guest_instance_id); | 156 GuestView* guest = GuestView::From(embedder_process_id, guest_instance_id); |
| 154 if (!guest) | 157 if (!guest) |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 guest_web_contents()); | 471 guest_web_contents()); |
| 469 content::ResourceRedirectDetails* resource_redirect_details = | 472 content::ResourceRedirectDetails* resource_redirect_details = |
| 470 content::Details<content::ResourceRedirectDetails>(details).ptr(); | 473 content::Details<content::ResourceRedirectDetails>(details).ptr(); |
| 471 bool is_top_level = | 474 bool is_top_level = |
| 472 resource_redirect_details->resource_type == ResourceType::MAIN_FRAME; | 475 resource_redirect_details->resource_type == ResourceType::MAIN_FRAME; |
| 473 LoadRedirect(resource_redirect_details->url, | 476 LoadRedirect(resource_redirect_details->url, |
| 474 resource_redirect_details->new_url, | 477 resource_redirect_details->new_url, |
| 475 is_top_level); | 478 is_top_level); |
| 476 break; | 479 break; |
| 477 } | 480 } |
| 478 #if defined(OS_CHROMEOS) | |
| 479 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK: | |
| 480 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); | |
| 481 break; | |
| 482 #endif | |
| 483 default: | 481 default: |
| 484 NOTREACHED() << "Unexpected notification sent."; | 482 NOTREACHED() << "Unexpected notification sent."; |
| 485 break; | 483 break; |
| 486 } | 484 } |
| 487 } | 485 } |
| 488 | 486 |
| 489 void WebViewGuest::SetZoom(double zoom_factor) { | 487 void WebViewGuest::SetZoom(double zoom_factor) { |
| 490 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); | 488 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); |
| 491 guest_web_contents()->SetZoomLevel(zoom_level); | 489 guest_web_contents()->SetZoomLevel(zoom_level); |
| 492 | 490 |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 void WebViewGuest::SizeChanged(const gfx::Size& old_size, | 741 void WebViewGuest::SizeChanged(const gfx::Size& old_size, |
| 744 const gfx::Size& new_size) { | 742 const gfx::Size& new_size) { |
| 745 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 743 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| 746 args->SetInteger(webview::kOldHeight, old_size.height()); | 744 args->SetInteger(webview::kOldHeight, old_size.height()); |
| 747 args->SetInteger(webview::kOldWidth, old_size.width()); | 745 args->SetInteger(webview::kOldWidth, old_size.width()); |
| 748 args->SetInteger(webview::kNewHeight, new_size.height()); | 746 args->SetInteger(webview::kNewHeight, new_size.height()); |
| 749 args->SetInteger(webview::kNewWidth, new_size.width()); | 747 args->SetInteger(webview::kNewWidth, new_size.width()); |
| 750 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); | 748 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); |
| 751 } | 749 } |
| 752 | 750 |
| 751 #if defined(OS_CHROMEOS) |
| 752 void WebViewGuest::OnAccessibilityStatusChanged( |
| 753 const chromeos::AccessibilityStatusEventDetails& details) { |
| 754 if (details.notification_type == chromeos::ACCESSIBILITY_MANAGER_SHUTDOWN) { |
| 755 accessibility_subscription_.reset(); |
| 756 } else if (details.notification_type == |
| 757 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { |
| 758 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); |
| 759 } |
| 760 } |
| 761 #endif |
| 762 |
| 753 void WebViewGuest::InjectChromeVoxIfNeeded( | 763 void WebViewGuest::InjectChromeVoxIfNeeded( |
| 754 content::RenderViewHost* render_view_host) { | 764 content::RenderViewHost* render_view_host) { |
| 755 #if defined(OS_CHROMEOS) | 765 #if defined(OS_CHROMEOS) |
| 756 if (!chromevox_injected_) { | 766 if (!chromevox_injected_) { |
| 757 chromeos::AccessibilityManager* manager = | 767 chromeos::AccessibilityManager* manager = |
| 758 chromeos::AccessibilityManager::Get(); | 768 chromeos::AccessibilityManager::Get(); |
| 759 if (manager && manager->IsSpokenFeedbackEnabled()) { | 769 if (manager && manager->IsSpokenFeedbackEnabled()) { |
| 760 manager->InjectChromeVox(render_view_host); | 770 manager->InjectChromeVox(render_view_host); |
| 761 chromevox_injected_ = true; | 771 chromevox_injected_ = true; |
| 762 } | 772 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 773 const PermissionResponseCallback& callback, | 783 const PermissionResponseCallback& callback, |
| 774 BrowserPluginPermissionType permission_type, | 784 BrowserPluginPermissionType permission_type, |
| 775 bool allowed_by_default) | 785 bool allowed_by_default) |
| 776 : callback(callback), | 786 : callback(callback), |
| 777 permission_type(permission_type), | 787 permission_type(permission_type), |
| 778 allowed_by_default(allowed_by_default) { | 788 allowed_by_default(allowed_by_default) { |
| 779 } | 789 } |
| 780 | 790 |
| 781 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { | 791 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { |
| 782 } | 792 } |
| OLD | NEW |