| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/activity_log/fullstream_ui_policy.h" | 5 #include "chrome/browser/extensions/activity_log/fullstream_ui_policy.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 |
| 9 #include <memory> |
| 8 #include <utility> | 10 #include <utility> |
| 9 | 11 |
| 10 #include "base/cancelable_callback.h" | 12 #include "base/cancelable_callback.h" |
| 11 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 12 #include "base/location.h" | 14 #include "base/location.h" |
| 13 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/ptr_util.h" |
| 14 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 15 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 16 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 17 #include "base/synchronization/waitable_event.h" | 19 #include "base/synchronization/waitable_event.h" |
| 18 #include "base/test/simple_test_clock.h" | 20 #include "base/test/simple_test_clock.h" |
| 19 #include "base/test/test_timeouts.h" | 21 #include "base/test/test_timeouts.h" |
| 20 #include "base/thread_task_runner_handle.h" | 22 #include "base/thread_task_runner_handle.h" |
| 21 #include "build/build_config.h" | 23 #include "build/build_config.h" |
| 22 #include "chrome/browser/extensions/activity_log/activity_log.h" | 24 #include "chrome/browser/extensions/activity_log/activity_log.h" |
| 23 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 #endif | 68 #endif |
| 67 base::RunLoop().RunUntilIdle(); | 69 base::RunLoop().RunUntilIdle(); |
| 68 profile_.reset(NULL); | 70 profile_.reset(NULL); |
| 69 base::RunLoop().RunUntilIdle(); | 71 base::RunLoop().RunUntilIdle(); |
| 70 // Restore the original command line and undo the affects of SetUp(). | 72 // Restore the original command line and undo the affects of SetUp(). |
| 71 *base::CommandLine::ForCurrentProcess() = saved_cmdline_; | 73 *base::CommandLine::ForCurrentProcess() = saved_cmdline_; |
| 72 } | 74 } |
| 73 | 75 |
| 74 // A wrapper function for CheckReadFilteredData, so that we don't need to | 76 // A wrapper function for CheckReadFilteredData, so that we don't need to |
| 75 // enter empty string values for parameters we don't care about. | 77 // enter empty string values for parameters we don't care about. |
| 76 void CheckReadData( | 78 void CheckReadData(ActivityLogDatabasePolicy* policy, |
| 77 ActivityLogDatabasePolicy* policy, | 79 const std::string& extension_id, |
| 78 const std::string& extension_id, | 80 int day, |
| 79 int day, | 81 const base::Callback<void( |
| 80 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { | 82 std::unique_ptr<Action::ActionVector>)>& checker) { |
| 81 CheckReadFilteredData( | 83 CheckReadFilteredData( |
| 82 policy, extension_id, Action::ACTION_ANY, "", "", "", day, checker); | 84 policy, extension_id, Action::ACTION_ANY, "", "", "", day, checker); |
| 83 } | 85 } |
| 84 | 86 |
| 85 // A helper function to call ReadFilteredData on a policy object and wait for | 87 // A helper function to call ReadFilteredData on a policy object and wait for |
| 86 // the results to be processed. | 88 // the results to be processed. |
| 87 void CheckReadFilteredData( | 89 void CheckReadFilteredData( |
| 88 ActivityLogDatabasePolicy* policy, | 90 ActivityLogDatabasePolicy* policy, |
| 89 const std::string& extension_id, | 91 const std::string& extension_id, |
| 90 const Action::ActionType type, | 92 const Action::ActionType type, |
| 91 const std::string& api_name, | 93 const std::string& api_name, |
| 92 const std::string& page_url, | 94 const std::string& page_url, |
| 93 const std::string& arg_url, | 95 const std::string& arg_url, |
| 94 const int days_ago, | 96 const int days_ago, |
| 95 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { | 97 const base::Callback<void(std::unique_ptr<Action::ActionVector>)>& |
| 98 checker) { |
| 96 // Submit a request to the policy to read back some data, and call the | 99 // Submit a request to the policy to read back some data, and call the |
| 97 // checker function when results are available. This will happen on the | 100 // checker function when results are available. This will happen on the |
| 98 // database thread. | 101 // database thread. |
| 99 policy->ReadFilteredData( | 102 policy->ReadFilteredData( |
| 100 extension_id, type, api_name, page_url, arg_url, days_ago, | 103 extension_id, type, api_name, page_url, arg_url, days_ago, |
| 101 base::Bind(&FullStreamUIPolicyTest::CheckWrapper, checker, | 104 base::Bind(&FullStreamUIPolicyTest::CheckWrapper, checker, |
| 102 base::MessageLoop::current()->QuitWhenIdleClosure())); | 105 base::MessageLoop::current()->QuitWhenIdleClosure())); |
| 103 | 106 |
| 104 // Set up a timeout for receiving results; if we haven't received anything | 107 // Set up a timeout for receiving results; if we haven't received anything |
| 105 // when the timeout triggers then assume that the test is broken. | 108 // when the timeout triggers then assume that the test is broken. |
| 106 base::CancelableClosure timeout( | 109 base::CancelableClosure timeout( |
| 107 base::Bind(&FullStreamUIPolicyTest::TimeoutCallback)); | 110 base::Bind(&FullStreamUIPolicyTest::TimeoutCallback)); |
| 108 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 111 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 109 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); | 112 FROM_HERE, timeout.callback(), TestTimeouts::action_timeout()); |
| 110 | 113 |
| 111 // Wait for results; either the checker or the timeout callbacks should | 114 // Wait for results; either the checker or the timeout callbacks should |
| 112 // cause the main loop to exit. | 115 // cause the main loop to exit. |
| 113 base::MessageLoop::current()->Run(); | 116 base::MessageLoop::current()->Run(); |
| 114 | 117 |
| 115 timeout.Cancel(); | 118 timeout.Cancel(); |
| 116 } | 119 } |
| 117 | 120 |
| 118 static void CheckWrapper( | 121 static void CheckWrapper(const base::Callback<void( |
| 119 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker, | 122 std::unique_ptr<Action::ActionVector>)>& checker, |
| 120 const base::Closure& done, | 123 const base::Closure& done, |
| 121 scoped_ptr<Action::ActionVector> results) { | 124 std::unique_ptr<Action::ActionVector> results) { |
| 122 checker.Run(std::move(results)); | 125 checker.Run(std::move(results)); |
| 123 done.Run(); | 126 done.Run(); |
| 124 } | 127 } |
| 125 | 128 |
| 126 static void TimeoutCallback() { | 129 static void TimeoutCallback() { |
| 127 base::MessageLoop::current()->QuitWhenIdle(); | 130 base::MessageLoop::current()->QuitWhenIdle(); |
| 128 FAIL() << "Policy test timed out waiting for results"; | 131 FAIL() << "Policy test timed out waiting for results"; |
| 129 } | 132 } |
| 130 | 133 |
| 131 static void RetrieveActions_LogAndFetchActions( | 134 static void RetrieveActions_LogAndFetchActions( |
| 132 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 135 std::unique_ptr<std::vector<scoped_refptr<Action>>> i) { |
| 133 ASSERT_EQ(2, static_cast<int>(i->size())); | 136 ASSERT_EQ(2, static_cast<int>(i->size())); |
| 134 } | 137 } |
| 135 | 138 |
| 136 static void RetrieveActions_FetchFilteredActions0( | 139 static void RetrieveActions_FetchFilteredActions0( |
| 137 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 140 std::unique_ptr<std::vector<scoped_refptr<Action>>> i) { |
| 138 ASSERT_EQ(0, static_cast<int>(i->size())); | 141 ASSERT_EQ(0, static_cast<int>(i->size())); |
| 139 } | 142 } |
| 140 | 143 |
| 141 static void RetrieveActions_FetchFilteredActions1( | 144 static void RetrieveActions_FetchFilteredActions1( |
| 142 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 145 std::unique_ptr<std::vector<scoped_refptr<Action>>> i) { |
| 143 ASSERT_EQ(1, static_cast<int>(i->size())); | 146 ASSERT_EQ(1, static_cast<int>(i->size())); |
| 144 } | 147 } |
| 145 | 148 |
| 146 static void RetrieveActions_FetchFilteredActions2( | 149 static void RetrieveActions_FetchFilteredActions2( |
| 147 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 150 std::unique_ptr<std::vector<scoped_refptr<Action>>> i) { |
| 148 ASSERT_EQ(2, static_cast<int>(i->size())); | 151 ASSERT_EQ(2, static_cast<int>(i->size())); |
| 149 } | 152 } |
| 150 | 153 |
| 151 static void RetrieveActions_FetchFilteredActions300( | 154 static void RetrieveActions_FetchFilteredActions300( |
| 152 scoped_ptr<std::vector<scoped_refptr<Action> > > i) { | 155 std::unique_ptr<std::vector<scoped_refptr<Action>>> i) { |
| 153 ASSERT_EQ(300, static_cast<int>(i->size())); | 156 ASSERT_EQ(300, static_cast<int>(i->size())); |
| 154 } | 157 } |
| 155 | 158 |
| 156 static void Arguments_Present(scoped_ptr<Action::ActionVector> i) { | 159 static void Arguments_Present(std::unique_ptr<Action::ActionVector> i) { |
| 157 scoped_refptr<Action> last = i->front(); | 160 scoped_refptr<Action> last = i->front(); |
| 158 CheckAction(*last.get(), | 161 CheckAction(*last.get(), |
| 159 "odlameecjipmbmbejkplpemijjgpljce", | 162 "odlameecjipmbmbejkplpemijjgpljce", |
| 160 Action::ACTION_API_CALL, | 163 Action::ACTION_API_CALL, |
| 161 "extension.connect", | 164 "extension.connect", |
| 162 "[\"hello\",\"world\"]", | 165 "[\"hello\",\"world\"]", |
| 163 "", | 166 "", |
| 164 "", | 167 "", |
| 165 ""); | 168 ""); |
| 166 } | 169 } |
| 167 | 170 |
| 168 static void Arguments_GetTodaysActions( | 171 static void Arguments_GetTodaysActions( |
| 169 scoped_ptr<Action::ActionVector> actions) { | 172 std::unique_ptr<Action::ActionVector> actions) { |
| 170 ASSERT_EQ(2, static_cast<int>(actions->size())); | 173 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 171 CheckAction(*actions->at(0).get(), | 174 CheckAction(*actions->at(0).get(), |
| 172 "punky", | 175 "punky", |
| 173 Action::ACTION_DOM_ACCESS, | 176 Action::ACTION_DOM_ACCESS, |
| 174 "lets", | 177 "lets", |
| 175 "[\"vamoose\"]", | 178 "[\"vamoose\"]", |
| 176 "http://www.google.com/", | 179 "http://www.google.com/", |
| 177 "Page Title", | 180 "Page Title", |
| 178 "http://www.arg-url.com/"); | 181 "http://www.arg-url.com/"); |
| 179 CheckAction(*actions->at(1).get(), | 182 CheckAction(*actions->at(1).get(), |
| 180 "punky", | 183 "punky", |
| 181 Action::ACTION_API_CALL, | 184 Action::ACTION_API_CALL, |
| 182 "brewster", | 185 "brewster", |
| 183 "[\"woof\"]", | 186 "[\"woof\"]", |
| 184 "", | 187 "", |
| 185 "Page Title", | 188 "Page Title", |
| 186 "http://www.arg-url.com/"); | 189 "http://www.arg-url.com/"); |
| 187 } | 190 } |
| 188 | 191 |
| 189 static void Arguments_GetOlderActions( | 192 static void Arguments_GetOlderActions( |
| 190 scoped_ptr<Action::ActionVector> actions) { | 193 std::unique_ptr<Action::ActionVector> actions) { |
| 191 ASSERT_EQ(2, static_cast<int>(actions->size())); | 194 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 192 CheckAction(*actions->at(0).get(), | 195 CheckAction(*actions->at(0).get(), |
| 193 "punky", | 196 "punky", |
| 194 Action::ACTION_DOM_ACCESS, | 197 Action::ACTION_DOM_ACCESS, |
| 195 "lets", | 198 "lets", |
| 196 "[\"vamoose\"]", | 199 "[\"vamoose\"]", |
| 197 "http://www.google.com/", | 200 "http://www.google.com/", |
| 198 "", | 201 "", |
| 199 ""); | 202 ""); |
| 200 CheckAction(*actions->at(1).get(), | 203 CheckAction(*actions->at(1).get(), |
| 201 "punky", | 204 "punky", |
| 202 Action::ACTION_API_CALL, | 205 Action::ACTION_API_CALL, |
| 203 "brewster", | 206 "brewster", |
| 204 "[\"woof\"]", | 207 "[\"woof\"]", |
| 205 "", | 208 "", |
| 206 "", | 209 "", |
| 207 ""); | 210 ""); |
| 208 } | 211 } |
| 209 | 212 |
| 210 static void AllURLsRemoved(scoped_ptr<Action::ActionVector> actions) { | 213 static void AllURLsRemoved(std::unique_ptr<Action::ActionVector> actions) { |
| 211 ASSERT_EQ(2, static_cast<int>(actions->size())); | 214 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 212 CheckAction(*actions->at(0).get(), | 215 CheckAction(*actions->at(0).get(), |
| 213 "punky", | 216 "punky", |
| 214 Action::ACTION_API_CALL, | 217 Action::ACTION_API_CALL, |
| 215 "lets", | 218 "lets", |
| 216 "[\"vamoose\"]", | 219 "[\"vamoose\"]", |
| 217 "", | 220 "", |
| 218 "", | 221 "", |
| 219 ""); | 222 ""); |
| 220 CheckAction(*actions->at(1).get(), | 223 CheckAction(*actions->at(1).get(), |
| 221 "punky", | 224 "punky", |
| 222 Action::ACTION_DOM_ACCESS, | 225 Action::ACTION_DOM_ACCESS, |
| 223 "lets", | 226 "lets", |
| 224 "[\"vamoose\"]", | 227 "[\"vamoose\"]", |
| 225 "", | 228 "", |
| 226 "", | 229 "", |
| 227 ""); | 230 ""); |
| 228 } | 231 } |
| 229 | 232 |
| 230 static void SomeURLsRemoved(scoped_ptr<Action::ActionVector> actions) { | 233 static void SomeURLsRemoved(std::unique_ptr<Action::ActionVector> actions) { |
| 231 // These will be in the vector in reverse time order. | 234 // These will be in the vector in reverse time order. |
| 232 ASSERT_EQ(5, static_cast<int>(actions->size())); | 235 ASSERT_EQ(5, static_cast<int>(actions->size())); |
| 233 CheckAction(*actions->at(0).get(), | 236 CheckAction(*actions->at(0).get(), |
| 234 "punky", | 237 "punky", |
| 235 Action::ACTION_DOM_ACCESS, | 238 Action::ACTION_DOM_ACCESS, |
| 236 "lets", | 239 "lets", |
| 237 "[\"vamoose\"]", | 240 "[\"vamoose\"]", |
| 238 "http://www.google.com/", | 241 "http://www.google.com/", |
| 239 "Google", | 242 "Google", |
| 240 "http://www.args-url.com/"); | 243 "http://www.args-url.com/"); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 ASSERT_EQ(expected_arg_url, action.SerializeArgUrl()); | 293 ASSERT_EQ(expected_arg_url, action.SerializeArgUrl()); |
| 291 ASSERT_NE(-1, action.action_id()); | 294 ASSERT_NE(-1, action.action_id()); |
| 292 } | 295 } |
| 293 | 296 |
| 294 // A helper function initializes the policy with a number of actions, calls | 297 // A helper function initializes the policy with a number of actions, calls |
| 295 // RemoveActions on a policy object and then checks the result of the | 298 // RemoveActions on a policy object and then checks the result of the |
| 296 // deletion. | 299 // deletion. |
| 297 void CheckRemoveActions( | 300 void CheckRemoveActions( |
| 298 ActivityLogDatabasePolicy* policy, | 301 ActivityLogDatabasePolicy* policy, |
| 299 const std::vector<int64_t>& action_ids, | 302 const std::vector<int64_t>& action_ids, |
| 300 const base::Callback<void(scoped_ptr<Action::ActionVector>)>& checker) { | 303 const base::Callback<void(std::unique_ptr<Action::ActionVector>)>& |
| 304 checker) { |
| 301 // Use a mock clock to ensure that events are not recorded on the wrong day | 305 // Use a mock clock to ensure that events are not recorded on the wrong day |
| 302 // when the test is run close to local midnight. | 306 // when the test is run close to local midnight. |
| 303 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); | 307 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); |
| 304 mock_clock->SetNow(base::Time::Now().LocalMidnight() + | 308 mock_clock->SetNow(base::Time::Now().LocalMidnight() + |
| 305 base::TimeDelta::FromHours(12)); | 309 base::TimeDelta::FromHours(12)); |
| 306 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock)); | 310 policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock)); |
| 307 | 311 |
| 308 // Record some actions | 312 // Record some actions |
| 309 scoped_refptr<Action> action = | 313 scoped_refptr<Action> action = |
| 310 new Action("punky1", | 314 new Action("punky1", |
| 311 mock_clock->Now() - base::TimeDelta::FromMinutes(40), | 315 mock_clock->Now() - base::TimeDelta::FromMinutes(40), |
| 312 Action::ACTION_DOM_ACCESS, | 316 Action::ACTION_DOM_ACCESS, |
| 313 "lets1"); | 317 "lets1"); |
| 314 action->mutable_args()->AppendString("vamoose1"); | 318 action->mutable_args()->AppendString("vamoose1"); |
| 315 action->set_page_url(GURL("http://www.google1.com")); | 319 action->set_page_url(GURL("http://www.google1.com")); |
| 316 action->set_page_title("Google1"); | 320 action->set_page_title("Google1"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 337 policy->RemoveActions(action_ids); | 341 policy->RemoveActions(action_ids); |
| 338 | 342 |
| 339 // Check the result of the deletion. The checker function gets all | 343 // Check the result of the deletion. The checker function gets all |
| 340 // activities in the database. | 344 // activities in the database. |
| 341 CheckReadData(policy, "", -1, checker); | 345 CheckReadData(policy, "", -1, checker); |
| 342 | 346 |
| 343 // Clean database. | 347 // Clean database. |
| 344 policy->DeleteDatabase(); | 348 policy->DeleteDatabase(); |
| 345 } | 349 } |
| 346 | 350 |
| 347 static void AllActionsDeleted(scoped_ptr<Action::ActionVector> actions) { | 351 static void AllActionsDeleted(std::unique_ptr<Action::ActionVector> actions) { |
| 348 ASSERT_EQ(0, static_cast<int>(actions->size())); | 352 ASSERT_EQ(0, static_cast<int>(actions->size())); |
| 349 } | 353 } |
| 350 | 354 |
| 351 static void NoActionsDeleted(scoped_ptr<Action::ActionVector> actions) { | 355 static void NoActionsDeleted(std::unique_ptr<Action::ActionVector> actions) { |
| 352 // These will be in the vector in reverse time order. | 356 // These will be in the vector in reverse time order. |
| 353 ASSERT_EQ(4, static_cast<int>(actions->size())); | 357 ASSERT_EQ(4, static_cast<int>(actions->size())); |
| 354 CheckAction(*actions->at(0).get(), | 358 CheckAction(*actions->at(0).get(), |
| 355 "punky2", | 359 "punky2", |
| 356 Action::ACTION_API_CALL, | 360 Action::ACTION_API_CALL, |
| 357 "lets2", | 361 "lets2", |
| 358 "[\"vamoose2\"]", | 362 "[\"vamoose2\"]", |
| 359 "http://www.google2.com/", | 363 "http://www.google2.com/", |
| 360 "Google2", | 364 "Google2", |
| 361 "http://www.args-url2.com/"); | 365 "http://www.args-url2.com/"); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 382 "punky1", | 386 "punky1", |
| 383 Action::ACTION_DOM_ACCESS, | 387 Action::ACTION_DOM_ACCESS, |
| 384 "lets1", | 388 "lets1", |
| 385 "[\"vamoose1\"]", | 389 "[\"vamoose1\"]", |
| 386 "http://www.google1.com/", | 390 "http://www.google1.com/", |
| 387 "Google1", | 391 "Google1", |
| 388 "http://www.args-url1.com/"); | 392 "http://www.args-url1.com/"); |
| 389 ASSERT_EQ(2, actions->at(3)->action_id()); | 393 ASSERT_EQ(2, actions->at(3)->action_id()); |
| 390 } | 394 } |
| 391 | 395 |
| 392 static void Action1Deleted(scoped_ptr<Action::ActionVector> actions) { | 396 static void Action1Deleted(std::unique_ptr<Action::ActionVector> actions) { |
| 393 // These will be in the vector in reverse time order. | 397 // These will be in the vector in reverse time order. |
| 394 ASSERT_EQ(2, static_cast<int>(actions->size())); | 398 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 395 CheckAction(*actions->at(0).get(), | 399 CheckAction(*actions->at(0).get(), |
| 396 "punky2", | 400 "punky2", |
| 397 Action::ACTION_API_CALL, | 401 Action::ACTION_API_CALL, |
| 398 "lets2", | 402 "lets2", |
| 399 "[\"vamoose2\"]", | 403 "[\"vamoose2\"]", |
| 400 "http://www.google2.com/", | 404 "http://www.google2.com/", |
| 401 "Google2", | 405 "Google2", |
| 402 "http://www.args-url2.com/"); | 406 "http://www.args-url2.com/"); |
| 403 ASSERT_EQ(3, actions->at(0)->action_id()); | 407 ASSERT_EQ(3, actions->at(0)->action_id()); |
| 404 CheckAction(*actions->at(1).get(), | 408 CheckAction(*actions->at(1).get(), |
| 405 "punky2", | 409 "punky2", |
| 406 Action::ACTION_API_CALL, | 410 Action::ACTION_API_CALL, |
| 407 "lets2", | 411 "lets2", |
| 408 "[\"vamoose2\"]", | 412 "[\"vamoose2\"]", |
| 409 "http://www.google2.com/", | 413 "http://www.google2.com/", |
| 410 "Google2", | 414 "Google2", |
| 411 "http://www.args-url2.com/"); | 415 "http://www.args-url2.com/"); |
| 412 ASSERT_EQ(4, actions->at(1)->action_id()); | 416 ASSERT_EQ(4, actions->at(1)->action_id()); |
| 413 } | 417 } |
| 414 | 418 |
| 415 static void Action2Deleted(scoped_ptr<Action::ActionVector> actions) { | 419 static void Action2Deleted(std::unique_ptr<Action::ActionVector> actions) { |
| 416 // These will be in the vector in reverse time order. | 420 // These will be in the vector in reverse time order. |
| 417 ASSERT_EQ(2, static_cast<int>(actions->size())); | 421 ASSERT_EQ(2, static_cast<int>(actions->size())); |
| 418 CheckAction(*actions->at(0).get(), | 422 CheckAction(*actions->at(0).get(), |
| 419 "punky1", | 423 "punky1", |
| 420 Action::ACTION_DOM_ACCESS, | 424 Action::ACTION_DOM_ACCESS, |
| 421 "lets1", | 425 "lets1", |
| 422 "[\"vamoose1\"]", | 426 "[\"vamoose1\"]", |
| 423 "http://www.google1.com/", | 427 "http://www.google1.com/", |
| 424 "Google1", | 428 "Google1", |
| 425 "http://www.args-url1.com/"); | 429 "http://www.args-url1.com/"); |
| 426 ASSERT_EQ(1, actions->at(0)->action_id()); | 430 ASSERT_EQ(1, actions->at(0)->action_id()); |
| 427 CheckAction(*actions->at(1).get(), | 431 CheckAction(*actions->at(1).get(), |
| 428 "punky1", | 432 "punky1", |
| 429 Action::ACTION_DOM_ACCESS, | 433 Action::ACTION_DOM_ACCESS, |
| 430 "lets1", | 434 "lets1", |
| 431 "[\"vamoose1\"]", | 435 "[\"vamoose1\"]", |
| 432 "http://www.google1.com/", | 436 "http://www.google1.com/", |
| 433 "Google1", | 437 "Google1", |
| 434 "http://www.args-url1.com/"); | 438 "http://www.args-url1.com/"); |
| 435 ASSERT_EQ(2, actions->at(1)->action_id()); | 439 ASSERT_EQ(2, actions->at(1)->action_id()); |
| 436 } | 440 } |
| 437 | 441 |
| 438 protected: | 442 protected: |
| 439 ExtensionService* extension_service_; | 443 ExtensionService* extension_service_; |
| 440 scoped_ptr<TestingProfile> profile_; | 444 std::unique_ptr<TestingProfile> profile_; |
| 441 content::TestBrowserThreadBundle thread_bundle_; | 445 content::TestBrowserThreadBundle thread_bundle_; |
| 442 // Used to preserve a copy of the original command line. | 446 // Used to preserve a copy of the original command line. |
| 443 // The test framework will do this itself as well. However, by then, | 447 // The test framework will do this itself as well. However, by then, |
| 444 // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in | 448 // it is too late to call ActivityLog::RecomputeLoggingIsEnabled() in |
| 445 // TearDown(). | 449 // TearDown(). |
| 446 base::CommandLine saved_cmdline_; | 450 base::CommandLine saved_cmdline_; |
| 447 | 451 |
| 448 #if defined OS_CHROMEOS | 452 #if defined OS_CHROMEOS |
| 449 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; | 453 chromeos::ScopedTestDeviceSettingsService test_device_settings_service_; |
| 450 chromeos::ScopedTestCrosSettings test_cros_settings_; | 454 chromeos::ScopedTestCrosSettings test_cros_settings_; |
| 451 scoped_ptr<chromeos::ScopedTestUserManager> test_user_manager_; | 455 std::unique_ptr<chromeos::ScopedTestUserManager> test_user_manager_; |
| 452 #endif | 456 #endif |
| 453 }; | 457 }; |
| 454 | 458 |
| 455 TEST_F(FullStreamUIPolicyTest, Construct) { | 459 TEST_F(FullStreamUIPolicyTest, Construct) { |
| 456 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); | 460 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 457 policy->Init(); | 461 policy->Init(); |
| 458 scoped_refptr<const Extension> extension = | 462 scoped_refptr<const Extension> extension = |
| 459 ExtensionBuilder() | 463 ExtensionBuilder() |
| 460 .SetManifest(DictionaryBuilder() | 464 .SetManifest(DictionaryBuilder() |
| 461 .Set("name", "Test extension") | 465 .Set("name", "Test extension") |
| 462 .Set("version", "1.0.0") | 466 .Set("version", "1.0.0") |
| 463 .Set("manifest_version", 2) | 467 .Set("manifest_version", 2) |
| 464 .Build()) | 468 .Build()) |
| 465 .Build(); | 469 .Build(); |
| 466 extension_service_->AddExtension(extension.get()); | 470 extension_service_->AddExtension(extension.get()); |
| 467 scoped_ptr<base::ListValue> args(new base::ListValue()); | 471 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 468 scoped_refptr<Action> action = new Action(extension->id(), | 472 scoped_refptr<Action> action = new Action(extension->id(), |
| 469 base::Time::Now(), | 473 base::Time::Now(), |
| 470 Action::ACTION_API_CALL, | 474 Action::ACTION_API_CALL, |
| 471 "tabs.testMethod"); | 475 "tabs.testMethod"); |
| 472 action->set_args(std::move(args)); | 476 action->set_args(std::move(args)); |
| 473 policy->ProcessAction(action); | 477 policy->ProcessAction(action); |
| 474 policy->Close(); | 478 policy->Close(); |
| 475 } | 479 } |
| 476 | 480 |
| 477 TEST_F(FullStreamUIPolicyTest, LogAndFetchActions) { | 481 TEST_F(FullStreamUIPolicyTest, LogAndFetchActions) { |
| 478 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); | 482 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 479 policy->Init(); | 483 policy->Init(); |
| 480 scoped_refptr<const Extension> extension = | 484 scoped_refptr<const Extension> extension = |
| 481 ExtensionBuilder() | 485 ExtensionBuilder() |
| 482 .SetManifest(DictionaryBuilder() | 486 .SetManifest(DictionaryBuilder() |
| 483 .Set("name", "Test extension") | 487 .Set("name", "Test extension") |
| 484 .Set("version", "1.0.0") | 488 .Set("version", "1.0.0") |
| 485 .Set("manifest_version", 2) | 489 .Set("manifest_version", 2) |
| 486 .Build()) | 490 .Build()) |
| 487 .Build(); | 491 .Build(); |
| 488 extension_service_->AddExtension(extension.get()); | 492 extension_service_->AddExtension(extension.get()); |
| 489 GURL gurl("http://www.google.com"); | 493 GURL gurl("http://www.google.com"); |
| 490 | 494 |
| 491 // Write some API calls | 495 // Write some API calls |
| 492 scoped_refptr<Action> action_api = new Action(extension->id(), | 496 scoped_refptr<Action> action_api = new Action(extension->id(), |
| 493 base::Time::Now(), | 497 base::Time::Now(), |
| 494 Action::ACTION_API_CALL, | 498 Action::ACTION_API_CALL, |
| 495 "tabs.testMethod"); | 499 "tabs.testMethod"); |
| 496 action_api->set_args(make_scoped_ptr(new base::ListValue())); | 500 action_api->set_args(base::WrapUnique(new base::ListValue())); |
| 497 policy->ProcessAction(action_api); | 501 policy->ProcessAction(action_api); |
| 498 | 502 |
| 499 scoped_refptr<Action> action_dom = new Action(extension->id(), | 503 scoped_refptr<Action> action_dom = new Action(extension->id(), |
| 500 base::Time::Now(), | 504 base::Time::Now(), |
| 501 Action::ACTION_DOM_ACCESS, | 505 Action::ACTION_DOM_ACCESS, |
| 502 "document.write"); | 506 "document.write"); |
| 503 action_dom->set_args(make_scoped_ptr(new base::ListValue())); | 507 action_dom->set_args(base::WrapUnique(new base::ListValue())); |
| 504 action_dom->set_page_url(gurl); | 508 action_dom->set_page_url(gurl); |
| 505 policy->ProcessAction(action_dom); | 509 policy->ProcessAction(action_dom); |
| 506 | 510 |
| 507 CheckReadData( | 511 CheckReadData( |
| 508 policy, | 512 policy, |
| 509 extension->id(), | 513 extension->id(), |
| 510 0, | 514 0, |
| 511 base::Bind(&FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions)); | 515 base::Bind(&FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions)); |
| 512 | 516 |
| 513 policy->Close(); | 517 policy->Close(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 525 .Build()) | 529 .Build()) |
| 526 .Build(); | 530 .Build(); |
| 527 extension_service_->AddExtension(extension.get()); | 531 extension_service_->AddExtension(extension.get()); |
| 528 GURL gurl("http://www.google.com"); | 532 GURL gurl("http://www.google.com"); |
| 529 | 533 |
| 530 // Write some API calls | 534 // Write some API calls |
| 531 scoped_refptr<Action> action_api = new Action(extension->id(), | 535 scoped_refptr<Action> action_api = new Action(extension->id(), |
| 532 base::Time::Now(), | 536 base::Time::Now(), |
| 533 Action::ACTION_API_CALL, | 537 Action::ACTION_API_CALL, |
| 534 "tabs.testMethod"); | 538 "tabs.testMethod"); |
| 535 action_api->set_args(make_scoped_ptr(new base::ListValue())); | 539 action_api->set_args(base::WrapUnique(new base::ListValue())); |
| 536 policy->ProcessAction(action_api); | 540 policy->ProcessAction(action_api); |
| 537 | 541 |
| 538 scoped_refptr<Action> action_dom = new Action(extension->id(), | 542 scoped_refptr<Action> action_dom = new Action(extension->id(), |
| 539 base::Time::Now(), | 543 base::Time::Now(), |
| 540 Action::ACTION_DOM_ACCESS, | 544 Action::ACTION_DOM_ACCESS, |
| 541 "document.write"); | 545 "document.write"); |
| 542 action_dom->set_args(make_scoped_ptr(new base::ListValue())); | 546 action_dom->set_args(base::WrapUnique(new base::ListValue())); |
| 543 action_dom->set_page_url(gurl); | 547 action_dom->set_page_url(gurl); |
| 544 policy->ProcessAction(action_dom); | 548 policy->ProcessAction(action_dom); |
| 545 | 549 |
| 546 CheckReadFilteredData( | 550 CheckReadFilteredData( |
| 547 policy, | 551 policy, |
| 548 extension->id(), | 552 extension->id(), |
| 549 Action::ACTION_API_CALL, | 553 Action::ACTION_API_CALL, |
| 550 "tabs.testMethod", | 554 "tabs.testMethod", |
| 551 "", | 555 "", |
| 552 "", | 556 "", |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 scoped_refptr<const Extension> extension = | 622 scoped_refptr<const Extension> extension = |
| 619 ExtensionBuilder() | 623 ExtensionBuilder() |
| 620 .SetManifest(DictionaryBuilder() | 624 .SetManifest(DictionaryBuilder() |
| 621 .Set("name", "Test extension") | 625 .Set("name", "Test extension") |
| 622 .Set("version", "1.0.0") | 626 .Set("version", "1.0.0") |
| 623 .Set("manifest_version", 2) | 627 .Set("manifest_version", 2) |
| 624 .Build()) | 628 .Build()) |
| 625 .Build(); | 629 .Build(); |
| 626 extension_service_->AddExtension(extension.get()); | 630 extension_service_->AddExtension(extension.get()); |
| 627 | 631 |
| 628 scoped_ptr<base::ListValue> args(new base::ListValue()); | 632 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
| 629 args->Set(0, new base::StringValue("hello")); | 633 args->Set(0, new base::StringValue("hello")); |
| 630 args->Set(1, new base::StringValue("world")); | 634 args->Set(1, new base::StringValue("world")); |
| 631 scoped_refptr<Action> action = new Action(extension->id(), | 635 scoped_refptr<Action> action = new Action(extension->id(), |
| 632 base::Time::Now(), | 636 base::Time::Now(), |
| 633 Action::ACTION_API_CALL, | 637 Action::ACTION_API_CALL, |
| 634 "extension.connect"); | 638 "extension.connect"); |
| 635 action->set_args(std::move(args)); | 639 action->set_args(std::move(args)); |
| 636 | 640 |
| 637 policy->ProcessAction(action); | 641 policy->ProcessAction(action); |
| 638 CheckReadData(policy, | 642 CheckReadData(policy, |
| 639 extension->id(), | 643 extension->id(), |
| 640 0, | 644 0, |
| 641 base::Bind(&FullStreamUIPolicyTest::Arguments_Present)); | 645 base::Bind(&FullStreamUIPolicyTest::Arguments_Present)); |
| 642 policy->Close(); | 646 policy->Close(); |
| 643 } | 647 } |
| 644 | 648 |
| 645 TEST_F(FullStreamUIPolicyTest, GetTodaysActions) { | 649 TEST_F(FullStreamUIPolicyTest, GetTodaysActions) { |
| 646 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); | 650 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 647 policy->Init(); | 651 policy->Init(); |
| 648 | 652 |
| 649 // Use a mock clock to ensure that events are not recorded on the wrong day | 653 // Use a mock clock to ensure that events are not recorded on the wrong day |
| 650 // when the test is run close to local midnight. Note: Ownership is passed | 654 // when the test is run close to local midnight. Note: Ownership is passed |
| 651 // to the policy, but we still keep a pointer locally. The policy will take | 655 // to the policy, but we still keep a pointer locally. The policy will take |
| 652 // care of destruction; this is safe since the policy outlives all our | 656 // care of destruction; this is safe since the policy outlives all our |
| 653 // accesses to the mock clock. | 657 // accesses to the mock clock. |
| 654 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); | 658 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); |
| 655 mock_clock->SetNow(base::Time::Now().LocalMidnight() + | 659 mock_clock->SetNow(base::Time::Now().LocalMidnight() + |
| 656 base::TimeDelta::FromHours(12)); | 660 base::TimeDelta::FromHours(12)); |
| 657 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock)); | 661 policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock)); |
| 658 | 662 |
| 659 // Record some actions | 663 // Record some actions |
| 660 scoped_refptr<Action> action = | 664 scoped_refptr<Action> action = |
| 661 new Action("punky", | 665 new Action("punky", |
| 662 mock_clock->Now() - base::TimeDelta::FromMinutes(40), | 666 mock_clock->Now() - base::TimeDelta::FromMinutes(40), |
| 663 Action::ACTION_API_CALL, | 667 Action::ACTION_API_CALL, |
| 664 "brewster"); | 668 "brewster"); |
| 665 action->mutable_args()->AppendString("woof"); | 669 action->mutable_args()->AppendString("woof"); |
| 666 action->set_arg_url(GURL("http://www.arg-url.com")); | 670 action->set_arg_url(GURL("http://www.arg-url.com")); |
| 667 action->set_page_title("Page Title"); | 671 action->set_page_title("Page Title"); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 693 // Check that we can read back less recent actions in the db. | 697 // Check that we can read back less recent actions in the db. |
| 694 TEST_F(FullStreamUIPolicyTest, GetOlderActions) { | 698 TEST_F(FullStreamUIPolicyTest, GetOlderActions) { |
| 695 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); | 699 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 696 policy->Init(); | 700 policy->Init(); |
| 697 | 701 |
| 698 // Use a mock clock to ensure that events are not recorded on the wrong day | 702 // Use a mock clock to ensure that events are not recorded on the wrong day |
| 699 // when the test is run close to local midnight. | 703 // when the test is run close to local midnight. |
| 700 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); | 704 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); |
| 701 mock_clock->SetNow(base::Time::Now().LocalMidnight() + | 705 mock_clock->SetNow(base::Time::Now().LocalMidnight() + |
| 702 base::TimeDelta::FromHours(12)); | 706 base::TimeDelta::FromHours(12)); |
| 703 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock)); | 707 policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock)); |
| 704 | 708 |
| 705 // Record some actions | 709 // Record some actions |
| 706 scoped_refptr<Action> action = | 710 scoped_refptr<Action> action = |
| 707 new Action("punky", | 711 new Action("punky", |
| 708 mock_clock->Now() - base::TimeDelta::FromDays(3) - | 712 mock_clock->Now() - base::TimeDelta::FromDays(3) - |
| 709 base::TimeDelta::FromMinutes(40), | 713 base::TimeDelta::FromMinutes(40), |
| 710 Action::ACTION_API_CALL, | 714 Action::ACTION_API_CALL, |
| 711 "brewster"); | 715 "brewster"); |
| 712 action->mutable_args()->AppendString("woof"); | 716 action->mutable_args()->AppendString("woof"); |
| 713 policy->ProcessAction(action); | 717 policy->ProcessAction(action); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 | 750 |
| 747 TEST_F(FullStreamUIPolicyTest, RemoveAllURLs) { | 751 TEST_F(FullStreamUIPolicyTest, RemoveAllURLs) { |
| 748 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); | 752 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 749 policy->Init(); | 753 policy->Init(); |
| 750 | 754 |
| 751 // Use a mock clock to ensure that events are not recorded on the wrong day | 755 // Use a mock clock to ensure that events are not recorded on the wrong day |
| 752 // when the test is run close to local midnight. | 756 // when the test is run close to local midnight. |
| 753 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); | 757 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); |
| 754 mock_clock->SetNow(base::Time::Now().LocalMidnight() + | 758 mock_clock->SetNow(base::Time::Now().LocalMidnight() + |
| 755 base::TimeDelta::FromHours(12)); | 759 base::TimeDelta::FromHours(12)); |
| 756 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock)); | 760 policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock)); |
| 757 | 761 |
| 758 // Record some actions | 762 // Record some actions |
| 759 scoped_refptr<Action> action = | 763 scoped_refptr<Action> action = |
| 760 new Action("punky", mock_clock->Now(), | 764 new Action("punky", mock_clock->Now(), |
| 761 Action::ACTION_DOM_ACCESS, "lets"); | 765 Action::ACTION_DOM_ACCESS, "lets"); |
| 762 action->mutable_args()->AppendString("vamoose"); | 766 action->mutable_args()->AppendString("vamoose"); |
| 763 action->set_page_url(GURL("http://www.google.com")); | 767 action->set_page_url(GURL("http://www.google.com")); |
| 764 action->set_page_title("Google"); | 768 action->set_page_title("Google"); |
| 765 action->set_arg_url(GURL("http://www.google.com")); | 769 action->set_arg_url(GURL("http://www.google.com")); |
| 766 policy->ProcessAction(action); | 770 policy->ProcessAction(action); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 789 | 793 |
| 790 TEST_F(FullStreamUIPolicyTest, RemoveSpecificURLs) { | 794 TEST_F(FullStreamUIPolicyTest, RemoveSpecificURLs) { |
| 791 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); | 795 ActivityLogDatabasePolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 792 policy->Init(); | 796 policy->Init(); |
| 793 | 797 |
| 794 // Use a mock clock to ensure that events are not recorded on the wrong day | 798 // Use a mock clock to ensure that events are not recorded on the wrong day |
| 795 // when the test is run close to local midnight. | 799 // when the test is run close to local midnight. |
| 796 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); | 800 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); |
| 797 mock_clock->SetNow(base::Time::Now().LocalMidnight() + | 801 mock_clock->SetNow(base::Time::Now().LocalMidnight() + |
| 798 base::TimeDelta::FromHours(12)); | 802 base::TimeDelta::FromHours(12)); |
| 799 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock)); | 803 policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock)); |
| 800 | 804 |
| 801 // Record some actions | 805 // Record some actions |
| 802 // This should have the page url and args url cleared. | 806 // This should have the page url and args url cleared. |
| 803 scoped_refptr<Action> action = new Action("punky", mock_clock->Now(), | 807 scoped_refptr<Action> action = new Action("punky", mock_clock->Now(), |
| 804 Action::ACTION_DOM_ACCESS, "lets"); | 808 Action::ACTION_DOM_ACCESS, "lets"); |
| 805 action->mutable_args()->AppendString("vamoose"); | 809 action->mutable_args()->AppendString("vamoose"); |
| 806 action->set_page_url(GURL("http://www.google1.com")); | 810 action->set_page_url(GURL("http://www.google1.com")); |
| 807 action->set_page_title("Google"); | 811 action->set_page_title("Google"); |
| 808 action->set_arg_url(GURL("http://www.google1.com")); | 812 action->set_arg_url(GURL("http://www.google1.com")); |
| 809 policy->ProcessAction(action); | 813 policy->ProcessAction(action); |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 | 869 |
| 866 TEST_F(FullStreamUIPolicyTest, RemoveExtensionData) { | 870 TEST_F(FullStreamUIPolicyTest, RemoveExtensionData) { |
| 867 FullStreamUIPolicy* policy = new FullStreamUIPolicy(profile_.get()); | 871 FullStreamUIPolicy* policy = new FullStreamUIPolicy(profile_.get()); |
| 868 policy->Init(); | 872 policy->Init(); |
| 869 | 873 |
| 870 // Use a mock clock to ensure that events are not recorded on the wrong day | 874 // Use a mock clock to ensure that events are not recorded on the wrong day |
| 871 // when the test is run close to local midnight. | 875 // when the test is run close to local midnight. |
| 872 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); | 876 base::SimpleTestClock* mock_clock = new base::SimpleTestClock(); |
| 873 mock_clock->SetNow(base::Time::Now().LocalMidnight() + | 877 mock_clock->SetNow(base::Time::Now().LocalMidnight() + |
| 874 base::TimeDelta::FromHours(12)); | 878 base::TimeDelta::FromHours(12)); |
| 875 policy->SetClockForTesting(scoped_ptr<base::Clock>(mock_clock)); | 879 policy->SetClockForTesting(std::unique_ptr<base::Clock>(mock_clock)); |
| 876 | 880 |
| 877 // Record some actions | 881 // Record some actions |
| 878 scoped_refptr<Action> action = new Action("deleteextensiondata", | 882 scoped_refptr<Action> action = new Action("deleteextensiondata", |
| 879 mock_clock->Now(), | 883 mock_clock->Now(), |
| 880 Action::ACTION_DOM_ACCESS, | 884 Action::ACTION_DOM_ACCESS, |
| 881 "lets"); | 885 "lets"); |
| 882 action->mutable_args()->AppendString("vamoose"); | 886 action->mutable_args()->AppendString("vamoose"); |
| 883 action->set_page_title("Google"); | 887 action->set_page_title("Google"); |
| 884 action->set_arg_url(GURL("http://www.google.com")); | 888 action->set_arg_url(GURL("http://www.google.com")); |
| 885 policy->ProcessAction(action); | 889 policy->ProcessAction(action); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 966 .Build()) | 970 .Build()) |
| 967 .Build(); | 971 .Build(); |
| 968 extension_service_->AddExtension(extension.get()); | 972 extension_service_->AddExtension(extension.get()); |
| 969 GURL gurl("http://www.google.com"); | 973 GURL gurl("http://www.google.com"); |
| 970 | 974 |
| 971 // Write some API calls. | 975 // Write some API calls. |
| 972 scoped_refptr<Action> action_api = new Action(extension->id(), | 976 scoped_refptr<Action> action_api = new Action(extension->id(), |
| 973 base::Time::Now(), | 977 base::Time::Now(), |
| 974 Action::ACTION_API_CALL, | 978 Action::ACTION_API_CALL, |
| 975 "tabs.testMethod"); | 979 "tabs.testMethod"); |
| 976 action_api->set_args(make_scoped_ptr(new base::ListValue())); | 980 action_api->set_args(base::WrapUnique(new base::ListValue())); |
| 977 policy->ProcessAction(action_api); | 981 policy->ProcessAction(action_api); |
| 978 | 982 |
| 979 scoped_refptr<Action> action_dom = new Action(extension->id(), | 983 scoped_refptr<Action> action_dom = new Action(extension->id(), |
| 980 base::Time::Now(), | 984 base::Time::Now(), |
| 981 Action::ACTION_DOM_ACCESS, | 985 Action::ACTION_DOM_ACCESS, |
| 982 "document.write"); | 986 "document.write"); |
| 983 action_dom->set_args(make_scoped_ptr(new base::ListValue())); | 987 action_dom->set_args(base::WrapUnique(new base::ListValue())); |
| 984 action_dom->set_page_url(gurl); | 988 action_dom->set_page_url(gurl); |
| 985 policy->ProcessAction(action_dom); | 989 policy->ProcessAction(action_dom); |
| 986 | 990 |
| 987 CheckReadData( | 991 CheckReadData( |
| 988 policy, | 992 policy, |
| 989 extension->id(), | 993 extension->id(), |
| 990 0, | 994 0, |
| 991 base::Bind(&FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions)); | 995 base::Bind(&FullStreamUIPolicyTest::RetrieveActions_LogAndFetchActions)); |
| 992 | 996 |
| 993 // Now delete them. | 997 // Now delete them. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1055 action_ids.push_back(3); | 1059 action_ids.push_back(3); |
| 1056 action_ids.push_back(4); | 1060 action_ids.push_back(4); |
| 1057 CheckRemoveActions( | 1061 CheckRemoveActions( |
| 1058 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); | 1062 policy, action_ids, base::Bind(&FullStreamUIPolicyTest::Action2Deleted)); |
| 1059 action_ids.clear(); | 1063 action_ids.clear(); |
| 1060 | 1064 |
| 1061 policy->Close(); | 1065 policy->Close(); |
| 1062 } | 1066 } |
| 1063 | 1067 |
| 1064 } // namespace extensions | 1068 } // namespace extensions |
| OLD | NEW |