| 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 "chrome/browser/extensions/user_script_master.h" | 5 #include "chrome/browser/extensions/user_script_master.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" |
| 11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 13 #include "base/scoped_temp_dir.h" | |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
| 16 #include "chrome/test/base/testing_profile.h" | 16 #include "chrome/test/base/testing_profile.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/test/test_browser_thread.h" | 19 #include "content/public/test/test_browser_thread.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| 23 | 23 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 const content::NotificationSource& source, | 67 const content::NotificationSource& source, |
| 68 const content::NotificationDetails& details) { | 68 const content::NotificationDetails& details) { |
| 69 DCHECK(type == chrome::NOTIFICATION_USER_SCRIPTS_UPDATED); | 69 DCHECK(type == chrome::NOTIFICATION_USER_SCRIPTS_UPDATED); |
| 70 | 70 |
| 71 shared_memory_ = content::Details<base::SharedMemory>(details).ptr(); | 71 shared_memory_ = content::Details<base::SharedMemory>(details).ptr(); |
| 72 if (MessageLoop::current() == &message_loop_) | 72 if (MessageLoop::current() == &message_loop_) |
| 73 MessageLoop::current()->Quit(); | 73 MessageLoop::current()->Quit(); |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Directory containing user scripts. | 76 // Directory containing user scripts. |
| 77 ScopedTempDir temp_dir_; | 77 base::ScopedTempDir temp_dir_; |
| 78 | 78 |
| 79 content::NotificationRegistrar registrar_; | 79 content::NotificationRegistrar registrar_; |
| 80 | 80 |
| 81 // MessageLoop used in tests. | 81 // MessageLoop used in tests. |
| 82 MessageLoop message_loop_; | 82 MessageLoop message_loop_; |
| 83 | 83 |
| 84 scoped_ptr<content::TestBrowserThread> file_thread_; | 84 scoped_ptr<content::TestBrowserThread> file_thread_; |
| 85 scoped_ptr<content::TestBrowserThread> ui_thread_; | 85 scoped_ptr<content::TestBrowserThread> ui_thread_; |
| 86 | 86 |
| 87 // Updated to the script shared memory when we get notified. | 87 // Updated to the script shared memory when we get notified. |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 UserScriptMaster::ScriptReloader* script_reloader = | 269 UserScriptMaster::ScriptReloader* script_reloader = |
| 270 new UserScriptMaster::ScriptReloader(NULL); | 270 new UserScriptMaster::ScriptReloader(NULL); |
| 271 script_reloader->AddRef(); | 271 script_reloader->AddRef(); |
| 272 script_reloader->LoadUserScripts(&user_scripts); | 272 script_reloader->LoadUserScripts(&user_scripts); |
| 273 script_reloader->Release(); | 273 script_reloader->Release(); |
| 274 | 274 |
| 275 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); | 275 EXPECT_EQ(content, user_scripts[0].js_scripts()[0].GetContent().as_string()); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace extensions | 278 } // namespace extensions |
| OLD | NEW |