| 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/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/prefs/pref_service.h" | 6 #include "base/prefs/pref_service.h" |
| 7 #include "chrome/browser/download/download_prefs.h" | 7 #include "chrome/browser/download/download_prefs.h" |
| 8 #include "chrome/browser/extensions/api/streams_private/streams_resource_throttl
e.h" | 8 #include "chrome/browser/extensions/api/streams_private/streams_resource_throttl
e.h" |
| 9 #include "chrome/browser/extensions/event_router.h" | 9 #include "chrome/browser/extensions/event_router.h" |
| 10 #include "chrome/browser/extensions/extension_apitest.h" | 10 #include "chrome/browser/extensions/extension_apitest.h" |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 171 |
| 172 // Sends onExecuteContentHandler event with the MIME type "test/done" to the | 172 // Sends onExecuteContentHandler event with the MIME type "test/done" to the |
| 173 // test extension. | 173 // test extension. |
| 174 // The test extension calls 'chrome.test.notifySuccess' when it receives the | 174 // The test extension calls 'chrome.test.notifySuccess' when it receives the |
| 175 // event with the "test/done" MIME type (unless the 'chrome.test.notifyFail' | 175 // event with the "test/done" MIME type (unless the 'chrome.test.notifyFail' |
| 176 // has already been called). | 176 // has already been called). |
| 177 void SendDoneEvent() { | 177 void SendDoneEvent() { |
| 178 scoped_ptr<ListValue> event_args(new ListValue()); | 178 scoped_ptr<ListValue> event_args(new ListValue()); |
| 179 event_args->Append(new base::StringValue("test/done")); | 179 event_args->Append(new base::StringValue("test/done")); |
| 180 event_args->Append(new base::StringValue("http://foo")); | 180 event_args->Append(new base::StringValue("http://foo")); |
| 181 event_args->Append(new base::StringValue("blob://bar")); |
| 181 | 182 |
| 182 scoped_ptr<Event> event(new Event( | 183 scoped_ptr<Event> event(new Event( |
| 183 "streamsPrivate.onExecuteMimeTypeHandler", event_args.Pass())); | 184 "streamsPrivate.onExecuteMimeTypeHandler", event_args.Pass())); |
| 184 | 185 |
| 185 ExtensionSystem::Get(browser()->profile())->event_router()-> | 186 ExtensionSystem::Get(browser()->profile())->event_router()-> |
| 186 DispatchEventToExtension(test_extension_id_, event.Pass()); | 187 DispatchEventToExtension(test_extension_id_, event.Pass()); |
| 187 } | 188 } |
| 188 | 189 |
| 189 // Loads the test extension and set's up its file_browser_handler to handle | 190 // Loads the test extension and set's up its file_browser_handler to handle |
| 190 // 'application/msword' and 'plain/text' MIME types. | 191 // 'application/msword' and 'plain/text' MIME types. |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 // The test extension should not receive any events by now. Send it an event | 391 // The test extension should not receive any events by now. Send it an event |
| 391 // with MIME type "test/done", so it stops waiting for the events. (If there | 392 // with MIME type "test/done", so it stops waiting for the events. (If there |
| 392 // was an event with MIME type 'plain/text', |catcher.GetNextResult()| will | 393 // was an event with MIME type 'plain/text', |catcher.GetNextResult()| will |
| 393 // fail regardless of the sent event; chrome.test.notifySuccess will not be | 394 // fail regardless of the sent event; chrome.test.notifySuccess will not be |
| 394 // called by the extension). | 395 // called by the extension). |
| 395 SendDoneEvent(); | 396 SendDoneEvent(); |
| 396 EXPECT_TRUE(catcher.GetNextResult()); | 397 EXPECT_TRUE(catcher.GetNextResult()); |
| 397 } | 398 } |
| 398 | 399 |
| 399 } // namespace | 400 } // namespace |
| OLD | NEW |