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

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

Issue 454053005: Consolidate ExtensionToolbarModel::Action and LocationBarController::Action (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master for CQ 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
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/extension_action.h"
10 #include "chrome/browser/extensions/page_action_controller.h" 9 #include "chrome/browser/extensions/page_action_controller.h"
11 #include "chrome/common/extensions/api/extension_action/action_info.h" 10 #include "chrome/common/extensions/api/extension_action/action_info.h"
12 #include "content/public/browser/invalidate_type.h" 11 #include "content/public/browser/invalidate_type.h"
13 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
14 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
15 #include "extensions/browser/extension_registry.h" 14 #include "extensions/browser/extension_registry.h"
16 15
17 namespace extensions { 16 namespace extensions {
18 17
19 LocationBarController::LocationBarController( 18 LocationBarController::LocationBarController(
(...skipping 25 matching lines...) Expand all
45 page_action_controller_->GetActionForExtension(*iter); 44 page_action_controller_->GetActionForExtension(*iter);
46 if (!action) 45 if (!action)
47 action = active_script_controller_->GetActionForExtension(*iter); 46 action = active_script_controller_->GetActionForExtension(*iter);
48 if (action) 47 if (action)
49 current_actions.push_back(action); 48 current_actions.push_back(action);
50 } 49 }
51 50
52 return current_actions; 51 return current_actions;
53 } 52 }
54 53
55 LocationBarController::Action LocationBarController::OnClicked( 54 ExtensionAction::ShowAction LocationBarController::OnClicked(
56 const ExtensionAction* action) { 55 const ExtensionAction* action) {
57 const Extension* extension = 56 const Extension* extension =
58 ExtensionRegistry::Get(web_contents_->GetBrowserContext()) 57 ExtensionRegistry::Get(web_contents_->GetBrowserContext())
59 ->enabled_extensions().GetByID(action->extension_id()); 58 ->enabled_extensions().GetByID(action->extension_id());
60 CHECK(extension) << action->extension_id(); 59 CHECK(extension) << action->extension_id();
61 60
62 Action page_action = 61 ExtensionAction::ShowAction page_action =
63 page_action_controller_->GetActionForExtension(extension) ? 62 page_action_controller_->GetActionForExtension(extension) ?
64 page_action_controller_->OnClicked(extension) : 63 page_action_controller_->OnClicked(extension) :
65 ACTION_NONE; 64 ExtensionAction::ACTION_NONE;
66 Action active_script_action = 65 ExtensionAction::ShowAction active_script_action =
67 active_script_controller_->GetActionForExtension(extension) ? 66 active_script_controller_->GetActionForExtension(extension) ?
68 active_script_controller_->OnClicked(extension) : 67 active_script_controller_->OnClicked(extension) :
69 ACTION_NONE; 68 ExtensionAction::ACTION_NONE;
70 69
71 // PageAction response takes priority. 70 // PageAction response takes priority.
72 return page_action != ACTION_NONE ? page_action : active_script_action; 71 return page_action != ExtensionAction::ACTION_NONE ? page_action :
72 active_script_action;
73 } 73 }
74 74
75 // static 75 // static
76 void LocationBarController::NotifyChange(content::WebContents* web_contents) { 76 void LocationBarController::NotifyChange(content::WebContents* web_contents) {
77 web_contents->NotifyNavigationStateChanged( 77 web_contents->NotifyNavigationStateChanged(
78 content::INVALIDATE_TYPE_PAGE_ACTIONS); 78 content::INVALIDATE_TYPE_PAGE_ACTIONS);
79 } 79 }
80 80
81 void LocationBarController::DidNavigateMainFrame( 81 void LocationBarController::DidNavigateMainFrame(
82 const content::LoadCommittedDetails& details, 82 const content::LoadCommittedDetails& details,
(...skipping 17 matching lines...) Expand all
100 if (active_script_controller_->GetActionForExtension(extension)) { 100 if (active_script_controller_->GetActionForExtension(extension)) {
101 active_script_controller_->OnExtensionUnloaded(extension); 101 active_script_controller_->OnExtensionUnloaded(extension);
102 should_update = true; 102 should_update = true;
103 } 103 }
104 104
105 if (should_update) 105 if (should_update)
106 NotifyChange(web_contents()); 106 NotifyChange(web_contents());
107 } 107 }
108 108
109 } // namespace extensions 109 } // 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