| 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/browser_event_router.h" | 5 #include "chrome/browser/extensions/browser_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/api/extension_action/extension_page_actions_
api_constants.h" | 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_
api_constants.h" |
| 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 // The onHighlighted event replaced onHighlightChanged. | 307 // The onHighlighted event replaced onHighlightChanged. |
| 308 Profile* profile = tab_strip_model->profile(); | 308 Profile* profile = tab_strip_model->profile(); |
| 309 DispatchEvent(profile, events::kOnTabHighlightChanged, | 309 DispatchEvent(profile, events::kOnTabHighlightChanged, |
| 310 scoped_ptr<ListValue>(args->DeepCopy()), | 310 scoped_ptr<ListValue>(args->DeepCopy()), |
| 311 EventRouter::USER_GESTURE_UNKNOWN); | 311 EventRouter::USER_GESTURE_UNKNOWN); |
| 312 DispatchEvent(profile, events::kOnTabHighlighted, args.Pass(), | 312 DispatchEvent(profile, events::kOnTabHighlighted, args.Pass(), |
| 313 EventRouter::USER_GESTURE_UNKNOWN); | 313 EventRouter::USER_GESTURE_UNKNOWN); |
| 314 } | 314 } |
| 315 | 315 |
| 316 void BrowserEventRouter::TabMoved(TabContents* contents, | 316 void BrowserEventRouter::TabMoved(WebContents* contents, |
| 317 int from_index, | 317 int from_index, |
| 318 int to_index) { | 318 int to_index) { |
| 319 scoped_ptr<ListValue> args(new ListValue()); | 319 scoped_ptr<ListValue> args(new ListValue()); |
| 320 args->Append(Value::CreateIntegerValue( | 320 args->Append(Value::CreateIntegerValue(ExtensionTabUtil::GetTabId(contents))); |
| 321 ExtensionTabUtil::GetTabId(contents->web_contents()))); | |
| 322 | 321 |
| 323 DictionaryValue* object_args = new DictionaryValue(); | 322 DictionaryValue* object_args = new DictionaryValue(); |
| 324 object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue( | 323 object_args->Set(tab_keys::kWindowIdKey, Value::CreateIntegerValue( |
| 325 ExtensionTabUtil::GetWindowIdOfTab(contents->web_contents()))); | 324 ExtensionTabUtil::GetWindowIdOfTab(contents))); |
| 326 object_args->Set(tab_keys::kFromIndexKey, Value::CreateIntegerValue( | 325 object_args->Set(tab_keys::kFromIndexKey, Value::CreateIntegerValue( |
| 327 from_index)); | 326 from_index)); |
| 328 object_args->Set(tab_keys::kToIndexKey, Value::CreateIntegerValue( | 327 object_args->Set(tab_keys::kToIndexKey, Value::CreateIntegerValue( |
| 329 to_index)); | 328 to_index)); |
| 330 args->Append(object_args); | 329 args->Append(object_args); |
| 331 | 330 |
| 332 DispatchEvent(contents->profile(), events::kOnTabMoved, args.Pass(), | 331 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 332 DispatchEvent(profile, events::kOnTabMoved, args.Pass(), |
| 333 EventRouter::USER_GESTURE_UNKNOWN); | 333 EventRouter::USER_GESTURE_UNKNOWN); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void BrowserEventRouter::TabUpdated(WebContents* contents, bool did_navigate) { | 336 void BrowserEventRouter::TabUpdated(WebContents* contents, bool did_navigate) { |
| 337 TabEntry* entry = GetTabEntry(contents); | 337 TabEntry* entry = GetTabEntry(contents); |
| 338 DictionaryValue* changed_properties = NULL; | 338 DictionaryValue* changed_properties = NULL; |
| 339 | 339 |
| 340 DCHECK(entry); | 340 DCHECK(entry); |
| 341 | 341 |
| 342 if (did_navigate) | 342 if (did_navigate) |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 | 595 |
| 596 DispatchEventToExtension(profile, | 596 DispatchEventToExtension(profile, |
| 597 extension_action.extension_id(), | 597 extension_action.extension_id(), |
| 598 event_name, | 598 event_name, |
| 599 args.Pass(), | 599 args.Pass(), |
| 600 EventRouter::USER_GESTURE_ENABLED); | 600 EventRouter::USER_GESTURE_ENABLED); |
| 601 } | 601 } |
| 602 } | 602 } |
| 603 | 603 |
| 604 } // namespace extensions | 604 } // namespace extensions |
| OLD | NEW |