OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/user_style_sheet_watcher.h" | 5 #include "chrome/browser/user_style_sheet_watcher.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 io_thread.message_loop()); | 37 io_thread.message_loop()); |
38 | 38 |
39 // It is important that the creation of |style_sheet_watcher| occur after the | 39 // It is important that the creation of |style_sheet_watcher| occur after the |
40 // creation of |browser_ui_thread| because UserStyleSheetWatchers are | 40 // creation of |browser_ui_thread| because UserStyleSheetWatchers are |
41 // restricted to being deleted only on UI browser threads. | 41 // restricted to being deleted only on UI browser threads. |
42 scoped_refptr<UserStyleSheetWatcher> style_sheet_watcher( | 42 scoped_refptr<UserStyleSheetWatcher> style_sheet_watcher( |
43 new UserStyleSheetWatcher(NULL, dir.path())); | 43 new UserStyleSheetWatcher(NULL, dir.path())); |
44 style_sheet_watcher->Init(); | 44 style_sheet_watcher->Init(); |
45 | 45 |
46 io_thread.Stop(); | 46 io_thread.Stop(); |
47 loop.RunAllPending(); | 47 loop.RunUntilIdle(); |
48 | 48 |
49 GURL result_url = style_sheet_watcher->user_style_sheet(); | 49 GURL result_url = style_sheet_watcher->user_style_sheet(); |
50 std::string result = result_url.spec(); | 50 std::string result = result_url.spec(); |
51 std::string prefix = "data:text/css;charset=utf-8;base64,"; | 51 std::string prefix = "data:text/css;charset=utf-8;base64,"; |
52 ASSERT_TRUE(StartsWithASCII(result, prefix, true)); | 52 ASSERT_TRUE(StartsWithASCII(result, prefix, true)); |
53 result = result.substr(prefix.length()); | 53 result = result.substr(prefix.length()); |
54 std::string decoded; | 54 std::string decoded; |
55 ASSERT_TRUE(base::Base64Decode(result, &decoded)); | 55 ASSERT_TRUE(base::Base64Decode(result, &decoded)); |
56 ASSERT_EQ(css_file_contents, decoded); | 56 ASSERT_EQ(css_file_contents, decoded); |
57 } | 57 } |
OLD | NEW |