| 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/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" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // background page) to navigate to non-extension content (i.e. to web | 171 // background page) to navigate to non-extension content (i.e. to web |
| 172 // content). | 172 // content). |
| 173 return !is_main_frame_navigation; | 173 return !is_main_frame_navigation; |
| 174 } | 174 } |
| 175 | 175 |
| 176 bool ExtensionViewHost::PreHandleKeyboardEvent( | 176 bool ExtensionViewHost::PreHandleKeyboardEvent( |
| 177 WebContents* source, | 177 WebContents* source, |
| 178 const NativeWebKeyboardEvent& event, | 178 const NativeWebKeyboardEvent& event, |
| 179 bool* is_keyboard_shortcut) { | 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 DCHECK(is_keyboard_shortcut != NULL); |
| 184 *is_keyboard_shortcut = true; | 184 *is_keyboard_shortcut = true; |
| 185 return false; | 185 return false; |
| 186 } | 186 } |
| 187 | 187 |
| 188 // Handle higher priority browser shortcuts such as Ctrl-w. | 188 // Handle higher priority browser shortcuts such as Ctrl-w. |
| 189 Browser* browser = view_->GetBrowser(); | 189 Browser* browser = view_->GetBrowser(); |
| 190 if (browser) | 190 if (browser) |
| 191 return browser->PreHandleKeyboardEvent(source, event, is_keyboard_shortcut); | 191 return browser->PreHandleKeyboardEvent(source, event, is_keyboard_shortcut); |
| 192 | 192 |
| 193 *is_keyboard_shortcut = false; | 193 *is_keyboard_shortcut = false; |
| 194 return false; | 194 return false; |
| 195 } | 195 } |
| 196 | 196 |
| 197 void ExtensionViewHost::HandleKeyboardEvent( | 197 void ExtensionViewHost::HandleKeyboardEvent( |
| 198 WebContents* source, | 198 WebContents* source, |
| 199 const NativeWebKeyboardEvent& event) { | 199 const NativeWebKeyboardEvent& event) { |
| 200 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) { | 200 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP) { |
| 201 if (event.type == NativeWebKeyboardEvent::RawKeyDown && | 201 if (event.type() == NativeWebKeyboardEvent::RawKeyDown && |
| 202 event.windowsKeyCode == ui::VKEY_ESCAPE) { | 202 event.windowsKeyCode == ui::VKEY_ESCAPE) { |
| 203 Close(); | 203 Close(); |
| 204 return; | 204 return; |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 UnhandledKeyboardEvent(source, event); | 207 UnhandledKeyboardEvent(source, event); |
| 208 } | 208 } |
| 209 | 209 |
| 210 bool ExtensionViewHost::PreHandleGestureEvent( | 210 bool ExtensionViewHost::PreHandleGestureEvent( |
| 211 content::WebContents* source, | 211 content::WebContents* source, |
| 212 const blink::WebGestureEvent& event) { | 212 const blink::WebGestureEvent& event) { |
| 213 // Disable pinch zooming. | 213 // Disable pinch zooming. |
| 214 return event.type == blink::WebGestureEvent::GesturePinchBegin || | 214 return event.type() == blink::WebGestureEvent::GesturePinchBegin || |
| 215 event.type == blink::WebGestureEvent::GesturePinchUpdate || | 215 event.type() == blink::WebGestureEvent::GesturePinchUpdate || |
| 216 event.type == blink::WebGestureEvent::GesturePinchEnd; | 216 event.type() == blink::WebGestureEvent::GesturePinchEnd; |
| 217 } | 217 } |
| 218 | 218 |
| 219 content::ColorChooser* ExtensionViewHost::OpenColorChooser( | 219 content::ColorChooser* ExtensionViewHost::OpenColorChooser( |
| 220 WebContents* web_contents, | 220 WebContents* web_contents, |
| 221 SkColor initial_color, | 221 SkColor initial_color, |
| 222 const std::vector<content::ColorSuggestion>& suggestions) { | 222 const std::vector<content::ColorSuggestion>& suggestions) { |
| 223 // Similar to the file chooser below, opening a color chooser requires a | 223 // Similar to the file chooser below, opening a color chooser requires a |
| 224 // visible <input> element to click on. Therefore this code only exists for | 224 // visible <input> element to click on. Therefore this code only exists for |
| 225 // extensions with a view. | 225 // extensions with a view. |
| 226 return chrome::ShowColorChooser(web_contents, initial_color); | 226 return chrome::ShowColorChooser(web_contents, initial_color); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 const content::NotificationSource& source, | 306 const content::NotificationSource& source, |
| 307 const content::NotificationDetails& details) { | 307 const content::NotificationDetails& details) { |
| 308 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY); | 308 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY); |
| 309 DCHECK(ExtensionSystem::Get(browser_context()) | 309 DCHECK(ExtensionSystem::Get(browser_context()) |
| 310 ->runtime_data() | 310 ->runtime_data() |
| 311 ->IsBackgroundPageReady(extension())); | 311 ->IsBackgroundPageReady(extension())); |
| 312 LoadInitialURL(); | 312 LoadInitialURL(); |
| 313 } | 313 } |
| 314 | 314 |
| 315 } // namespace extensions | 315 } // namespace extensions |
| OLD | NEW |