| OLD | NEW |
| 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
| 7 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 7 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
| 8 #include "chrome/browser/extensions/extension_apitest.h" | 8 #include "chrome/browser/extensions/extension_apitest.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/login/login_prompt.h" | 13 #include "chrome/browser/ui/login/login_prompt.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/test/browser_test_utils.h" | 20 #include "content/public/test/browser_test_utils.h" |
| 21 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/common/features/feature.h" | 22 #include "extensions/common/features/feature.h" |
| 23 #include "extensions/test/result_catcher.h" |
| 23 #include "net/dns/mock_host_resolver.h" | 24 #include "net/dns/mock_host_resolver.h" |
| 24 #include "net/test/embedded_test_server/embedded_test_server.h" | 25 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 25 #include "third_party/WebKit/public/web/WebInputEvent.h" | 26 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 26 | 27 |
| 27 using content::WebContents; | 28 using content::WebContents; |
| 28 using extensions::Feature; | 29 using extensions::Feature; |
| 30 using extensions::ResultCatcher; |
| 29 | 31 |
| 30 namespace { | 32 namespace { |
| 31 | 33 |
| 32 class CancelLoginDialog : public content::NotificationObserver { | 34 class CancelLoginDialog : public content::NotificationObserver { |
| 33 public: | 35 public: |
| 34 CancelLoginDialog() { | 36 CancelLoginDialog() { |
| 35 registrar_.Add(this, | 37 registrar_.Add(this, |
| 36 chrome::NOTIFICATION_AUTH_NEEDED, | 38 chrome::NOTIFICATION_AUTH_NEEDED, |
| 37 content::NotificationService::AllSources()); | 39 content::NotificationService::AllSources()); |
| 38 } | 40 } |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 << message_; | 176 << message_; |
| 175 } | 177 } |
| 176 | 178 |
| 177 void ExtensionWebRequestApiTest::RunPermissionTest( | 179 void ExtensionWebRequestApiTest::RunPermissionTest( |
| 178 const char* extension_directory, | 180 const char* extension_directory, |
| 179 bool load_extension_with_incognito_permission, | 181 bool load_extension_with_incognito_permission, |
| 180 bool wait_for_extension_loaded_in_incognito, | 182 bool wait_for_extension_loaded_in_incognito, |
| 181 const char* expected_content_regular_window, | 183 const char* expected_content_regular_window, |
| 182 const char* exptected_content_incognito_window) { | 184 const char* exptected_content_incognito_window) { |
| 183 ResultCatcher catcher; | 185 ResultCatcher catcher; |
| 184 catcher.RestrictToProfile(browser()->profile()); | 186 catcher.RestrictToBrowserContext(browser()->profile()); |
| 185 ResultCatcher catcher_incognito; | 187 ResultCatcher catcher_incognito; |
| 186 catcher_incognito.RestrictToProfile( | 188 catcher_incognito.RestrictToBrowserContext( |
| 187 browser()->profile()->GetOffTheRecordProfile()); | 189 browser()->profile()->GetOffTheRecordProfile()); |
| 188 | 190 |
| 189 ExtensionTestMessageListener listener("done", true); | 191 ExtensionTestMessageListener listener("done", true); |
| 190 ExtensionTestMessageListener listener_incognito("done_incognito", true); | 192 ExtensionTestMessageListener listener_incognito("done_incognito", true); |
| 191 | 193 |
| 192 int load_extension_flags = kFlagNone; | 194 int load_extension_flags = kFlagNone; |
| 193 if (load_extension_with_incognito_permission) | 195 if (load_extension_with_incognito_permission) |
| 194 load_extension_flags |= kFlagEnableIncognito; | 196 load_extension_flags |= kFlagEnableIncognito; |
| 195 ASSERT_TRUE(LoadExtensionWithFlags( | 197 ASSERT_TRUE(LoadExtensionWithFlags( |
| 196 test_data_dir_.AppendASCII("webrequest_permissions") | 198 test_data_dir_.AppendASCII("webrequest_permissions") |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // Reload extension and wait for rules to be set up again. This should not | 315 // Reload extension and wait for rules to be set up again. This should not |
| 314 // crash the browser. | 316 // crash the browser. |
| 315 ExtensionTestMessageListener listener2("done", true); | 317 ExtensionTestMessageListener listener2("done", true); |
| 316 ExtensionTestMessageListener listener_incognito2("done_incognito", true); | 318 ExtensionTestMessageListener listener_incognito2("done_incognito", true); |
| 317 | 319 |
| 318 ReloadExtension(extension->id()); | 320 ReloadExtension(extension->id()); |
| 319 | 321 |
| 320 EXPECT_TRUE(listener2.WaitUntilSatisfied()); | 322 EXPECT_TRUE(listener2.WaitUntilSatisfied()); |
| 321 EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied()); | 323 EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied()); |
| 322 } | 324 } |
| OLD | NEW |