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

Side by Side 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 unified diff | Download patch
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 #ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_
6 #define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ 6 #define CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_
7 7
8 8
9 #include "chrome/browser/extensions/extension_apitest.h" 9 #include "chrome/browser/extensions/extension_apitest.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_list.h"
12 #include "chrome/browser/ui/browser_window.h"
10 13
11 14
12 namespace content { 15 namespace content {
13 class WebContents; 16 class WebContents;
14 } 17 }
15 18
16 class CommandLine; 19 class CommandLine;
17 class ShellWindow; 20 class ShellWindow;
18 21
19 namespace extensions { 22 namespace extensions {
20 class Extension; 23 class Extension;
21 24
25 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
26 public:
27 MockExternalUrlController() {}
28
29 private:
30 // content::WebContentsDelegate implementation.
31 virtual content::WebContents* OpenURLFromTab(
32 content::WebContents* source,
33 const content::OpenURLParams& params) OVERRIDE {
34 // Delete useless web content first to
35 // avoid a potential leak in a render process host.
36 delete source;
37
38 // Force to open in a new tab.
39 WindowOpenDisposition disposition = params.disposition;
40 content::OpenURLParams new_tab_params = params;
41 new_tab_params.disposition =
42 disposition == NEW_BACKGROUND_TAB ? disposition : NEW_FOREGROUND_TAB;
43 for (BrowserList::const_iterator i = BrowserList::begin();
44 i != BrowserList::end(); ++i) {
45 if ((*i)->is_type_tabbed()) {
46 Browser* browser = *i;
47 content::WebContents* new_tab = browser->OpenURL(new_tab_params);
48 browser->window()->Show();
49 return new_tab;
50 }
51 }
52 return NULL;
53 }
54
55 DISALLOW_COPY_AND_ASSIGN(MockExternalUrlController);
56 };
57
22 class PlatformAppBrowserTest : public ExtensionApiTest { 58 class PlatformAppBrowserTest : public ExtensionApiTest {
23 public: 59 public:
24 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE; 60 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
61 virtual void SetUpOnMainThread() OVERRIDE;
25 62
26 protected: 63 protected:
27 // Runs the app named |name| out of the platform_apps subdirectory. Waits 64 // Runs the app named |name| out of the platform_apps subdirectory. Waits
28 // until it is launched. 65 // until it is launched.
29 const Extension* LoadAndLaunchPlatformApp(const char* name); 66 const Extension* LoadAndLaunchPlatformApp(const char* name);
30 67
31 // Installs and runs the app named |name| out of the platform_apps 68 // Installs and runs the app named |name| out of the platform_apps
32 // subdirectory. Waits until it is launched. 69 // subdirectory. Waits until it is launched.
33 const Extension* InstallAndLaunchPlatformApp(const char* name); 70 const Extension* InstallAndLaunchPlatformApp(const char* name);
34 71
(...skipping 24 matching lines...) Expand all
59 void ClearCommandLineArgs(); 96 void ClearCommandLineArgs();
60 97
61 // Sets up the command line for running platform apps. 98 // Sets up the command line for running platform apps.
62 void SetCommandLineArg(const std::string& test_file); 99 void SetCommandLineArg(const std::string& test_file);
63 100
64 // Creates an empty shell window for |extension|. 101 // Creates an empty shell window for |extension|.
65 ShellWindow* CreateShellWindow(const Extension* extension); 102 ShellWindow* CreateShellWindow(const Extension* extension);
66 103
67 // Closes |window| and waits until it's gone. 104 // Closes |window| and waits until it's gone.
68 void CloseShellWindow(ShellWindow* window); 105 void CloseShellWindow(ShellWindow* window);
106
107 scoped_ptr<MockExternalUrlController> mock_external_url_controller_;
69 }; 108 };
70 109
71 } 110 }
72 111
73 #endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_ 112 #endif // CHROME_BROWSER_EXTENSIONS_PLATFORM_APP_BROWSERTEST_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698