Index: chrome/browser/extensions/location_bar_controller.cc |
diff --git a/chrome/browser/extensions/location_bar_controller.cc b/chrome/browser/extensions/location_bar_controller.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..a23cab1d79afabf324a8e76f0393fecc7202641a |
--- /dev/null |
+++ b/chrome/browser/extensions/location_bar_controller.cc |
@@ -0,0 +1,66 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/extensions/location_bar_controller.h" |
+ |
+#include "base/logging.h" |
+#include "chrome/browser/extensions/active_script_controller.h" |
+#include "chrome/browser/extensions/extension_action.h" |
+#include "chrome/browser/extensions/page_action_controller.h" |
+#include "chrome/common/extensions/api/extension_action/action_info.h" |
+#include "content/public/browser/invalidate_type.h" |
+#include "content/public/browser/web_contents.h" |
+#include "extensions/browser/extension_registry.h" |
+ |
+namespace extensions { |
+ |
+LocationBarController::LocationBarController( |
+ content::WebContents* web_contents) |
+ : web_contents_(web_contents), |
+ active_script_controller_(new ActiveScriptController(web_contents_)), |
+ page_action_controller_(new PageActionController(web_contents_)) { |
+} |
+ |
+LocationBarController::~LocationBarController() { |
+} |
+ |
+std::vector<ExtensionAction*> LocationBarController::GetCurrentActions() { |
not at google - send to devlin
2014/05/07 22:49:02
To engineer this in a way that doesn't depend on o
Devlin
2014/05/08 18:15:46
Talked about offline, and decided to restructure t
|
+ std::vector<ExtensionAction*> current_actions; |
+ |
+ std::vector<ExtensionAction*> current_scripts = |
+ active_script_controller_->GetCurrentActions(); |
+ current_actions.insert( |
+ current_actions.end(), current_scripts.begin(), current_scripts.end()); |
+ |
+ std::vector<ExtensionAction*> current_page_actions = |
+ page_action_controller_->GetCurrentActions(); |
+ current_actions.insert(current_actions.end(), |
+ current_page_actions.begin(), |
+ current_page_actions.end()); |
+ |
+ return current_actions; |
+} |
+ |
+LocationBarController::Action LocationBarController::OnClicked( |
+ const ExtensionAction* action, MouseButton button) { |
+ const Extension* extension = |
+ ExtensionRegistry::Get(web_contents_->GetBrowserContext()) |
+ ->enabled_extensions().GetByID(action->extension_id()); |
+ CHECK(extension); |
+ |
+ if (action->action_type() == ActionInfo::TYPE_PAGE) |
+ return page_action_controller_->OnClicked(extension, button); |
+ else if (action->action_type() == ActionInfo::TYPE_ACTIVE_SCRIPT) |
+ return active_script_controller_->OnClicked(extension, button); |
+ else |
+ NOTREACHED(); |
+ return ACTION_NONE; |
+} |
+ |
+void LocationBarController::NotifyChange() { |
+ web_contents_->NotifyNavigationStateChanged( |
+ content::INVALIDATE_TYPE_PAGE_ACTIONS); |
+} |
+ |
+} // namespace extensions |