Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: chrome/browser/extensions/browser_event_router.cc

Issue 10829186: Tabs API is usable without tabs permission. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 const std::string& extension_id, 383 const std::string& extension_id,
384 const char* event_name, 384 const char* event_name,
385 const WebContents* web_contents, 385 const WebContents* web_contents,
386 bool active, 386 bool active,
387 EventRouter::UserGestureState user_gesture) { 387 EventRouter::UserGestureState user_gesture) {
388 if (!profile_->IsSameProfile(profile)) 388 if (!profile_->IsSameProfile(profile))
389 return; 389 return;
390 390
391 scoped_ptr<ListValue> args(new ListValue()); 391 scoped_ptr<ListValue> args(new ListValue());
392 args->Append(ExtensionTabUtil::CreateTabValueActive( 392 args->Append(ExtensionTabUtil::CreateTabValueActive(
393 web_contents, active)); 393 web_contents,
394 active,
395 profile->GetExtensionService()->extensions()->GetByID(extension_id)));
394 if (!extension_id.empty()) { 396 if (!extension_id.empty()) {
395 DispatchEventToExtension(profile, extension_id, event_name, args.Pass(), 397 DispatchEventToExtension(profile, extension_id, event_name, args.Pass(),
396 user_gesture); 398 user_gesture);
397 } else { 399 } else {
398 DispatchEvent(profile, event_name, args.Pass(), user_gesture); 400 DispatchEvent(profile, event_name, args.Pass(), user_gesture);
399 } 401 }
400 } 402 }
401 403
402 void BrowserEventRouter::DispatchSimpleBrowserEvent( 404 void BrowserEventRouter::DispatchSimpleBrowserEvent(
403 Profile* profile, const int window_id, const char* event_name) { 405 Profile* profile, const int window_id, const char* event_name) {
(...skipping 16 matching lines...) Expand all
420 // changed. Send a notification to the extension. 422 // changed. Send a notification to the extension.
421 scoped_ptr<ListValue> args(new ListValue()); 423 scoped_ptr<ListValue> args(new ListValue());
422 424
423 // First arg: The id of the tab that changed. 425 // First arg: The id of the tab that changed.
424 args->Append(Value::CreateIntegerValue(ExtensionTabUtil::GetTabId(contents))); 426 args->Append(Value::CreateIntegerValue(ExtensionTabUtil::GetTabId(contents)));
425 427
426 // Second arg: An object containing the changes to the tab state. 428 // Second arg: An object containing the changes to the tab state.
427 args->Append(changed_properties); 429 args->Append(changed_properties);
428 430
429 // Third arg: An object containing the state of the tab. 431 // Third arg: An object containing the state of the tab.
430 args->Append(ExtensionTabUtil::CreateTabValue(contents)); 432 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
433 args->Append(ExtensionTabUtil::CreateTabValue(contents, NULL /*extension*/));
431 434
432 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
433 DispatchEvent(profile, events::kOnTabUpdated, args.Pass(), 435 DispatchEvent(profile, events::kOnTabUpdated, args.Pass(),
434 EventRouter::USER_GESTURE_UNKNOWN); 436 EventRouter::USER_GESTURE_UNKNOWN);
435 } 437 }
436 438
437 BrowserEventRouter::TabEntry* BrowserEventRouter::GetTabEntry( 439 BrowserEventRouter::TabEntry* BrowserEventRouter::GetTabEntry(
438 const WebContents* contents) { 440 const WebContents* contents) {
439 int tab_id = ExtensionTabUtil::GetTabId(contents); 441 int tab_id = ExtensionTabUtil::GetTabId(contents);
440 std::map<int, TabEntry>::iterator i = tab_entries_.find(tab_id); 442 std::map<int, TabEntry>::iterator i = tab_entries_.find(tab_id);
441 if (tab_entries_.end() == i) 443 if (tab_entries_.end() == i)
442 return NULL; 444 return NULL;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 DispatchEventWithTab(profile, 586 DispatchEventWithTab(profile,
585 extension_action.extension_id(), 587 extension_action.extension_id(),
586 event_name, 588 event_name,
587 tab_contents->web_contents(), 589 tab_contents->web_contents(),
588 true, 590 true,
589 EventRouter::USER_GESTURE_ENABLED); 591 EventRouter::USER_GESTURE_ENABLED);
590 } 592 }
591 } 593 }
592 594
593 } // namespace extensions 595 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698