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

Unified Diff: chrome/browser/extensions/platform_app_browsertest_util.h

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 according to Mihaip's comment. 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.h
diff --git a/chrome/browser/extensions/platform_app_browsertest_util.h b/chrome/browser/extensions/platform_app_browsertest_util.h
index 3d3a2a7d40efd36e9d4d74b9e443b0147b72f2b3..a3d9cc64c0d4808fde42501f60b4e20daa711162 100644
--- a/chrome/browser/extensions/platform_app_browsertest_util.h
+++ b/chrome/browser/extensions/platform_app_browsertest_util.h
@@ -7,6 +7,9 @@
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
namespace content {
@@ -19,9 +22,43 @@ class ShellWindow;
namespace extensions {
class Extension;
+class MockExternalUrlController : public content::WebContentsDelegate {
Mihai Parparita -not on Chrome 2012/10/12 23:00:17 This doesn't need to be defined in the header, it
+ public:
+ MockExternalUrlController() {}
+
+ private:
+ // content::WebContentsDelegate implementation.
+ virtual content::WebContents* OpenURLFromTab(
+ content::WebContents* source,
+ const content::OpenURLParams& params) OVERRIDE {
+ // 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;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(MockExternalUrlController);
+};
+
class PlatformAppBrowserTest : public ExtensionApiTest {
public:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
+ virtual void SetUpOnMainThread() OVERRIDE;
protected:
// Runs the app named |name| out of the platform_apps subdirectory. Waits
@@ -66,6 +103,8 @@ class PlatformAppBrowserTest : public ExtensionApiTest {
// Closes |window| and waits until it's gone.
void CloseShellWindow(ShellWindow* window);
+
+ scoped_ptr<MockExternalUrlController> mock_external_url_controller_;
};
}

Powered by Google App Engine
This is Rietveld 408576698