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

Side by Side Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 10920084: don't display platform app resources in normal browser windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_window.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/extensions/shell_window.h" 5 #include "chrome/browser/ui/extensions/shell_window.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_process_manager.h" 8 #include "chrome/browser/extensions/extension_process_manager.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "chrome/browser/extensions/shell_window_geometry_cache.h" 10 #include "chrome/browser/extensions/shell_window_geometry_cache.h"
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 devices.push_back(iter->second[0]); 203 devices.push_back(iter->second[0]);
204 } 204 }
205 205
206 callback.Run(devices); 206 callback.Run(devices);
207 } 207 }
208 208
209 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, 209 WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
210 const content::OpenURLParams& params) { 210 const content::OpenURLParams& params) {
211 DCHECK(source == web_contents_); 211 DCHECK(source == web_contents_);
212 212
213 if (params.url.host() == extension_->id()) {
214 AddMessageToDevToolsConsole(
215 content::CONSOLE_MESSAGE_LEVEL_ERROR,
216 base::StringPrintf(
217 "Can't navigate to \"%s\"; apps do not support navigation.",
218 params.url.spec().c_str()));
219 return NULL;
220 }
221
222 // Don't allow the current tab to be navigated. It would be nice to map all
Evan Stade 2012/09/06 18:29:52 you can view this change as a proposal. Here is a
Mihai Parparita -not on Chrome 2012/09/06 18:40:35 This seems OK to me. To make it more obvious in th
223 // anchor tags (even those without target="_blank") to new tabs, but right
224 // now we can't distinguish between those and <meta> refreshes, which we
225 // don't want to allow.
226 // TOOD(mihaip): Can we check for user gestures instead?
227 WindowOpenDisposition disposition = params.disposition; 213 WindowOpenDisposition disposition = params.disposition;
228 if (disposition == CURRENT_TAB) {
229 AddMessageToDevToolsConsole(
230 content::CONSOLE_MESSAGE_LEVEL_ERROR,
231 base::StringPrintf(
232 "Can't open same-window link to \"%s\"; try target=\"_blank\".",
233 params.url.spec().c_str()));
234 return NULL;
235 }
236
237 // These dispositions aren't really navigations. 214 // These dispositions aren't really navigations.
238 if (disposition == SUPPRESS_OPEN || disposition == SAVE_TO_DISK || 215 if (disposition == SUPPRESS_OPEN || disposition == SAVE_TO_DISK ||
239 disposition == IGNORE_ACTION) { 216 disposition == IGNORE_ACTION) {
240 return NULL; 217 return NULL;
241 } 218 }
242 219
243 // Force all links to open in a new tab, even if they were trying to open a 220 // Force all links to open in a new tab, even if they were trying to open a
244 // window. 221 // window.
245 content::OpenURLParams new_tab_params = params; 222 chrome::NavigateParams new_tab_params(
223 static_cast<Browser*>(NULL), params.url, params.transition);
246 new_tab_params.disposition = 224 new_tab_params.disposition =
247 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; 225 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
248 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); 226 new_tab_params.initiating_profile = profile_;
249 WebContents* new_tab = browser->OpenURL(new_tab_params); 227 chrome::Navigate(&new_tab_params);
250 browser->window()->Show(); 228
251 return new_tab; 229 WebContents* new_contents = new_tab_params.target_contents ?
230 new_tab_params.target_contents->web_contents() : NULL;
231 if (!new_contents) {
232 AddMessageToDevToolsConsole(
233 content::CONSOLE_MESSAGE_LEVEL_ERROR,
234 base::StringPrintf(
235 "Can't navigate to \"%s\"; apps do not support navigation.",
236 params.url.spec().c_str()));
237 }
238
239 return new_contents;
252 } 240 }
253 241
254 void ShellWindow::AddNewContents(WebContents* source, 242 void ShellWindow::AddNewContents(WebContents* source,
255 WebContents* new_contents, 243 WebContents* new_contents,
256 WindowOpenDisposition disposition, 244 WindowOpenDisposition disposition,
257 const gfx::Rect& initial_pos, 245 const gfx::Rect& initial_pos,
258 bool user_gesture) { 246 bool user_gesture) {
259 DCHECK(source == web_contents_); 247 DCHECK(source == web_contents_);
260 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == 248 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) ==
261 profile_); 249 profile_);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 return; 409 return;
422 410
423 extensions::ShellWindowGeometryCache* cache = 411 extensions::ShellWindowGeometryCache* cache =
424 extensions::ExtensionSystem::Get(profile())-> 412 extensions::ExtensionSystem::Get(profile())->
425 shell_window_geometry_cache(); 413 shell_window_geometry_cache();
426 414
427 gfx::Rect bounds = native_window_->GetBounds(); 415 gfx::Rect bounds = native_window_->GetBounds();
428 cache->SaveGeometry(extension()->id(), window_key_, bounds); 416 cache->SaveGeometry(extension()->id(), window_key_, bounds);
429 } 417 }
430 418
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_window.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698