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/extensions/extension_view_host.h" | 5 #include "chrome/browser/extensions/extension_view_host.h" |
6 | 6 |
7 #include "base/strings/string_piece.h" | 7 #include "base/strings/string_piece.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/extensions/window_controller.h" | 9 #include "chrome/browser/extensions/window_controller.h" |
10 #include "chrome/browser/file_select_helper.h" | 10 #include "chrome/browser/file_select_helper.h" |
11 #include "chrome/browser/platform_util.h" | 11 #include "chrome/browser/platform_util.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_dialogs.h" | 13 #include "chrome/browser/ui/browser_dialogs.h" |
14 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 14 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
15 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
16 #include "content/public/browser/render_frame_host.h" | 16 #include "content/public/browser/render_frame_host.h" |
17 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
18 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
19 #include "content/public/browser/web_contents_view.h" | 19 #include "content/public/browser/web_contents_view.h" |
20 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
21 #include "extensions/browser/runtime_data.h" | 21 #include "extensions/browser/runtime_data.h" |
22 #include "extensions/common/extension_messages.h" | 22 #include "extensions/common/extension_messages.h" |
23 #include "grit/browser_resources.h" | 23 #include "grit/browser_resources.h" |
| 24 #include "third_party/WebKit/public/web/WebInputEvent.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/events/keycodes/keyboard_codes.h" | 26 #include "ui/events/keycodes/keyboard_codes.h" |
26 | 27 |
27 using content::NativeWebKeyboardEvent; | 28 using content::NativeWebKeyboardEvent; |
28 using content::OpenURLParams; | 29 using content::OpenURLParams; |
29 using content::RenderViewHost; | 30 using content::RenderViewHost; |
30 using content::WebContents; | 31 using content::WebContents; |
31 using content::WebContentsObserver; | 32 using content::WebContentsObserver; |
32 using web_modal::WebContentsModalDialogManager; | 33 using web_modal::WebContentsModalDialogManager; |
33 | 34 |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) { | 216 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) { |
216 if (event.type == NativeWebKeyboardEvent::RawKeyDown && | 217 if (event.type == NativeWebKeyboardEvent::RawKeyDown && |
217 event.windowsKeyCode == ui::VKEY_ESCAPE) { | 218 event.windowsKeyCode == ui::VKEY_ESCAPE) { |
218 Close(); | 219 Close(); |
219 return; | 220 return; |
220 } | 221 } |
221 } | 222 } |
222 UnhandledKeyboardEvent(source, event); | 223 UnhandledKeyboardEvent(source, event); |
223 } | 224 } |
224 | 225 |
| 226 bool ExtensionViewHost::PreHandleGestureEvent( |
| 227 content::WebContents* source, |
| 228 const blink::WebGestureEvent& event) { |
| 229 // Disable pinch zooming. |
| 230 return event.type == blink::WebGestureEvent::GesturePinchBegin || |
| 231 event.type == blink::WebGestureEvent::GesturePinchUpdate || |
| 232 event.type == blink::WebGestureEvent::GesturePinchEnd; |
| 233 } |
| 234 |
225 content::ColorChooser* ExtensionViewHost::OpenColorChooser( | 235 content::ColorChooser* ExtensionViewHost::OpenColorChooser( |
226 WebContents* web_contents, | 236 WebContents* web_contents, |
227 SkColor initial_color, | 237 SkColor initial_color, |
228 const std::vector<content::ColorSuggestion>& suggestions) { | 238 const std::vector<content::ColorSuggestion>& suggestions) { |
229 // Similar to the file chooser below, opening a color chooser requires a | 239 // Similar to the file chooser below, opening a color chooser requires a |
230 // visible <input> element to click on. Therefore this code only exists for | 240 // visible <input> element to click on. Therefore this code only exists for |
231 // extensions with a view. | 241 // extensions with a view. |
232 return chrome::ShowColorChooser(web_contents, initial_color); | 242 return chrome::ShowColorChooser(web_contents, initial_color); |
233 } | 243 } |
234 | 244 |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 341 |
332 void ExtensionViewHost::InsertInfobarCSS() { | 342 void ExtensionViewHost::InsertInfobarCSS() { |
333 static const base::StringPiece css( | 343 static const base::StringPiece css( |
334 ResourceBundle::GetSharedInstance().GetRawDataResource( | 344 ResourceBundle::GetSharedInstance().GetRawDataResource( |
335 IDR_EXTENSIONS_INFOBAR_CSS)); | 345 IDR_EXTENSIONS_INFOBAR_CSS)); |
336 | 346 |
337 host_contents()->GetMainFrame()->InsertCSS(css.as_string()); | 347 host_contents()->GetMainFrame()->InsertCSS(css.as_string()); |
338 } | 348 } |
339 | 349 |
340 } // namespace extensions | 350 } // namespace extensions |
OLD | NEW |