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

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

Issue 496863003: Consolidate ExtensionAction execution code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/location_bar_controller.h" 5 #include "chrome/browser/extensions/location_bar_controller.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/extensions/active_script_controller.h" 8 #include "chrome/browser/extensions/active_script_controller.h"
9 #include "chrome/browser/extensions/page_action_controller.h" 9 #include "chrome/browser/extensions/page_action_controller.h"
10 #include "chrome/browser/ui/browser_finder.h" 10 #include "chrome/browser/ui/browser_finder.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 page_action_controller_->GetActionForExtension(*iter); 50 page_action_controller_->GetActionForExtension(*iter);
51 if (!action) 51 if (!action)
52 action = active_script_controller_->GetActionForExtension(*iter); 52 action = active_script_controller_->GetActionForExtension(*iter);
53 if (action) 53 if (action)
54 current_actions.push_back(action); 54 current_actions.push_back(action);
55 } 55 }
56 56
57 return current_actions; 57 return current_actions;
58 } 58 }
59 59
60 ExtensionAction::ShowAction LocationBarController::OnClicked(
61 const ExtensionAction* action) {
62 const Extension* extension =
63 ExtensionRegistry::Get(web_contents_->GetBrowserContext())
64 ->enabled_extensions().GetByID(action->extension_id());
65 CHECK(extension) << action->extension_id();
66
67 ExtensionAction::ShowAction page_action =
68 page_action_controller_->GetActionForExtension(extension) ?
69 page_action_controller_->OnClicked(extension) :
70 ExtensionAction::ACTION_NONE;
71 ExtensionAction::ShowAction active_script_action =
72 active_script_controller_->GetActionForExtension(extension) ?
73 active_script_controller_->OnClicked(extension) :
74 ExtensionAction::ACTION_NONE;
75
76 // PageAction response takes priority.
77 return page_action != ExtensionAction::ACTION_NONE ? page_action :
78 active_script_action;
79 }
80
81 // static 60 // static
82 void LocationBarController::NotifyChange(content::WebContents* web_contents) { 61 void LocationBarController::NotifyChange(content::WebContents* web_contents) {
83 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); 62 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
84 if (!browser) 63 if (!browser)
85 return; 64 return;
86 LocationBar* location_bar = 65 LocationBar* location_bar =
87 browser->window() ? browser->window()->GetLocationBar() : NULL; 66 browser->window() ? browser->window()->GetLocationBar() : NULL;
88 if (!location_bar) 67 if (!location_bar)
89 return; 68 return;
90 location_bar->UpdatePageActions(); 69 location_bar->UpdatePageActions();
(...skipping 26 matching lines...) Expand all
117 if (active_script_controller_->GetActionForExtension(extension)) { 96 if (active_script_controller_->GetActionForExtension(extension)) {
118 active_script_controller_->OnExtensionUnloaded(extension); 97 active_script_controller_->OnExtensionUnloaded(extension);
119 should_update = true; 98 should_update = true;
120 } 99 }
121 100
122 if (should_update) 101 if (should_update)
123 NotifyChange(web_contents()); 102 NotifyChange(web_contents());
124 } 103 }
125 104
126 } // namespace extensions 105 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/location_bar_controller.h ('k') | chrome/browser/extensions/page_action_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698