| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 5 |
| 6 #include "base/basictypes.h" | 6 #include "base/basictypes.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/background_contents_service.h" | 10 #include "chrome/browser/background_contents_service.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 DictionaryValue* GetPrefs(Profile* profile) { | 31 DictionaryValue* GetPrefs(Profile* profile) { |
| 32 return profile->GetPrefs()->GetMutableDictionary( | 32 return profile->GetPrefs()->GetMutableDictionary( |
| 33 prefs::kRegisteredBackgroundContents); | 33 prefs::kRegisteredBackgroundContents); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // Returns the stored pref URL for the passed app id. | 36 // Returns the stored pref URL for the passed app id. |
| 37 std::string GetPrefURLForApp(Profile* profile, const string16& appid) { | 37 std::string GetPrefURLForApp(Profile* profile, const string16& appid) { |
| 38 DictionaryValue* pref = GetPrefs(profile); | 38 DictionaryValue* pref = GetPrefs(profile); |
| 39 EXPECT_TRUE(pref->HasKey(UTF16ToWide(appid))); | 39 EXPECT_TRUE(pref->HasKey(UTF16ToWide(appid))); |
| 40 DictionaryValue* value; | 40 DictionaryValue* value; |
| 41 pref->GetDictionaryWithoutPathExpansion(UTF16ToWide(appid), &value); | 41 pref->GetDictionaryWithoutPathExpansion(UTF16ToUTF8(appid), &value); |
| 42 std::string url; | 42 std::string url; |
| 43 value->GetString(L"url", &url); | 43 value->GetString("url", &url); |
| 44 return url; | 44 return url; |
| 45 } | 45 } |
| 46 | 46 |
| 47 scoped_ptr<CommandLine> command_line_; | 47 scoped_ptr<CommandLine> command_line_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class MockBackgroundContents : public BackgroundContents { | 50 class MockBackgroundContents : public BackgroundContents { |
| 51 public: | 51 public: |
| 52 explicit MockBackgroundContents(Profile* profile) | 52 explicit MockBackgroundContents(Profile* profile) |
| 53 : appid_(ASCIIToUTF16("app_id")), | 53 : appid_(ASCIIToUTF16("app_id")), |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 contents->Navigate(url); | 224 contents->Navigate(url); |
| 225 EXPECT_EQ(1U, GetPrefs(&profile)->size()); | 225 EXPECT_EQ(1U, GetPrefs(&profile)->size()); |
| 226 contents2->Navigate(url2); | 226 contents2->Navigate(url2); |
| 227 EXPECT_EQ(2U, GetPrefs(&profile)->size()); | 227 EXPECT_EQ(2U, GetPrefs(&profile)->size()); |
| 228 service.ShutdownAssociatedBackgroundContents(ASCIIToUTF16("appid")); | 228 service.ShutdownAssociatedBackgroundContents(ASCIIToUTF16("appid")); |
| 229 EXPECT_FALSE(service.IsTracked(contents)); | 229 EXPECT_FALSE(service.IsTracked(contents)); |
| 230 EXPECT_EQ(NULL, service.GetAppBackgroundContents(ASCIIToUTF16("appid"))); | 230 EXPECT_EQ(NULL, service.GetAppBackgroundContents(ASCIIToUTF16("appid"))); |
| 231 EXPECT_EQ(1U, GetPrefs(&profile)->size()); | 231 EXPECT_EQ(1U, GetPrefs(&profile)->size()); |
| 232 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); | 232 EXPECT_EQ(url2.spec(), GetPrefURLForApp(&profile, contents2->appid())); |
| 233 } | 233 } |
| OLD | NEW |