| 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 "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/extensions/api/identity/identity_api.h" | 10 #include "chrome/browser/extensions/api/identity/identity_api.h" |
| 11 #include "chrome/browser/extensions/component_loader.h" | 11 #include "chrome/browser/extensions/component_loader.h" |
| 12 #include "chrome/browser/extensions/extension_apitest.h" | 12 #include "chrome/browser/extensions/extension_apitest.h" |
| 13 #include "chrome/browser/extensions/extension_browsertest.h" | 13 #include "chrome/browser/extensions/extension_browsertest.h" |
| 14 #include "chrome/browser/extensions/extension_function_test_utils.h" | 14 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/guest_view/guest_view_base.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/signin/signin_manager_factory.h" | 18 #include "chrome/browser/signin/signin_manager_factory.h" |
| 18 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" | 22 #include "chrome/common/extensions/api/identity/oauth2_manifest_handler.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/test_switches.h" | 24 #include "chrome/test/base/test_switches.h" |
| 24 #include "components/signin/core/browser/signin_manager.h" | 25 #include "components/signin/core/browser/signin_manager.h" |
| 25 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 const content::NotificationDetails& details) OVERRIDE { | 225 const content::NotificationDetails& details) OVERRIDE { |
| 225 content::NavigationController* web_auth_flow_controller = | 226 content::NavigationController* web_auth_flow_controller = |
| 226 content::Source<content::NavigationController>(source).ptr(); | 227 content::Source<content::NavigationController>(source).ptr(); |
| 227 content::WebContents* web_contents = | 228 content::WebContents* web_contents = |
| 228 web_auth_flow_controller->GetWebContents(); | 229 web_auth_flow_controller->GetWebContents(); |
| 229 | 230 |
| 230 if (web_contents->GetURL() == url_) { | 231 if (web_contents->GetURL() == url_) { |
| 231 // It is safe to keep the pointer here, because we know in a test, that | 232 // It is safe to keep the pointer here, because we know in a test, that |
| 232 // the WebContents won't go away before CloseEmbedderWebContents is | 233 // the WebContents won't go away before CloseEmbedderWebContents is |
| 233 // called. Don't copy this code to production. | 234 // called. Don't copy this code to production. |
| 234 embedder_web_contents_ = web_contents->GetEmbedderWebContents(); | 235 GuestViewBase* guest = GuestViewBase::FromWebContents(web_contents); |
| 236 embedder_web_contents_ = guest->embedder_web_contents(); |
| 235 // Condtionally invoke parent class so that Wait will not exit | 237 // Condtionally invoke parent class so that Wait will not exit |
| 236 // until the target URL arrives. | 238 // until the target URL arrives. |
| 237 content::WindowedNotificationObserver::Observe(type, source, details); | 239 content::WindowedNotificationObserver::Observe(type, source, details); |
| 238 } | 240 } |
| 239 } | 241 } |
| 240 | 242 |
| 241 // Closes the window embedding the WebContents. The action is separated from | 243 // Closes the window embedding the WebContents. The action is separated from |
| 242 // the Observe method to make sure the list of observers is not deleted, | 244 // the Observe method to make sure the list of observers is not deleted, |
| 243 // while some event is already being processed. (That causes ASAN failures.) | 245 // while some event is already being processed. (That causes ASAN failures.) |
| 244 void CloseEmbedderWebContents() { | 246 void CloseEmbedderWebContents() { |
| (...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1328 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), | 1330 EXPECT_EQ(std::string("https://abcdefghij.chromiumapp.org/callback#test"), |
| 1329 url); | 1331 url); |
| 1330 } | 1332 } |
| 1331 | 1333 |
| 1332 } // namespace extensions | 1334 } // namespace extensions |
| 1333 | 1335 |
| 1334 // Tests the chrome.identity API implemented by custom JS bindings . | 1336 // Tests the chrome.identity API implemented by custom JS bindings . |
| 1335 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { | 1337 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, ChromeIdentityJsBindings) { |
| 1336 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; | 1338 ASSERT_TRUE(RunExtensionTest("identity/js_bindings")) << message_; |
| 1337 } | 1339 } |
| OLD | NEW |