| 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 // Only allow these from hosts that are bound to a browser (e.g. popups). | 159 // Only allow these from hosts that are bound to a browser (e.g. popups). |
| 160 // Otherwise they are not driven by a user gesture. | 160 // Otherwise they are not driven by a user gesture. |
| 161 Browser* browser = view_->GetBrowser(); | 161 Browser* browser = view_->GetBrowser(); |
| 162 return browser ? browser->OpenURL(params) : NULL; | 162 return browser ? browser->OpenURL(params) : NULL; |
| 163 } | 163 } |
| 164 default: | 164 default: |
| 165 return NULL; | 165 return NULL; |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 bool ExtensionViewHost::ShouldTransferNavigation( |
| 170 bool is_main_frame_navigation) { |
| 171 // Block navigations that cause main frame of an extension pop-up (or |
| 172 // background page) to navigate to non-extension content (i.e. to web |
| 173 // content). |
| 174 return !is_main_frame_navigation; |
| 175 } |
| 176 |
| 169 bool ExtensionViewHost::PreHandleKeyboardEvent( | 177 bool ExtensionViewHost::PreHandleKeyboardEvent( |
| 170 WebContents* source, | 178 WebContents* source, |
| 171 const NativeWebKeyboardEvent& event, | 179 const NativeWebKeyboardEvent& event, |
| 172 bool* is_keyboard_shortcut) { | 180 bool* is_keyboard_shortcut) { |
| 173 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP && | 181 if (extension_host_type() == VIEW_TYPE_EXTENSION_POPUP && |
| 174 event.type == NativeWebKeyboardEvent::RawKeyDown && | 182 event.type == NativeWebKeyboardEvent::RawKeyDown && |
| 175 event.windowsKeyCode == ui::VKEY_ESCAPE) { | 183 event.windowsKeyCode == ui::VKEY_ESCAPE) { |
| 176 DCHECK(is_keyboard_shortcut != NULL); | 184 DCHECK(is_keyboard_shortcut != NULL); |
| 177 *is_keyboard_shortcut = true; | 185 *is_keyboard_shortcut = true; |
| 178 return false; | 186 return false; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 const content::NotificationSource& source, | 307 const content::NotificationSource& source, |
| 300 const content::NotificationDetails& details) { | 308 const content::NotificationDetails& details) { |
| 301 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY); | 309 DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY); |
| 302 DCHECK(ExtensionSystem::Get(browser_context()) | 310 DCHECK(ExtensionSystem::Get(browser_context()) |
| 303 ->runtime_data() | 311 ->runtime_data() |
| 304 ->IsBackgroundPageReady(extension())); | 312 ->IsBackgroundPageReady(extension())); |
| 305 LoadInitialURL(); | 313 LoadInitialURL(); |
| 306 } | 314 } |
| 307 | 315 |
| 308 } // namespace extensions | 316 } // namespace extensions |
| OLD | NEW |