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 "chrome/browser/extensions/api/runtime/runtime_api.h" | 5 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/extensions/event_router.h" | 8 #include "chrome/browser/extensions/event_router.h" |
9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
10 #include "chrome/browser/extensions/extension_process_manager.h" | 10 #include "chrome/browser/extensions/extension_process_manager.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 system->lazy_background_task_queue()-> | 62 system->lazy_background_task_queue()-> |
63 ShouldEnqueueTask(profile, extension)) { | 63 ShouldEnqueueTask(profile, extension)) { |
64 system->lazy_background_task_queue()->AddPendingTask( | 64 system->lazy_background_task_queue()->AddPendingTask( |
65 profile, extension_id, | 65 profile, extension_id, |
66 base::Bind(&DispatchOnStartupEventImpl, | 66 base::Bind(&DispatchOnStartupEventImpl, |
67 profile, extension_id, false)); | 67 profile, extension_id, false)); |
68 return; | 68 return; |
69 } | 69 } |
70 | 70 |
71 scoped_ptr<base::ListValue> event_args(new ListValue()); | 71 scoped_ptr<base::ListValue> event_args(new ListValue()); |
72 system->event_router()->DispatchEventToExtension( | 72 scoped_ptr<Event> event(new Event(kOnStartupEvent, event_args.Pass())); |
73 extension_id, kOnStartupEvent, event_args.Pass(), NULL, GURL()); | 73 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); |
74 } | 74 } |
75 | 75 |
76 } // namespace | 76 } // namespace |
77 | 77 |
78 // static | 78 // static |
79 void RuntimeEventRouter::DispatchOnStartupEvent( | 79 void RuntimeEventRouter::DispatchOnStartupEvent( |
80 Profile* profile, const std::string& extension_id) { | 80 Profile* profile, const std::string& extension_id) { |
81 DispatchOnStartupEventImpl(profile, extension_id, true, NULL); | 81 DispatchOnStartupEventImpl(profile, extension_id, true, NULL); |
82 } | 82 } |
83 | 83 |
(...skipping 18 matching lines...) Expand all Loading... |
102 if (old_version.IsValid()) { | 102 if (old_version.IsValid()) { |
103 info->SetString(kInstallReason, kInstallReasonUpdate); | 103 info->SetString(kInstallReason, kInstallReasonUpdate); |
104 info->SetString(kInstallPreviousVersion, old_version.GetString()); | 104 info->SetString(kInstallPreviousVersion, old_version.GetString()); |
105 } else if (chrome_updated) { | 105 } else if (chrome_updated) { |
106 info->SetString(kInstallReason, kInstallReasonChromeUpdate); | 106 info->SetString(kInstallReason, kInstallReasonChromeUpdate); |
107 } else { | 107 } else { |
108 info->SetString(kInstallReason, kInstallReasonInstall); | 108 info->SetString(kInstallReason, kInstallReasonInstall); |
109 } | 109 } |
110 DCHECK(system->event_router()); | 110 DCHECK(system->event_router()); |
111 system->event_router()->AddLazyEventListener(kOnInstalledEvent, extension_id); | 111 system->event_router()->AddLazyEventListener(kOnInstalledEvent, extension_id); |
112 system->event_router()->DispatchEventToExtension( | 112 scoped_ptr<Event> event(new Event(kOnInstalledEvent, event_args.Pass())); |
113 extension_id, kOnInstalledEvent, event_args.Pass(), NULL, GURL()); | 113 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); |
114 system->event_router()->RemoveLazyEventListener(kOnInstalledEvent, | 114 system->event_router()->RemoveLazyEventListener(kOnInstalledEvent, |
115 extension_id); | 115 extension_id); |
116 } | 116 } |
117 | 117 |
118 // static | 118 // static |
119 void RuntimeEventRouter::DispatchOnUpdateAvailableEvent( | 119 void RuntimeEventRouter::DispatchOnUpdateAvailableEvent( |
120 Profile* profile, | 120 Profile* profile, |
121 const std::string& extension_id, | 121 const std::string& extension_id, |
122 const DictionaryValue* manifest) { | 122 const DictionaryValue* manifest) { |
123 ExtensionSystem* system = ExtensionSystem::Get(profile); | 123 ExtensionSystem* system = ExtensionSystem::Get(profile); |
124 if (!system) | 124 if (!system) |
125 return; | 125 return; |
126 | 126 |
127 scoped_ptr<ListValue> args(new ListValue); | 127 scoped_ptr<ListValue> args(new ListValue); |
128 args->Append(manifest->DeepCopy()); | 128 args->Append(manifest->DeepCopy()); |
129 DCHECK(system->event_router()); | 129 DCHECK(system->event_router()); |
130 system->event_router()->DispatchEventToExtension( | 130 scoped_ptr<Event> event(new Event(kOnUpdateAvailableEvent, args.Pass())); |
131 extension_id, kOnUpdateAvailableEvent, args.Pass(), NULL, GURL()); | 131 system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); |
132 } | 132 } |
133 | 133 |
134 bool RuntimeGetBackgroundPageFunction::RunImpl() { | 134 bool RuntimeGetBackgroundPageFunction::RunImpl() { |
135 ExtensionHost* host = | 135 ExtensionHost* host = |
136 ExtensionSystem::Get(profile())->process_manager()-> | 136 ExtensionSystem::Get(profile())->process_manager()-> |
137 GetBackgroundHostForExtension(extension_id()); | 137 GetBackgroundHostForExtension(extension_id()); |
138 if (host) { | 138 if (host) { |
139 OnPageLoaded(host); | 139 OnPageLoaded(host); |
140 } else if (GetExtension()->has_lazy_background_page()) { | 140 } else if (GetExtension()->has_lazy_background_page()) { |
141 ExtensionSystem::Get(profile())->lazy_background_task_queue()-> | 141 ExtensionSystem::Get(profile())->lazy_background_task_queue()-> |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 did_reply_ = true; | 237 did_reply_ = true; |
238 results_.reset(new base::ListValue); | 238 results_.reset(new base::ListValue); |
239 results_->AppendString(kUpdateFound); | 239 results_->AppendString(kUpdateFound); |
240 base::DictionaryValue* details = new base::DictionaryValue; | 240 base::DictionaryValue* details = new base::DictionaryValue; |
241 results_->Append(details); | 241 results_->Append(details); |
242 details->SetString("version", version); | 242 details->SetString("version", version); |
243 SendResponse(true); | 243 SendResponse(true); |
244 } | 244 } |
245 | 245 |
246 } // namespace extensions | 246 } // namespace extensions |
OLD | NEW |