| 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/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "chrome/browser/extensions/activity_log/activity_log.h" | 10 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 Action::ACTION_API_CALL, | 128 Action::ACTION_API_CALL, |
| 129 "tabs.testMethod"); | 129 "tabs.testMethod"); |
| 130 activity_log->LogAction(action); | 130 activity_log->LogAction(action); |
| 131 action = new Action(kExtensionId, | 131 action = new Action(kExtensionId, |
| 132 base::Time::Now(), | 132 base::Time::Now(), |
| 133 Action::ACTION_DOM_ACCESS, | 133 Action::ACTION_DOM_ACCESS, |
| 134 "document.write"); | 134 "document.write"); |
| 135 action->set_page_url(GURL("http://www.google.com")); | 135 action->set_page_url(GURL("http://www.google.com")); |
| 136 activity_log->LogAction(action); | 136 activity_log->LogAction(action); |
| 137 | 137 |
| 138 activity_log->GetActions( | 138 activity_log->GetFilteredActions( |
| 139 kExtensionId, | 139 kExtensionId, |
| 140 Action::ACTION_ANY, |
| 141 "", |
| 142 "", |
| 143 "", |
| 140 0, | 144 0, |
| 141 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); | 145 base::Bind(ActivityLogTest::RetrieveActions_LogAndFetchActions)); |
| 142 } | 146 } |
| 143 | 147 |
| 144 TEST_F(ActivityLogTest, LogPrerender) { | 148 TEST_F(ActivityLogTest, LogPrerender) { |
| 145 scoped_refptr<const Extension> extension = | 149 scoped_refptr<const Extension> extension = |
| 146 ExtensionBuilder() | 150 ExtensionBuilder() |
| 147 .SetManifest(DictionaryBuilder() | 151 .SetManifest(DictionaryBuilder() |
| 148 .Set("name", "Test extension") | 152 .Set("name", "Test extension") |
| 149 .Set("version", "1.0.0") | 153 .Set("version", "1.0.0") |
| (...skipping 20 matching lines...) Expand all Loading... |
| 170 ASSERT_EQ(1U, contentses.size()); | 174 ASSERT_EQ(1U, contentses.size()); |
| 171 content::WebContents *contents = contentses[0]; | 175 content::WebContents *contents = contentses[0]; |
| 172 ASSERT_TRUE(prerender_manager->IsWebContentsPrerendering(contents, NULL)); | 176 ASSERT_TRUE(prerender_manager->IsWebContentsPrerendering(contents, NULL)); |
| 173 | 177 |
| 174 TabHelper::ScriptExecutionObserver::ExecutingScriptsMap executing_scripts; | 178 TabHelper::ScriptExecutionObserver::ExecutingScriptsMap executing_scripts; |
| 175 executing_scripts[extension->id()].insert("script"); | 179 executing_scripts[extension->id()].insert("script"); |
| 176 | 180 |
| 177 static_cast<TabHelper::ScriptExecutionObserver*>(activity_log)-> | 181 static_cast<TabHelper::ScriptExecutionObserver*>(activity_log)-> |
| 178 OnScriptsExecuted(contents, executing_scripts, 0, url); | 182 OnScriptsExecuted(contents, executing_scripts, 0, url); |
| 179 | 183 |
| 180 activity_log->GetActions( | 184 activity_log->GetFilteredActions( |
| 181 extension->id(), 0, base::Bind(ActivityLogTest::Arguments_Prerender)); | 185 extension->id(), |
| 186 Action::ACTION_ANY, |
| 187 "", |
| 188 "", |
| 189 "", |
| 190 0, |
| 191 base::Bind(ActivityLogTest::Arguments_Prerender)); |
| 182 | 192 |
| 183 prerender_manager->CancelAllPrerenders(); | 193 prerender_manager->CancelAllPrerenders(); |
| 184 } | 194 } |
| 185 | 195 |
| 186 } // namespace extensions | 196 } // namespace extensions |
| OLD | NEW |