OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/extensions/location_bar_controller.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "chrome/browser/extensions/active_script_controller.h" | |
9 #include "chrome/browser/extensions/extension_action.h" | |
10 #include "chrome/browser/extensions/page_action_controller.h" | |
11 #include "chrome/common/extensions/api/extension_action/action_info.h" | |
12 #include "content/public/browser/invalidate_type.h" | |
13 #include "content/public/browser/web_contents.h" | |
14 #include "extensions/browser/extension_registry.h" | |
15 | |
16 namespace extensions { | |
17 | |
18 LocationBarController::LocationBarController( | |
19 content::WebContents* web_contents) | |
20 : web_contents_(web_contents), | |
21 active_script_controller_(new ActiveScriptController(web_contents_)), | |
22 page_action_controller_(new PageActionController(web_contents_)) { | |
23 } | |
24 | |
25 LocationBarController::~LocationBarController() { | |
26 } | |
27 | |
28 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
| |
29 std::vector<ExtensionAction*> current_actions; | |
30 | |
31 std::vector<ExtensionAction*> current_scripts = | |
32 active_script_controller_->GetCurrentActions(); | |
33 current_actions.insert( | |
34 current_actions.end(), current_scripts.begin(), current_scripts.end()); | |
35 | |
36 std::vector<ExtensionAction*> current_page_actions = | |
37 page_action_controller_->GetCurrentActions(); | |
38 current_actions.insert(current_actions.end(), | |
39 current_page_actions.begin(), | |
40 current_page_actions.end()); | |
41 | |
42 return current_actions; | |
43 } | |
44 | |
45 LocationBarController::Action LocationBarController::OnClicked( | |
46 const ExtensionAction* action, MouseButton button) { | |
47 const Extension* extension = | |
48 ExtensionRegistry::Get(web_contents_->GetBrowserContext()) | |
49 ->enabled_extensions().GetByID(action->extension_id()); | |
50 CHECK(extension); | |
51 | |
52 if (action->action_type() == ActionInfo::TYPE_PAGE) | |
53 return page_action_controller_->OnClicked(extension, button); | |
54 else if (action->action_type() == ActionInfo::TYPE_ACTIVE_SCRIPT) | |
55 return active_script_controller_->OnClicked(extension, button); | |
56 else | |
57 NOTREACHED(); | |
58 return ACTION_NONE; | |
59 } | |
60 | |
61 void LocationBarController::NotifyChange() { | |
62 web_contents_->NotifyNavigationStateChanged( | |
63 content::INVALIDATE_TYPE_PAGE_ACTIONS); | |
64 } | |
65 | |
66 } // namespace extensions | |
OLD | NEW |