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

Unified Diff: chrome/browser/extensions/platform_app_browsertest_util.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: 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/platform_app_browsertest_util.cc
diff --git a/chrome/browser/extensions/platform_app_browsertest_util.cc b/chrome/browser/extensions/platform_app_browsertest_util.cc
index a722eb590f43465756c4dcc0d13fa7a596aad27a..2795469610a83fd9694b1618ccb95b8ad02a4001 100644
--- a/chrome/browser/extensions/platform_app_browsertest_util.cc
+++ b/chrome/browser/extensions/platform_app_browsertest_util.cc
@@ -10,6 +10,8 @@
#include "chrome/browser/extensions/extension_function_test_utils.h"
#include "chrome/browser/extensions/shell_window_registry.h"
#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/extensions/shell_window.h"
#include "chrome/common/chrome_switches.h"
@@ -22,11 +24,53 @@ namespace utils = extension_function_test_utils;
namespace extensions {
+MockExternalUrlController::MockExternalUrlController() {
+}
+
+MockExternalUrlController::~MockExternalUrlController() {
+}
+
+content::WebContents* MockExternalUrlController::OpenURLFromTab(
+ content::WebContents* source,
+ const content::OpenURLParams& params) {
+ // Delete useless web content first to
+ // avoid a potential leak in a render process host.
+ delete source;
+
+ // Force to open in a new tab.
+ WindowOpenDisposition disposition = params.disposition;
+ content::OpenURLParams new_tab_params = params;
+ new_tab_params.disposition =
+ disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
+ for (BrowserList::const_iterator i = BrowserList::begin();
+ i != BrowserList::end(); ++i) {
+ if ((*i)->is_type_tabbed()) {
+ Browser* browser = *i;
+ content::WebContents* new_tab = browser->OpenURL(new_tab_params);
+ browser->window()->Show();
+ return new_tab;
+ }
+ }
+ return NULL;
+}
+
+PlatformAppBrowserTest::PlatformAppBrowserTest() {
+}
+
+PlatformAppBrowserTest::~PlatformAppBrowserTest() {
+}
+
void PlatformAppBrowserTest::SetUpCommandLine(CommandLine* command_line) {
ExtensionBrowserTest::SetUpCommandLine(command_line);
command_line->AppendSwitch(switches::kEnableExperimentalExtensionApis);
}
+void PlatformAppBrowserTest::SetUpOnMainThread() {
+ mock_external_url_controller_.reset(new MockExternalUrlController());
+ ShellWindow::SetExternalUrlControllerForTesting(
+ mock_external_url_controller_.get());
+}
+
const Extension* PlatformAppBrowserTest::LoadAndLaunchPlatformApp(
const char* name) {
content::WindowedNotificationObserver app_loaded_observer(
« no previous file with comments | « chrome/browser/extensions/platform_app_browsertest_util.h ('k') | chrome/browser/ui/extensions/shell_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698