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

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

Issue 10917026: Switch Extensions::TabHelper to use WebContents, WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase only Created 8 years, 3 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 | Annotate | Revision Log
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/menu_manager.h" 5 #include "chrome/browser/extensions/menu_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 if (params.selection_text.length() > 0) 635 if (params.selection_text.length() > 0)
636 properties->SetString("selectionText", params.selection_text); 636 properties->SetString("selectionText", params.selection_text);
637 637
638 properties->SetBoolean("editable", params.is_editable); 638 properties->SetBoolean("editable", params.is_editable);
639 639
640 args->Append(properties); 640 args->Append(properties);
641 641
642 // Add the tab info to the argument list. 642 // Add the tab info to the argument list.
643 // No tab info in a platform app. 643 // No tab info in a platform app.
644 if (!extension || !extension->is_platform_app()) { 644 if (!extension || !extension->is_platform_app()) {
645 // Note: web_contents only NULL in unit tests :( 645 // Note: web_contents are NULL in unit tests :(
646 if (web_contents) 646 if (web_contents)
647 args->Append(ExtensionTabUtil::CreateTabValue(web_contents, extension)); 647 args->Append(ExtensionTabUtil::CreateTabValue(web_contents, extension));
648 else 648 else
649 args->Append(new DictionaryValue()); 649 args->Append(new DictionaryValue());
650 } 650 }
651 651
652 if (item->type() == MenuItem::CHECKBOX || 652 if (item->type() == MenuItem::CHECKBOX ||
653 item->type() == MenuItem::RADIO) { 653 item->type() == MenuItem::RADIO) {
654 bool was_checked = item->checked(); 654 bool was_checked = item->checked();
655 properties->SetBoolean("wasChecked", was_checked); 655 properties->SetBoolean("wasChecked", was_checked);
656 656
657 // RADIO items always get set to true when you click on them, but CHECKBOX 657 // RADIO items always get set to true when you click on them, but CHECKBOX
658 // items get their state toggled. 658 // items get their state toggled.
659 bool checked = 659 bool checked =
660 (item->type() == MenuItem::RADIO) ? true : !was_checked; 660 (item->type() == MenuItem::RADIO) ? true : !was_checked;
661 661
662 item->SetChecked(checked); 662 item->SetChecked(checked);
663 properties->SetBoolean("checked", item->checked()); 663 properties->SetBoolean("checked", item->checked());
664 664
665 if (extension) 665 if (extension)
666 WriteToStorage(extension); 666 WriteToStorage(extension);
667 } 667 }
668 668
669 TabContents* tab_contents = web_contents ? 669 // Note: web_contents are NULL in unit tests :(
670 TabContents::FromWebContents(web_contents) : NULL; 670 if (web_contents && extensions::TabHelper::FromWebContents(web_contents)) {
671 if (tab_contents && extension) { 671 extensions::TabHelper::FromWebContents(web_contents)->
672 tab_contents->extension_tab_helper()->active_tab_permission_manager()-> 672 active_tab_permission_manager()->GrantIfRequested(extension);
673 GrantIfRequested(extension);
674 } 673 }
675 674
676 event_router->DispatchEventToExtension( 675 event_router->DispatchEventToExtension(
677 item->extension_id(), event_names::kOnContextMenus, 676 item->extension_id(), event_names::kOnContextMenus,
678 scoped_ptr<ListValue>(args->DeepCopy()), profile, GURL(), 677 scoped_ptr<ListValue>(args->DeepCopy()), profile, GURL(),
679 EventRouter::USER_GESTURE_ENABLED); 678 EventRouter::USER_GESTURE_ENABLED);
680 event_router->DispatchEventToExtension( 679 event_router->DispatchEventToExtension(
681 item->extension_id(), event_names::kOnContextMenuClicked, 680 item->extension_id(), event_names::kOnContextMenuClicked,
682 args.Pass(), profile, GURL(), 681 args.Pass(), profile, GURL(),
683 EventRouter::USER_GESTURE_ENABLED); 682 EventRouter::USER_GESTURE_ENABLED);
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 if (uid < other.uid) 840 if (uid < other.uid)
842 return true; 841 return true;
843 if (uid == other.uid) 842 if (uid == other.uid)
844 return string_uid < other.string_uid; 843 return string_uid < other.string_uid;
845 } 844 }
846 } 845 }
847 return false; 846 return false;
848 } 847 }
849 848
850 } // namespace extensions 849 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | chrome/browser/extensions/page_action_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698