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

Side by Side Diff: chrome/browser/extensions/extension_view_host.cc

Issue 2775553002: Adds the ability for WebContentsDelegate to decide if event should be updated (Closed)
Patch Set: Fix compile Created 3 years, 9 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 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/extensions/extension_view_host.h" 5 #include "chrome/browser/extensions/extension_view_host.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/strings/string_piece.h" 8 #include "base/strings/string_piece.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
11 #include "chrome/browser/extensions/extension_view.h" 11 #include "chrome/browser/extensions/extension_view.h"
12 #include "chrome/browser/extensions/window_controller.h" 12 #include "chrome/browser/extensions/window_controller.h"
13 #include "chrome/browser/file_select_helper.h" 13 #include "chrome/browser/file_select_helper.h"
14 #include "chrome/browser/platform_util.h" 14 #include "chrome/browser/platform_util.h"
15 #include "chrome/browser/ui/autofill/chrome_autofill_client.h" 15 #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
16 #include "chrome/browser/ui/browser.h" 16 #include "chrome/browser/ui/browser.h"
17 #include "chrome/browser/ui/browser_dialogs.h" 17 #include "chrome/browser/ui/browser_dialogs.h"
18 #include "components/autofill/content/browser/content_autofill_driver_factory.h" 18 #include "components/autofill/content/browser/content_autofill_driver_factory.h"
19 #include "components/autofill/core/browser/autofill_manager.h" 19 #include "components/autofill/core/browser/autofill_manager.h"
20 #include "components/web_modal/web_contents_modal_dialog_manager.h" 20 #include "components/web_modal/web_contents_modal_dialog_manager.h"
21 #include "content/public/browser/keyboard_event_processing_result.h"
21 #include "content/public/browser/notification_source.h" 22 #include "content/public/browser/notification_source.h"
22 #include "content/public/browser/render_view_host.h" 23 #include "content/public/browser/render_view_host.h"
23 #include "content/public/browser/render_widget_host.h" 24 #include "content/public/browser/render_widget_host.h"
24 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
25 #include "extensions/browser/extension_system.h" 26 #include "extensions/browser/extension_system.h"
26 #include "extensions/browser/runtime_data.h" 27 #include "extensions/browser/runtime_data.h"
27 #include "third_party/WebKit/public/platform/WebInputEvent.h" 28 #include "third_party/WebKit/public/platform/WebInputEvent.h"
28 #include "ui/base/resource/resource_bundle.h" 29 #include "ui/base/resource/resource_bundle.h"
29 #include "ui/events/keycodes/keyboard_codes.h" 30 #include "ui/events/keycodes/keyboard_codes.h"
30 31
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 167 }
167 168
168 bool ExtensionViewHost::ShouldTransferNavigation( 169 bool ExtensionViewHost::ShouldTransferNavigation(
169 bool is_main_frame_navigation) { 170 bool is_main_frame_navigation) {
170 // Block navigations that cause main frame of an extension pop-up (or 171 // Block navigations that cause main frame of an extension pop-up (or
171 // background page) to navigate to non-extension content (i.e. to web 172 // background page) to navigate to non-extension content (i.e. to web
172 // content). 173 // content).
173 return !is_main_frame_navigation; 174 return !is_main_frame_navigation;
174 } 175 }
175 176
176 bool ExtensionViewHost::PreHandleKeyboardEvent( 177 content::KeyboardEventProcessingResult
177 WebContents* source, 178 ExtensionViewHost::PreHandleKeyboardEvent(WebContents* source,
178 const NativeWebKeyboardEvent& event, 179 const NativeWebKeyboardEvent& event) {
179 bool* is_keyboard_shortcut) {
180 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP && 180 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP &&
181 event.type() == NativeWebKeyboardEvent::RawKeyDown && 181 event.type() == NativeWebKeyboardEvent::RawKeyDown &&
182 event.windowsKeyCode == ui::VKEY_ESCAPE) { 182 event.windowsKeyCode == ui::VKEY_ESCAPE) {
183 DCHECK(is_keyboard_shortcut != NULL); 183 return content::KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT;
184 *is_keyboard_shortcut = true;
185 return false;
186 } 184 }
187 185
188 // Handle higher priority browser shortcuts such as Ctrl-w. 186 // Handle higher priority browser shortcuts such as Ctrl-w.
189 Browser* browser = view_->GetBrowser(); 187 Browser* browser = view_->GetBrowser();
190 if (browser) 188 if (browser)
191 return browser->PreHandleKeyboardEvent(source, event, is_keyboard_shortcut); 189 return browser->PreHandleKeyboardEvent(source, event);
192 190
193 *is_keyboard_shortcut = false; 191 return content::KeyboardEventProcessingResult::NOT_HANDLED;
194 return false;
195 } 192 }
196 193
197 void ExtensionViewHost::HandleKeyboardEvent( 194 void ExtensionViewHost::HandleKeyboardEvent(
198 WebContents* source, 195 WebContents* source,
199 const NativeWebKeyboardEvent& event) { 196 const NativeWebKeyboardEvent& event) {
200 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) { 197 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) {
201 if (event.type() == NativeWebKeyboardEvent::RawKeyDown && 198 if (event.type() == NativeWebKeyboardEvent::RawKeyDown &&
202 event.windowsKeyCode == ui::VKEY_ESCAPE) { 199 event.windowsKeyCode == ui::VKEY_ESCAPE) {
203 Close(); 200 Close();
204 return; 201 return;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 const content::NotificationSource& source, 303 const content::NotificationSource& source,
307 const content::NotificationDetails& details) { 304 const content::NotificationDetails& details) {
308 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY); 305 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY);
309 DCHECK(ExtensionSystem::Get(browser_context()) 306 DCHECK(ExtensionSystem::Get(browser_context())
310 ->runtime_data() 307 ->runtime_data()
311 ->IsBackgroundPageReady(extension())); 308 ->IsBackgroundPageReady(extension()));
312 LoadInitialURL(); 309 LoadInitialURL();
313 } 310 }
314 311
315 } // namespace extensions 312 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_view_host.h ('k') | chrome/browser/extensions/global_shortcut_listener_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698