| 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/chromeos/extensions/file_browser_handler.h" | 7 #include "chrome/browser/chromeos/extensions/file_browser_handler.h" |
| 8 #include "chrome/browser/chromeos/extensions/file_browser_resource_throttle.h" | 8 #include "chrome/browser/chromeos/extensions/file_browser_resource_throttle.h" |
| 9 #include "chrome/browser/download/download_prefs.h" | 9 #include "chrome/browser/download/download_prefs.h" |
| 10 #include "chrome/browser/extensions/event_router.h" | 10 #include "chrome/browser/extensions/event_router.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 // Sends onExecuteContentHandler event with the MIME type "test/done" to the | 171 // Sends onExecuteContentHandler event with the MIME type "test/done" to the |
| 172 // test extension. | 172 // test extension. |
| 173 // The test extension calls 'chrome.test.notifySuccess' when it receives the | 173 // The test extension calls 'chrome.test.notifySuccess' when it receives the |
| 174 // event with the "test/done" MIME type (unless the 'chrome.test.notifyFail' | 174 // event with the "test/done" MIME type (unless the 'chrome.test.notifyFail' |
| 175 // has already been called). | 175 // has already been called). |
| 176 void SendDoneEvent() { | 176 void SendDoneEvent() { |
| 177 scoped_ptr<ListValue> event_args(new ListValue()); | 177 scoped_ptr<ListValue> event_args(new ListValue()); |
| 178 event_args->Append(new base::StringValue("test/done")); | 178 event_args->Append(new base::StringValue("test/done")); |
| 179 event_args->Append(new base::StringValue("http://foo")); | 179 event_args->Append(new base::StringValue("http://foo")); |
| 180 event_args->Append(new base::StringValue("blob://bar")); |
| 180 | 181 |
| 181 scoped_ptr<Event> event(new Event( | 182 scoped_ptr<Event> event(new Event( |
| 182 "fileBrowserHandler.onExecuteContentHandler", event_args.Pass())); | 183 "fileBrowserHandler.onExecuteContentHandler", event_args.Pass())); |
| 183 | 184 |
| 184 ExtensionSystem::Get(browser()->profile())->event_router()-> | 185 ExtensionSystem::Get(browser()->profile())->event_router()-> |
| 185 DispatchEventToExtension(test_extension_id_, event.Pass()); | 186 DispatchEventToExtension(test_extension_id_, event.Pass()); |
| 186 } | 187 } |
| 187 | 188 |
| 188 // Loads the test extension and set's up its file_browser_handler to handle | 189 // Loads the test extension and set's up its file_browser_handler to handle |
| 189 // 'application/msword' and 'plain/text' MIME types. | 190 // 'application/msword' and 'plain/text' MIME types. |
| (...skipping 200 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 |