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

Unified Diff: chrome/browser/ui/extensions/shell_window.cc

Issue 10915047: Links in platform apps should open in the system default browser. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: refine the patch. 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/extensions/shell_window.cc
diff --git a/chrome/browser/ui/extensions/shell_window.cc b/chrome/browser/ui/extensions/shell_window.cc
index 9f8a75a59f77baca23cb782d2ca81ec4b85e251b..91fb6655a97a0b296364d26d178102daf91e13f0 100644
--- a/chrome/browser/ui/extensions/shell_window.cc
+++ b/chrome/browser/ui/extensions/shell_window.cc
@@ -4,6 +4,20 @@
#include "chrome/browser/ui/extensions/shell_window.h"
+#if defined(OS_WIN)
+#include <windows.h>
+#include <shellapi.h>
+#endif // OS_WIN
+
+#if defined(OS_POSIX)
+#include "chrome/browser/shell_integration_linux.h"
+#endif // OS_POSIX
+
+#if defined(OS_MACOSX)
+#include <CoreFoundation/CFBundle.h>
+#include <ApplicationServices/ApplicationServices.h>
+#endif // OS_MACOSX
Marijn Kruisselbrink 2012/09/04 15:40:53 I think the chromium coding style says platform-sp
+
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_system.h"
@@ -201,6 +215,22 @@ void ShellWindow::RequestMediaAccessPermission(
WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
const content::OpenURLParams& params) {
+#if defined(OS_WIN)
+ ShellExecuteA(NULL, "open", params.url.spec().c_str(),
+ NULL, NULL, SW_SHOWNORMAL);
+#elif defined(OS_POSIX)
+ ShellIntegrationLinux::LaunchDefaultBrowser(params.url);
+#elif defined(OS_MACOSX)
+ CFURLRef url = CFURLCreateWithBytes(
+ NULL,
+ (UInt8*)params.url.spec().c_str(),
+ params.url.spec().length(),
+ kCFStringEncodingASCII,
+ NULL
+ );
+ LSOpenCFURLRef(url,0);
+ CFRelease(url);
jeremya 2012/09/03 02:42:29 It's kind of icky to have all these #ifdefs here.
+#else
DCHECK(source == web_contents_);
if (params.url.host() == extension_->id()) {
@@ -242,6 +272,9 @@ WebContents* ShellWindow::OpenURLFromTab(WebContents* source,
WebContents* new_tab = browser->OpenURL(new_tab_params);
browser->window()->Show();
return new_tab;
+#endif
+ source->SetDelegate(NULL);
jeremya 2012/09/03 02:42:29 Rather than setting the delegate to the ShellWindo
+ return NULL;
}
void ShellWindow::AddNewContents(WebContents* source,
@@ -252,6 +285,10 @@ void ShellWindow::AddNewContents(WebContents* source,
DCHECK(source == web_contents_);
DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) ==
profile_);
+
+#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_POSIX)
+ new_contents->SetDelegate(this);
+#else
Browser* browser = browser::FindOrCreateTabbedBrowser(profile_);
// Force all links to open in a new tab, even if they were trying to open a
// new window.
@@ -259,6 +296,7 @@ void ShellWindow::AddNewContents(WebContents* source,
disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
chrome::AddWebContents(browser, NULL, new_contents, disposition, initial_pos,
user_gesture);
+#endif
}
void ShellWindow::HandleKeyboardEvent(
« chrome/browser/shell_integration_linux.cc ('K') | « chrome/browser/shell_integration_linux.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698