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