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

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

Issue 2352083003: Allow top-level navigation in extension pop-ups if it only triggers a download. (Closed)
Patch Set: Changed bug reference (in a TODO comment) to a fresh bug. Created 4 years, 2 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"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_view_host.h ('k') | chrome/browser/extensions/process_management_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698