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/window_event_router.h" | 5 #include "chrome/browser/extensions/window_event_router.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/event_names.h" | 9 #include "chrome/browser/extensions/event_names.h" |
10 #include "chrome/browser/extensions/event_router.h" | 10 #include "chrome/browser/extensions/event_router.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 if (focused_profile_ != NULL && previous_focused_profile != NULL && | 145 if (focused_profile_ != NULL && previous_focused_profile != NULL && |
146 focused_profile_ != previous_focused_profile) { | 146 focused_profile_ != previous_focused_profile) { |
147 ListValue none_args; | 147 ListValue none_args; |
148 none_args.Append( | 148 none_args.Append( |
149 Value::CreateIntegerValue(extension_misc::kUnknownWindowId)); | 149 Value::CreateIntegerValue(extension_misc::kUnknownWindowId)); |
150 base::JSONWriter::Write(&none_args, &none_json_args); | 150 base::JSONWriter::Write(&none_args, &none_json_args); |
151 } | 151 } |
152 | 152 |
153 if (!window_profile) | 153 if (!window_profile) |
154 window_profile = previous_focused_profile; | 154 window_profile = previous_focused_profile; |
| 155 if (!profile_->IsSameProfile(window_profile) || |
| 156 !ExtensionSystem::Get(window_profile)->event_router()) { |
| 157 return; |
| 158 } |
155 | 159 |
156 ExtensionSystem::Get(window_profile)->event_router()-> | 160 ExtensionSystem::Get(window_profile)->event_router()-> |
157 DispatchEventsToRenderersAcrossIncognito( | 161 DispatchEventsToRenderersAcrossIncognito( |
158 event_names::kOnWindowFocusedChanged, | 162 event_names::kOnWindowFocusedChanged, |
159 real_json_args, | 163 real_json_args, |
160 window_profile, | 164 window_profile, |
161 none_json_args, | 165 none_json_args, |
162 GURL()); | 166 GURL()); |
163 } | 167 } |
164 | 168 |
165 void WindowEventRouter::DispatchEvent(const char* event_name, | 169 void WindowEventRouter::DispatchEvent(const char* event_name, |
166 Profile* profile, | 170 Profile* profile, |
167 base::ListValue* args) { | 171 base::ListValue* args) { |
168 std::string json_args; | 172 std::string json_args; |
169 base::JSONWriter::Write(args, &json_args); | 173 base::JSONWriter::Write(args, &json_args); |
170 ExtensionSystem::Get(profile)->event_router()-> | 174 ExtensionSystem::Get(profile)->event_router()-> |
171 DispatchEventToRenderers(event_name, json_args, profile, GURL()); | 175 DispatchEventToRenderers(event_name, json_args, profile, GURL()); |
172 } | 176 } |
173 | 177 |
174 } // namespace extensions | 178 } // namespace extensions |
OLD | NEW |