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/utf_string_conversions.h" | 5 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/automation/automation_util.h" | 6 #include "chrome/browser/automation/automation_util.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 public: | 28 public: |
29 // Returns whether the given tab's current URL has the given cookie. | 29 // Returns whether the given tab's current URL has the given cookie. |
30 bool WARN_UNUSED_RESULT HasCookie(WebContents* contents, std::string cookie) { | 30 bool WARN_UNUSED_RESULT HasCookie(WebContents* contents, std::string cookie) { |
31 int value_size; | 31 int value_size; |
32 std::string actual_cookie; | 32 std::string actual_cookie; |
33 automation_util::GetCookies(contents->GetURL(), contents, &value_size, | 33 automation_util::GetCookies(contents->GetURL(), contents, &value_size, |
34 &actual_cookie); | 34 &actual_cookie); |
35 return actual_cookie.find(cookie) != std::string::npos; | 35 return actual_cookie.find(cookie) != std::string::npos; |
36 } | 36 } |
37 | 37 |
38 const Extension* GetInstalledApp(WebContents* contents) { | 38 const extensions::Extension* GetInstalledApp(WebContents* contents) { |
39 const Extension* installed_app = NULL; | 39 const extensions::Extension* installed_app = NULL; |
40 Profile* profile = | 40 Profile* profile = |
41 Profile::FromBrowserContext(contents->GetBrowserContext()); | 41 Profile::FromBrowserContext(contents->GetBrowserContext()); |
42 ExtensionService* service = profile->GetExtensionService(); | 42 ExtensionService* service = profile->GetExtensionService(); |
43 if (service) { | 43 if (service) { |
44 installed_app = service->GetInstalledAppForRenderer( | 44 installed_app = service->GetInstalledAppForRenderer( |
45 contents->GetRenderProcessHost()->GetID()); | 45 contents->GetRenderProcessHost()->GetID()); |
46 } | 46 } |
47 return installed_app; | 47 return installed_app; |
48 } | 48 } |
49 | 49 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(0), "app2=4")); | 162 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(0), "app2=4")); |
163 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(0), "normalPage=5")); | 163 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(0), "normalPage=5")); |
164 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(0), "nonAppFrame=6")); | 164 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(0), "nonAppFrame=6")); |
165 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(1), "app1=3")); | 165 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(1), "app1=3")); |
166 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(1), "normalPage=5")); | 166 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(1), "normalPage=5")); |
167 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(1), "nonAppFrame=6")); | 167 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(1), "nonAppFrame=6")); |
168 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(2), "app1=3")); | 168 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(2), "app1=3")); |
169 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(2), "app2=4")); | 169 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(2), "app2=4")); |
170 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(2), "nonAppFrame=6")); | 170 EXPECT_TRUE(HasCookie(browser()->GetWebContentsAt(2), "nonAppFrame=6")); |
171 } | 171 } |
OLD | NEW |