OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/test/permission_bubble_browsertest.h" | |
6 | |
7 #include "base/command_line.h" | |
8 #include "chrome/browser/extensions/extension_browsertest.h" | |
9 #include "chrome/browser/ui/browser.h" | |
10 #include "chrome/browser/ui/browser_finder.h" | |
11 #include "chrome/browser/ui/browser_window.h" | |
12 #include "chrome/browser/ui/extensions/app_launch_params.h" | |
13 #include "chrome/browser/ui/extensions/application_launch.h" | |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
15 #include "chrome/browser/ui/website_settings/mock_permission_bubble_request.h" | |
16 #include "chrome/common/chrome_switches.h" | |
17 #include "chrome/grit/generated_resources.h" | |
18 #include "ui/base/l10n/l10n_util.h" | |
19 | |
20 // TestPermissionBubbleViewDelegate //////////////////////////////////////////// | |
21 | |
22 TestPermissionBubbleViewDelegate::TestPermissionBubbleViewDelegate() | |
23 : PermissionBubbleView::Delegate() { | |
24 } | |
25 | |
26 // PermissionBubbleBrowsertest ///////////////////////////////////////////////// | |
27 | |
28 PermissionBubbleBrowsertest::PermissionBubbleBrowsertest() | |
29 : ExtensionBrowserTest() { | |
30 } | |
31 | |
32 PermissionBubbleBrowsertest::~PermissionBubbleBrowsertest() { | |
33 } | |
34 | |
35 void PermissionBubbleBrowsertest::SetUpOnMainThread() { | |
36 ExtensionBrowserTest::SetUpOnMainThread(); | |
37 | |
38 // Add a single permission request. | |
39 MockPermissionBubbleRequest* request = new MockPermissionBubbleRequest( | |
40 "Request 1", l10n_util::GetStringUTF8(IDS_PERMISSION_ALLOW), | |
41 l10n_util::GetStringUTF8(IDS_PERMISSION_DENY)); | |
42 requests_.push_back(request); | |
43 } | |
44 | |
45 // PermissionBubbleAppBrowsertest ////////////////////////////////////////////// | |
46 | |
47 PermissionBubbleAppBrowsertest::PermissionBubbleAppBrowsertest() | |
48 : PermissionBubbleBrowsertest(), app_browser_(nullptr) { | |
49 } | |
50 | |
51 PermissionBubbleAppBrowsertest::~PermissionBubbleAppBrowsertest() { | |
52 } | |
53 | |
54 void PermissionBubbleAppBrowsertest::SetUpOnMainThread() { | |
55 PermissionBubbleBrowsertest::SetUpOnMainThread(); | |
56 | |
57 auto extension = | |
58 LoadExtension(test_data_dir_.AppendASCII("app_with_panel_container/")); | |
groby-ooo-7-16
2015/04/08 18:39:15
I take it leaking extensions is OK here?
hcarmona
2015/04/10 18:54:07
I think the extension is owned by ExtensionRegistr
| |
59 ASSERT_TRUE(extension); | |
60 | |
61 app_browser_ = OpenExtensionAppWindow(extension); | |
62 ASSERT_TRUE(app_browser()); | |
63 ASSERT_TRUE(app_browser()->is_app()); | |
64 } | |
65 | |
66 Browser* PermissionBubbleAppBrowsertest::OpenExtensionAppWindow( | |
67 const extensions::Extension* extension) { | |
68 base::CommandLine command_line(base::CommandLine::NO_PROGRAM); | |
69 command_line.AppendSwitchASCII(switches::kAppId, extension->id()); | |
70 | |
71 AppLaunchParams params(browser()->profile(), extension, | |
72 extensions::LAUNCH_CONTAINER_PANEL, NEW_WINDOW, | |
73 extensions::SOURCE_COMMAND_LINE); | |
74 params.command_line = command_line; | |
75 params.current_directory = base::FilePath(); | |
76 | |
77 content::WebContents* app_window = OpenApplication(params); | |
78 assert(app_window); | |
79 | |
80 return chrome::FindBrowserWithWebContents(app_window); | |
81 } | |
82 | |
83 // PermissionBubbleKioskBrowsertest //////////////////////////////////////////// | |
84 | |
85 PermissionBubbleKioskBrowsertest::PermissionBubbleKioskBrowsertest() | |
86 : PermissionBubbleBrowsertest() { | |
87 } | |
88 | |
89 PermissionBubbleKioskBrowsertest::~PermissionBubbleKioskBrowsertest() { | |
90 } | |
91 | |
92 void PermissionBubbleKioskBrowsertest::SetUpCommandLine( | |
93 base::CommandLine* command_line) { | |
94 PermissionBubbleBrowsertest::SetUpCommandLine(command_line); | |
95 command_line->AppendSwitch(switches::kKioskMode); | |
96 } | |
OLD | NEW |