Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/browser/guestview/webview/webview_guest.cc

Issue 166273014: Remove dependency on NotificationService for cros a11y settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix magnification manager. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/command_line.h" 7 #include "base/command_line.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"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 chromevox_injected_(false) { 134 chromevox_injected_(false) {
135 notification_registrar_.Add( 135 notification_registrar_.Add(
136 this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 136 this, content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
137 content::Source<WebContents>(guest_web_contents)); 137 content::Source<WebContents>(guest_web_contents));
138 138
139 notification_registrar_.Add( 139 notification_registrar_.Add(
140 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT, 140 this, content::NOTIFICATION_RESOURCE_RECEIVED_REDIRECT,
141 content::Source<WebContents>(guest_web_contents)); 141 content::Source<WebContents>(guest_web_contents));
142 142
143 #if defined(OS_CHROMEOS) 143 #if defined(OS_CHROMEOS)
144 notification_registrar_.Add(this, 144 chromeos::AccessibilityManager* accessibility_manager =
145 chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK, 145 chromeos::AccessibilityManager::Get();
146 content::NotificationService::AllSources()); 146 CHECK(accessibility_manager);
147 accessibility_subscription_ = accessibility_manager->RegisterCallback(
148 base::Bind(&WebViewGuest::OnAccessibilityStatusChanged,
149 base::Unretained(this)));
147 #endif 150 #endif
148 151
149 AttachWebViewHelpers(guest_web_contents); 152 AttachWebViewHelpers(guest_web_contents);
150 } 153 }
151 154
152 // static 155 // static
153 WebViewGuest* WebViewGuest::From(int embedder_process_id, 156 WebViewGuest* WebViewGuest::From(int embedder_process_id,
154 int guest_instance_id) { 157 int guest_instance_id) {
155 GuestView* guest = GuestView::From(embedder_process_id, guest_instance_id); 158 GuestView* guest = GuestView::From(embedder_process_id, guest_instance_id);
156 if (!guest) 159 if (!guest)
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 guest_web_contents()); 485 guest_web_contents());
483 content::ResourceRedirectDetails* resource_redirect_details = 486 content::ResourceRedirectDetails* resource_redirect_details =
484 content::Details<content::ResourceRedirectDetails>(details).ptr(); 487 content::Details<content::ResourceRedirectDetails>(details).ptr();
485 bool is_top_level = 488 bool is_top_level =
486 resource_redirect_details->resource_type == ResourceType::MAIN_FRAME; 489 resource_redirect_details->resource_type == ResourceType::MAIN_FRAME;
487 LoadRedirect(resource_redirect_details->url, 490 LoadRedirect(resource_redirect_details->url,
488 resource_redirect_details->new_url, 491 resource_redirect_details->new_url,
489 is_top_level); 492 is_top_level);
490 break; 493 break;
491 } 494 }
492 #if defined(OS_CHROMEOS)
493 case chrome::NOTIFICATION_CROS_ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK:
494 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost());
495 break;
496 #endif
497 default: 495 default:
498 NOTREACHED() << "Unexpected notification sent."; 496 NOTREACHED() << "Unexpected notification sent.";
499 break; 497 break;
500 } 498 }
501 } 499 }
502 500
503 void WebViewGuest::SetZoom(double zoom_factor) { 501 void WebViewGuest::SetZoom(double zoom_factor) {
504 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor); 502 double zoom_level = content::ZoomFactorToZoomLevel(zoom_factor);
505 guest_web_contents()->SetZoomLevel(zoom_level); 503 guest_web_contents()->SetZoomLevel(zoom_level);
506 504
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 void WebViewGuest::SizeChanged(const gfx::Size& old_size, 755 void WebViewGuest::SizeChanged(const gfx::Size& old_size,
758 const gfx::Size& new_size) { 756 const gfx::Size& new_size) {
759 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 757 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
760 args->SetInteger(webview::kOldHeight, old_size.height()); 758 args->SetInteger(webview::kOldHeight, old_size.height());
761 args->SetInteger(webview::kOldWidth, old_size.width()); 759 args->SetInteger(webview::kOldWidth, old_size.width());
762 args->SetInteger(webview::kNewHeight, new_size.height()); 760 args->SetInteger(webview::kNewHeight, new_size.height());
763 args->SetInteger(webview::kNewWidth, new_size.width()); 761 args->SetInteger(webview::kNewWidth, new_size.width());
764 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass())); 762 DispatchEvent(new GuestView::Event(webview::kEventSizeChanged, args.Pass()));
765 } 763 }
766 764
765 #if defined(OS_CHROMEOS)
766 void WebViewGuest::OnAccessibilityStatusChanged(
767 const chromeos::AccessibilityStatusEventDetails& details) {
768 if (details.notification_type == chromeos::ACCESSIBILITY_MANAGER_SHUTDOWN) {
769 accessibility_subscription_.reset();
770 } else if (details.notification_type ==
771 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) {
772 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost());
773 }
774 }
775 #endif
776
767 void WebViewGuest::InjectChromeVoxIfNeeded( 777 void WebViewGuest::InjectChromeVoxIfNeeded(
768 content::RenderViewHost* render_view_host) { 778 content::RenderViewHost* render_view_host) {
769 #if defined(OS_CHROMEOS) 779 #if defined(OS_CHROMEOS)
770 if (!chromevox_injected_) { 780 if (!chromevox_injected_) {
771 chromeos::AccessibilityManager* manager = 781 chromeos::AccessibilityManager* manager =
772 chromeos::AccessibilityManager::Get(); 782 chromeos::AccessibilityManager::Get();
773 if (manager && manager->IsSpokenFeedbackEnabled()) { 783 if (manager && manager->IsSpokenFeedbackEnabled()) {
774 manager->InjectChromeVox(render_view_host); 784 manager->InjectChromeVox(render_view_host);
775 chromevox_injected_ = true; 785 chromevox_injected_ = true;
776 } 786 }
(...skipping 10 matching lines...) Expand all
787 const PermissionResponseCallback& callback, 797 const PermissionResponseCallback& callback,
788 BrowserPluginPermissionType permission_type, 798 BrowserPluginPermissionType permission_type,
789 bool allowed_by_default) 799 bool allowed_by_default)
790 : callback(callback), 800 : callback(callback),
791 permission_type(permission_type), 801 permission_type(permission_type),
792 allowed_by_default(allowed_by_default) { 802 allowed_by_default(allowed_by_default) {
793 } 803 }
794 804
795 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() { 805 WebViewGuest::PermissionResponseInfo::~PermissionResponseInfo() {
796 } 806 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698