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

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: forgot to add Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_window.h ('k') | chrome/common/url_constants.h » ('j') | 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 } 217 }
218 } 218 }
219 219
220 callback.Run(devices); 220 callback.Run(devices);
221 } 221 }
222 222
223 WebContents* ShellWindow::OpenURLFromTab(WebContents* source, 223 WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
224 const content::OpenURLParams& params) { 224 const content::OpenURLParams& params) {
225 DCHECK(source == web_contents_); 225 DCHECK(source == web_contents_);
226 226
227 if (params.url.host() == extension_->id()) {
228 AddMessageToDevToolsConsole(
229 content::CONSOLE_MESSAGE_LEVEL_ERROR,
230 base::StringPrintf(
231 "Can't navigate to \"%s\"; apps do not support navigation.",
232 params.url.spec().c_str()));
233 return NULL;
234 }
235
236 // Don't allow the current tab to be navigated. It would be nice to map all 227 // Don't allow the current tab to be navigated. It would be nice to map all
237 // anchor tags (even those without target="_blank") to new tabs, but right 228 // anchor tags (even those without target="_blank") to new tabs, but right
238 // now we can't distinguish between those and <meta> refreshes, which we 229 // now we can't distinguish between those and <meta> refreshes or window.href
239 // don't want to allow. 230 // navigations, which we don't want to allow.
240 // TOOD(mihaip): Can we check for user gestures instead? 231 // TOOD(mihaip): Can we check for user gestures instead?
241 WindowOpenDisposition disposition = params.disposition; 232 WindowOpenDisposition disposition = params.disposition;
242 if (disposition == CURRENT_TAB) { 233 if (disposition == CURRENT_TAB) {
243 AddMessageToDevToolsConsole( 234 AddMessageToDevToolsConsole(
244 content::CONSOLE_MESSAGE_LEVEL_ERROR, 235 content::CONSOLE_MESSAGE_LEVEL_ERROR,
245 base::StringPrintf( 236 base::StringPrintf(
246 "Can't open same-window link to \"%s\"; try target=\"_blank\".", 237 "Can't open same-window link to \"%s\"; try target=\"_blank\".",
247 params.url.spec().c_str())); 238 params.url.spec().c_str()));
248 return NULL; 239 return NULL;
249 } 240 }
250 241
251 // These dispositions aren't really navigations. 242 // These dispositions aren't really navigations.
252 if (disposition == SUPPRESS_OPEN || disposition == SAVE_TO_DISK || 243 if (disposition == SUPPRESS_OPEN || disposition == SAVE_TO_DISK ||
253 disposition == IGNORE_ACTION) { 244 disposition == IGNORE_ACTION) {
254 return NULL; 245 return NULL;
255 } 246 }
256 247
257 // Force all links to open in a new tab, even if they were trying to open a 248 // Force all links to open in a new tab, even if they were trying to open a
258 // window. 249 // window.
259 content::OpenURLParams new_tab_params = params; 250 chrome::NavigateParams new_tab_params(
251 static_cast<Browser*>(NULL), params.url, params.transition);
260 new_tab_params.disposition = 252 new_tab_params.disposition =
261 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB; 253 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
262 Browser* browser = browser::FindOrCreateTabbedBrowser(profile_); 254 new_tab_params.initiating_profile = profile_;
263 WebContents* new_tab = browser->OpenURL(new_tab_params); 255 chrome::Navigate(&new_tab_params);
264 browser->window()->Show(); 256
265 return new_tab; 257 WebContents* new_contents = new_tab_params.target_contents ?
258 new_tab_params.target_contents->web_contents() : NULL;
259 if (!new_contents) {
260 AddMessageToDevToolsConsole(
261 content::CONSOLE_MESSAGE_LEVEL_ERROR,
262 base::StringPrintf(
263 "Can't navigate to \"%s\"; apps do not support navigation.",
264 params.url.spec().c_str()));
265 }
266
267 return new_contents;
266 } 268 }
267 269
268 void ShellWindow::AddNewContents(WebContents* source, 270 void ShellWindow::AddNewContents(WebContents* source,
269 WebContents* new_contents, 271 WebContents* new_contents,
270 WindowOpenDisposition disposition, 272 WindowOpenDisposition disposition,
271 const gfx::Rect& initial_pos, 273 const gfx::Rect& initial_pos,
272 bool user_gesture, 274 bool user_gesture,
273 bool* was_blocked) { 275 bool* was_blocked) {
274 DCHECK(source == web_contents_); 276 DCHECK(source == web_contents_);
275 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == 277 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) ==
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (window_key_.empty()) 484 if (window_key_.empty())
483 return; 485 return;
484 486
485 extensions::ShellWindowGeometryCache* cache = 487 extensions::ShellWindowGeometryCache* cache =
486 extensions::ExtensionSystem::Get(profile())-> 488 extensions::ExtensionSystem::Get(profile())->
487 shell_window_geometry_cache(); 489 shell_window_geometry_cache();
488 490
489 gfx::Rect bounds = native_window_->GetBounds(); 491 gfx::Rect bounds = native_window_->GetBounds();
490 cache->SaveGeometry(extension()->id(), window_key_, bounds); 492 cache->SaveGeometry(extension()->id(), window_key_, bounds);
491 } 493 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_window.h ('k') | chrome/common/url_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698