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/files/file_path.h" | 5 #include "base/files/file_path.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/extensions/event_router.h" | 10 #include "chrome/browser/extensions/event_router.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 namespace { | 29 namespace { |
30 | 30 |
31 class MessageSender : public content::NotificationObserver { | 31 class MessageSender : public content::NotificationObserver { |
32 public: | 32 public: |
33 MessageSender() { | 33 MessageSender() { |
34 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 34 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
35 content::NotificationService::AllSources()); | 35 content::NotificationService::AllSources()); |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 static scoped_ptr<ListValue> BuildEventArguments(const bool last_message, | 39 static scoped_ptr<base::ListValue> BuildEventArguments( |
40 const std::string& data) { | 40 const bool last_message, |
| 41 const std::string& data) { |
41 DictionaryValue* event = new DictionaryValue(); | 42 DictionaryValue* event = new DictionaryValue(); |
42 event->SetBoolean("lastMessage", last_message); | 43 event->SetBoolean("lastMessage", last_message); |
43 event->SetString("data", data); | 44 event->SetString("data", data); |
44 scoped_ptr<ListValue> arguments(new ListValue()); | 45 scoped_ptr<base::ListValue> arguments(new base::ListValue()); |
45 arguments->Append(event); | 46 arguments->Append(event); |
46 return arguments.Pass(); | 47 return arguments.Pass(); |
47 } | 48 } |
48 | 49 |
49 static scoped_ptr<extensions::Event> BuildEvent( | 50 static scoped_ptr<extensions::Event> BuildEvent( |
50 scoped_ptr<ListValue> event_args, | 51 scoped_ptr<base::ListValue> event_args, |
51 Profile* profile, | 52 Profile* profile, |
52 GURL event_url) { | 53 GURL event_url) { |
53 scoped_ptr<extensions::Event> event(new extensions::Event( | 54 scoped_ptr<extensions::Event> event(new extensions::Event( |
54 "test.onMessage", event_args.Pass())); | 55 "test.onMessage", event_args.Pass())); |
55 event->restrict_to_profile = profile; | 56 event->restrict_to_profile = profile; |
56 event->event_url = event_url; | 57 event->event_url = event_url; |
57 return event.Pass(); | 58 return event.Pass(); |
58 } | 59 } |
59 | 60 |
60 virtual void Observe(int type, | 61 virtual void Observe(int type, |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // will no longer exist. | 306 // will no longer exist. |
306 DisableExtension(web_connectable->id()); | 307 DisableExtension(web_connectable->id()); |
307 EXPECT_EQ(NAMESPACE_NOT_DEFINED, | 308 EXPECT_EQ(NAMESPACE_NOT_DEFINED, |
308 CanConnectAndSendMessages(web_connectable->id())); | 309 CanConnectAndSendMessages(web_connectable->id())); |
309 | 310 |
310 EnableExtension(web_connectable->id()); | 311 EnableExtension(web_connectable->id()); |
311 EXPECT_EQ(OK, CanConnectAndSendMessages(web_connectable->id())); | 312 EXPECT_EQ(OK, CanConnectAndSendMessages(web_connectable->id())); |
312 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, | 313 EXPECT_EQ(COULD_NOT_ESTABLISH_CONNECTION_ERROR, |
313 CanConnectAndSendMessages(not_connectable->id())); | 314 CanConnectAndSendMessages(not_connectable->id())); |
314 } | 315 } |
OLD | NEW |