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

Side by Side Diff: chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.cc

Issue 1140173003: Allow whitelisted content scripts to be injected in WebViews. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@document_has_focus
Patch Set: Created 5 years, 7 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
OLDNEW
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 5
6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" 6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h"
7 7
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
9 #include "chrome/browser/favicon/favicon_helper.h" 9 #include "chrome/browser/favicon/favicon_helper.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 17 matching lines...) Expand all
28 #endif // defined(ENABLE_PRINT_PREVIEW) 28 #endif // defined(ENABLE_PRINT_PREVIEW)
29 #endif // defined(ENABLE_PRINTING) 29 #endif // defined(ENABLE_PRINTING)
30 30
31 using guest_view::GuestViewEvent; 31 using guest_view::GuestViewEvent;
32 32
33 namespace extensions { 33 namespace extensions {
34 34
35 ChromeWebViewGuestDelegate::ChromeWebViewGuestDelegate( 35 ChromeWebViewGuestDelegate::ChromeWebViewGuestDelegate(
36 WebViewGuest* web_view_guest) 36 WebViewGuest* web_view_guest)
37 : pending_context_menu_request_id_(0), 37 : pending_context_menu_request_id_(0),
38 chromevox_injected_(false),
39 web_view_guest_(web_view_guest), 38 web_view_guest_(web_view_guest),
40 weak_ptr_factory_(this) { 39 weak_ptr_factory_(this) {
41 } 40 }
42 41
43 ChromeWebViewGuestDelegate::~ChromeWebViewGuestDelegate() { 42 ChromeWebViewGuestDelegate::~ChromeWebViewGuestDelegate() {
44 } 43 }
45 44
46 bool ChromeWebViewGuestDelegate::HandleContextMenu( 45 bool ChromeWebViewGuestDelegate::HandleContextMenu(
47 const content::ContextMenuParams& params) { 46 const content::ContextMenuParams& params) {
48 ContextMenuDelegate* menu_delegate = 47 ContextMenuDelegate* menu_delegate =
(...skipping 28 matching lines...) Expand all
77 printing::PrintViewManagerBasic::CreateForWebContents(contents); 76 printing::PrintViewManagerBasic::CreateForWebContents(contents);
78 #endif // defined(ENABLE_PRINT_PREVIEW) 77 #endif // defined(ENABLE_PRINT_PREVIEW)
79 #endif // defined(ENABLE_PRINTING) 78 #endif // defined(ENABLE_PRINTING)
80 pdf::PDFWebContentsHelper::CreateForWebContentsWithClient( 79 pdf::PDFWebContentsHelper::CreateForWebContentsWithClient(
81 contents, 80 contents,
82 scoped_ptr<pdf::PDFWebContentsHelperClient>( 81 scoped_ptr<pdf::PDFWebContentsHelperClient>(
83 new ChromePDFWebContentsHelperClient())); 82 new ChromePDFWebContentsHelperClient()));
84 } 83 }
85 84
86 void ChromeWebViewGuestDelegate::OnDidCommitProvisionalLoadForFrame( 85 void ChromeWebViewGuestDelegate::OnDidCommitProvisionalLoadForFrame(
87 bool is_main_frame) { 86 bool is_main_frame) {
Fady Samuel 2015/05/14 22:31:45 Remove this method and remove it from WebViewGuest
dmazzoni 2015/05/14 22:50:46 Done.
88 if (is_main_frame)
89 chromevox_injected_ = false;
90 } 87 }
91 88
92 void ChromeWebViewGuestDelegate::OnDidInitialize() { 89 void ChromeWebViewGuestDelegate::OnDidInitialize() {
Fady Samuel 2015/05/14 22:31:45 Remove this method and remove it from WebViewGuest
dmazzoni 2015/05/14 22:50:46 Done.
93 #if defined(OS_CHROMEOS)
94 chromeos::AccessibilityManager* accessibility_manager =
95 chromeos::AccessibilityManager::Get();
96 CHECK(accessibility_manager);
97 accessibility_subscription_ = accessibility_manager->RegisterCallback(
98 base::Bind(&ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged,
99 weak_ptr_factory_.GetWeakPtr()));
100 #endif
101 } 90 }
102 91
103 void ChromeWebViewGuestDelegate::OnDocumentLoadedInFrame( 92 void ChromeWebViewGuestDelegate::OnDocumentLoadedInFrame(
104 content::RenderFrameHost* render_frame_host) { 93 content::RenderFrameHost* render_frame_host) {
Fady Samuel 2015/05/14 22:31:45 Remove this method and remove it from WebViewGuest
dmazzoni 2015/05/14 22:50:45 Done.
105 if (!render_frame_host->GetParent())
106 InjectChromeVoxIfNeeded(render_frame_host->GetRenderViewHost());
107 } 94 }
108 95
109 void ChromeWebViewGuestDelegate::OnGuestDestroyed() { 96 void ChromeWebViewGuestDelegate::OnGuestDestroyed() {
110 // Clean up custom context menu items for this guest. 97 // Clean up custom context menu items for this guest.
111 MenuManager* menu_manager = MenuManager::Get( 98 MenuManager* menu_manager = MenuManager::Get(
112 Profile::FromBrowserContext(web_view_guest()->browser_context())); 99 Profile::FromBrowserContext(web_view_guest()->browser_context()));
113 menu_manager->RemoveAllContextItems(MenuItem::ExtensionKey( 100 menu_manager->RemoveAllContextItems(MenuItem::ExtensionKey(
114 web_view_guest()->owner_host(), 101 web_view_guest()->owner_host(),
115 web_view_guest()->view_instance_id())); 102 web_view_guest()->view_instance_id()));
116 } 103 }
(...skipping 25 matching lines...) Expand all
142 return; 129 return;
143 130
144 // TODO(lazyboy): Implement. 131 // TODO(lazyboy): Implement.
145 DCHECK(!items); 132 DCHECK(!items);
146 133
147 ContextMenuDelegate* menu_delegate = 134 ContextMenuDelegate* menu_delegate =
148 ContextMenuDelegate::FromWebContents(guest_web_contents()); 135 ContextMenuDelegate::FromWebContents(guest_web_contents());
149 menu_delegate->ShowMenu(pending_menu_.Pass()); 136 menu_delegate->ShowMenu(pending_menu_.Pass());
150 } 137 }
151 138
152 void ChromeWebViewGuestDelegate::InjectChromeVoxIfNeeded(
153 content::RenderViewHost* render_view_host) {
154 #if defined(OS_CHROMEOS)
155 if (!chromevox_injected_) {
156 chromeos::AccessibilityManager* manager =
157 chromeos::AccessibilityManager::Get();
158 if (manager && manager->IsSpokenFeedbackEnabled()) {
159 manager->InjectChromeVox(render_view_host);
160 chromevox_injected_ = true;
161 }
162 }
163 #endif
164 }
165
166 #if defined(OS_CHROMEOS)
167 void ChromeWebViewGuestDelegate::OnAccessibilityStatusChanged(
168 const chromeos::AccessibilityStatusEventDetails& details) {
169 if (details.notification_type == chromeos::ACCESSIBILITY_MANAGER_SHUTDOWN) {
170 accessibility_subscription_.reset();
171 } else if (details.notification_type ==
172 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) {
173 if (details.enabled)
174 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost());
175 else
176 chromevox_injected_ = false;
177 }
178 }
179 #endif
180
181 } // namespace extensions 139 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h ('k') | extensions/browser/user_script_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698