OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #include "apps/launcher.h" | 5 #include "apps/launcher.h" |
6 #include "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 : RenderViewContextMenu(render_frame_host, params) {} | 73 : RenderViewContextMenu(render_frame_host, params) {} |
74 | 74 |
75 bool HasCommandWithId(int command_id) { | 75 bool HasCommandWithId(int command_id) { |
76 return menu_model_.GetIndexOfCommandId(command_id) != -1; | 76 return menu_model_.GetIndexOfCommandId(command_id) != -1; |
77 } | 77 } |
78 | 78 |
79 protected: | 79 protected: |
80 // RenderViewContextMenu implementation. | 80 // RenderViewContextMenu implementation. |
81 virtual bool GetAcceleratorForCommandId( | 81 virtual bool GetAcceleratorForCommandId( |
82 int command_id, | 82 int command_id, |
83 ui::Accelerator* accelerator) OVERRIDE { | 83 ui::Accelerator* accelerator) override { |
84 return false; | 84 return false; |
85 } | 85 } |
86 }; | 86 }; |
87 | 87 |
88 // This class keeps track of tabs as they are added to the browser. It will be | 88 // This class keeps track of tabs as they are added to the browser. It will be |
89 // "done" (i.e. won't block on Wait()) once |observations| tabs have been added. | 89 // "done" (i.e. won't block on Wait()) once |observations| tabs have been added. |
90 class TabsAddedNotificationObserver | 90 class TabsAddedNotificationObserver |
91 : public content::WindowedNotificationObserver { | 91 : public content::WindowedNotificationObserver { |
92 public: | 92 public: |
93 explicit TabsAddedNotificationObserver(size_t observations) | 93 explicit TabsAddedNotificationObserver(size_t observations) |
94 : content::WindowedNotificationObserver( | 94 : content::WindowedNotificationObserver( |
95 chrome::NOTIFICATION_TAB_ADDED, | 95 chrome::NOTIFICATION_TAB_ADDED, |
96 content::NotificationService::AllSources()), | 96 content::NotificationService::AllSources()), |
97 observations_(observations) { | 97 observations_(observations) { |
98 } | 98 } |
99 | 99 |
100 virtual void Observe(int type, | 100 virtual void Observe(int type, |
101 const content::NotificationSource& source, | 101 const content::NotificationSource& source, |
102 const content::NotificationDetails& details) OVERRIDE { | 102 const content::NotificationDetails& details) override { |
103 observed_tabs_.push_back( | 103 observed_tabs_.push_back( |
104 content::Details<WebContents>(details).ptr()); | 104 content::Details<WebContents>(details).ptr()); |
105 if (observed_tabs_.size() == observations_) | 105 if (observed_tabs_.size() == observations_) |
106 content::WindowedNotificationObserver::Observe(type, source, details); | 106 content::WindowedNotificationObserver::Observe(type, source, details); |
107 } | 107 } |
108 | 108 |
109 const std::vector<content::WebContents*>& tabs() { return observed_tabs_; } | 109 const std::vector<content::WebContents*>& tabs() { return observed_tabs_; } |
110 | 110 |
111 private: | 111 private: |
112 size_t observations_; | 112 size_t observations_; |
(...skipping 10 matching lines...) Expand all Loading... |
123 total_page_count_(1), | 123 total_page_count_(1), |
124 rendered_page_count_(0) { | 124 rendered_page_count_(0) { |
125 PrintPreviewUI::SetDelegateForTesting(this); | 125 PrintPreviewUI::SetDelegateForTesting(this); |
126 } | 126 } |
127 | 127 |
128 ~ScopedPreviewTestingDelegate() { | 128 ~ScopedPreviewTestingDelegate() { |
129 PrintPreviewUI::SetDelegateForTesting(NULL); | 129 PrintPreviewUI::SetDelegateForTesting(NULL); |
130 } | 130 } |
131 | 131 |
132 // PrintPreviewUI::TestingDelegate implementation. | 132 // PrintPreviewUI::TestingDelegate implementation. |
133 virtual bool IsAutoCancelEnabled() OVERRIDE { | 133 virtual bool IsAutoCancelEnabled() override { |
134 return auto_cancel_; | 134 return auto_cancel_; |
135 } | 135 } |
136 | 136 |
137 // PrintPreviewUI::TestingDelegate implementation. | 137 // PrintPreviewUI::TestingDelegate implementation. |
138 virtual void DidGetPreviewPageCount(int page_count) OVERRIDE { | 138 virtual void DidGetPreviewPageCount(int page_count) override { |
139 total_page_count_ = page_count; | 139 total_page_count_ = page_count; |
140 } | 140 } |
141 | 141 |
142 // PrintPreviewUI::TestingDelegate implementation. | 142 // PrintPreviewUI::TestingDelegate implementation. |
143 virtual void DidRenderPreviewPage(content::WebContents* preview_dialog) | 143 virtual void DidRenderPreviewPage(content::WebContents* preview_dialog) |
144 OVERRIDE { | 144 override { |
145 dialog_size_ = preview_dialog->GetContainerBounds().size(); | 145 dialog_size_ = preview_dialog->GetContainerBounds().size(); |
146 ++rendered_page_count_; | 146 ++rendered_page_count_; |
147 CHECK(rendered_page_count_ <= total_page_count_); | 147 CHECK(rendered_page_count_ <= total_page_count_); |
148 if (waiting_runner_.get() && rendered_page_count_ == total_page_count_) { | 148 if (waiting_runner_.get() && rendered_page_count_ == total_page_count_) { |
149 waiting_runner_->Quit(); | 149 waiting_runner_->Quit(); |
150 } | 150 } |
151 } | 151 } |
152 | 152 |
153 void WaitUntilPreviewIsReady() { | 153 void WaitUntilPreviewIsReady() { |
154 CHECK(!waiting_runner_.get()); | 154 CHECK(!waiting_runner_.get()); |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 content::NotificationService::AllSources()); | 944 content::NotificationService::AllSources()); |
945 } | 945 } |
946 | 946 |
947 bool seen() const { | 947 bool seen() const { |
948 return seen_; | 948 return seen_; |
949 }; | 949 }; |
950 | 950 |
951 // NotificationObserver: | 951 // NotificationObserver: |
952 virtual void Observe(int type, | 952 virtual void Observe(int type, |
953 const content::NotificationSource& source, | 953 const content::NotificationSource& source, |
954 const content::NotificationDetails& details) OVERRIDE { | 954 const content::NotificationDetails& details) override { |
955 EXPECT_FALSE(seen_); | 955 EXPECT_FALSE(seen_); |
956 seen_ = true; | 956 seen_ = true; |
957 } | 957 } |
958 | 958 |
959 private: | 959 private: |
960 bool seen_; | 960 bool seen_; |
961 content::NotificationRegistrar registrar_; | 961 content::NotificationRegistrar registrar_; |
962 }; | 962 }; |
963 | 963 |
964 } // namespace | 964 } // namespace |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 GetFirstAppWindow()->GetBaseWindow()->Close(); | 1172 GetFirstAppWindow()->GetBaseWindow()->Close(); |
1173 } | 1173 } |
1174 #endif // ENABLE_FULL_PRINTING | 1174 #endif // ENABLE_FULL_PRINTING |
1175 | 1175 |
1176 | 1176 |
1177 #if defined(OS_CHROMEOS) | 1177 #if defined(OS_CHROMEOS) |
1178 | 1178 |
1179 class PlatformAppIncognitoBrowserTest : public PlatformAppBrowserTest, | 1179 class PlatformAppIncognitoBrowserTest : public PlatformAppBrowserTest, |
1180 public AppWindowRegistry::Observer { | 1180 public AppWindowRegistry::Observer { |
1181 public: | 1181 public: |
1182 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 1182 virtual void SetUpCommandLine(CommandLine* command_line) override { |
1183 // Tell chromeos to launch in Guest mode, aka incognito. | 1183 // Tell chromeos to launch in Guest mode, aka incognito. |
1184 command_line->AppendSwitch(switches::kIncognito); | 1184 command_line->AppendSwitch(switches::kIncognito); |
1185 PlatformAppBrowserTest::SetUpCommandLine(command_line); | 1185 PlatformAppBrowserTest::SetUpCommandLine(command_line); |
1186 } | 1186 } |
1187 virtual void SetUp() OVERRIDE { | 1187 virtual void SetUp() override { |
1188 // Make sure the file manager actually gets loaded. | 1188 // Make sure the file manager actually gets loaded. |
1189 ComponentLoader::EnableBackgroundExtensionsForTesting(); | 1189 ComponentLoader::EnableBackgroundExtensionsForTesting(); |
1190 PlatformAppBrowserTest::SetUp(); | 1190 PlatformAppBrowserTest::SetUp(); |
1191 } | 1191 } |
1192 | 1192 |
1193 // AppWindowRegistry::Observer implementation. | 1193 // AppWindowRegistry::Observer implementation. |
1194 virtual void OnAppWindowAdded(AppWindow* app_window) OVERRIDE { | 1194 virtual void OnAppWindowAdded(AppWindow* app_window) override { |
1195 opener_app_ids_.insert(app_window->extension_id()); | 1195 opener_app_ids_.insert(app_window->extension_id()); |
1196 } | 1196 } |
1197 | 1197 |
1198 protected: | 1198 protected: |
1199 // A set of ids of apps we've seen open a app window. | 1199 // A set of ids of apps we've seen open a app window. |
1200 std::set<std::string> opener_app_ids_; | 1200 std::set<std::string> opener_app_ids_; |
1201 }; | 1201 }; |
1202 | 1202 |
1203 IN_PROC_BROWSER_TEST_F(PlatformAppIncognitoBrowserTest, IncognitoComponentApp) { | 1203 IN_PROC_BROWSER_TEST_F(PlatformAppIncognitoBrowserTest, IncognitoComponentApp) { |
1204 // Get the file manager app. | 1204 // Get the file manager app. |
(...skipping 26 matching lines...) Expand all Loading... |
1231 } | 1231 } |
1232 | 1232 |
1233 class RestartDeviceTest : public PlatformAppBrowserTest { | 1233 class RestartDeviceTest : public PlatformAppBrowserTest { |
1234 public: | 1234 public: |
1235 RestartDeviceTest() | 1235 RestartDeviceTest() |
1236 : power_manager_client_(NULL), | 1236 : power_manager_client_(NULL), |
1237 mock_user_manager_(NULL) {} | 1237 mock_user_manager_(NULL) {} |
1238 virtual ~RestartDeviceTest() {} | 1238 virtual ~RestartDeviceTest() {} |
1239 | 1239 |
1240 // PlatformAppBrowserTest overrides | 1240 // PlatformAppBrowserTest overrides |
1241 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 1241 virtual void SetUpInProcessBrowserTestFixture() override { |
1242 PlatformAppBrowserTest::SetUpInProcessBrowserTestFixture(); | 1242 PlatformAppBrowserTest::SetUpInProcessBrowserTestFixture(); |
1243 | 1243 |
1244 power_manager_client_ = new chromeos::FakePowerManagerClient; | 1244 power_manager_client_ = new chromeos::FakePowerManagerClient; |
1245 chromeos::DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient( | 1245 chromeos::DBusThreadManager::GetSetterForTesting()->SetPowerManagerClient( |
1246 scoped_ptr<chromeos::PowerManagerClient>(power_manager_client_)); | 1246 scoped_ptr<chromeos::PowerManagerClient>(power_manager_client_)); |
1247 } | 1247 } |
1248 | 1248 |
1249 virtual void SetUpOnMainThread() OVERRIDE { | 1249 virtual void SetUpOnMainThread() override { |
1250 PlatformAppBrowserTest::SetUpOnMainThread(); | 1250 PlatformAppBrowserTest::SetUpOnMainThread(); |
1251 | 1251 |
1252 mock_user_manager_ = new chromeos::MockUserManager; | 1252 mock_user_manager_ = new chromeos::MockUserManager; |
1253 user_manager_enabler_.reset( | 1253 user_manager_enabler_.reset( |
1254 new chromeos::ScopedUserManagerEnabler(mock_user_manager_)); | 1254 new chromeos::ScopedUserManagerEnabler(mock_user_manager_)); |
1255 | 1255 |
1256 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) | 1256 EXPECT_CALL(*mock_user_manager_, IsUserLoggedIn()) |
1257 .WillRepeatedly(testing::Return(true)); | 1257 .WillRepeatedly(testing::Return(true)); |
1258 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsKioskApp()) | 1258 EXPECT_CALL(*mock_user_manager_, IsLoggedInAsKioskApp()) |
1259 .WillRepeatedly(testing::Return(true)); | 1259 .WillRepeatedly(testing::Return(true)); |
1260 } | 1260 } |
1261 | 1261 |
1262 virtual void TearDownOnMainThread() OVERRIDE { | 1262 virtual void TearDownOnMainThread() override { |
1263 user_manager_enabler_.reset(); | 1263 user_manager_enabler_.reset(); |
1264 PlatformAppBrowserTest::TearDownOnMainThread(); | 1264 PlatformAppBrowserTest::TearDownOnMainThread(); |
1265 } | 1265 } |
1266 | 1266 |
1267 virtual void TearDownInProcessBrowserTestFixture() OVERRIDE { | 1267 virtual void TearDownInProcessBrowserTestFixture() override { |
1268 PlatformAppBrowserTest::TearDownInProcessBrowserTestFixture(); | 1268 PlatformAppBrowserTest::TearDownInProcessBrowserTestFixture(); |
1269 } | 1269 } |
1270 | 1270 |
1271 int num_request_restart_calls() const { | 1271 int num_request_restart_calls() const { |
1272 return power_manager_client_->num_request_restart_calls(); | 1272 return power_manager_client_->num_request_restart_calls(); |
1273 } | 1273 } |
1274 | 1274 |
1275 private: | 1275 private: |
1276 chromeos::FakePowerManagerClient* power_manager_client_; | 1276 chromeos::FakePowerManagerClient* power_manager_client_; |
1277 chromeos::MockUserManager* mock_user_manager_; | 1277 chromeos::MockUserManager* mock_user_manager_; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1327 LoadAndLaunchPlatformApp("reinstall_data_cleanup", "Launched"); | 1327 LoadAndLaunchPlatformApp("reinstall_data_cleanup", "Launched"); |
1328 ASSERT_TRUE(extension); | 1328 ASSERT_TRUE(extension); |
1329 ASSERT_EQ(extension_id, extension->id()); | 1329 ASSERT_EQ(extension_id, extension->id()); |
1330 | 1330 |
1331 ResultCatcher result_catcher; | 1331 ResultCatcher result_catcher; |
1332 EXPECT_TRUE(result_catcher.GetNextResult()); | 1332 EXPECT_TRUE(result_catcher.GetNextResult()); |
1333 } | 1333 } |
1334 } | 1334 } |
1335 | 1335 |
1336 } // namespace extensions | 1336 } // namespace extensions |
OLD | NEW |