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

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

Issue 1363463002: [Extensions Toolbar] Add a finch config for the redesign (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Finnur's Created 5 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
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 <algorithm> 7 #include <algorithm>
8 8
9 #include "chrome/browser/extensions/active_script_controller.h" 9 #include "chrome/browser/extensions/active_script_controller.h"
10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
(...skipping 12 matching lines...) Expand all
23 namespace extensions { 23 namespace extensions {
24 24
25 LocationBarController::LocationBarController( 25 LocationBarController::LocationBarController(
26 content::WebContents* web_contents) 26 content::WebContents* web_contents)
27 : web_contents_(web_contents), 27 : web_contents_(web_contents),
28 browser_context_(web_contents->GetBrowserContext()), 28 browser_context_(web_contents->GetBrowserContext()),
29 action_manager_(ExtensionActionManager::Get(browser_context_)), 29 action_manager_(ExtensionActionManager::Get(browser_context_)),
30 should_show_page_actions_( 30 should_show_page_actions_(
31 !FeatureSwitch::extension_action_redesign()->IsEnabled()), 31 !FeatureSwitch::extension_action_redesign()->IsEnabled()),
32 extension_registry_observer_(this) { 32 extension_registry_observer_(this) {
33 if (should_show_page_actions_) 33 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
34 extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
35 } 34 }
36 35
37 LocationBarController::~LocationBarController() { 36 LocationBarController::~LocationBarController() {
38 } 37 }
39 38
40 std::vector<ExtensionAction*> LocationBarController::GetCurrentActions() { 39 std::vector<ExtensionAction*> LocationBarController::GetCurrentActions() {
41 const ExtensionSet& extensions = 40 const ExtensionSet& extensions =
42 ExtensionRegistry::Get(browser_context_)->enabled_extensions(); 41 ExtensionRegistry::Get(browser_context_)->enabled_extensions();
43 std::vector<ExtensionAction*> current_actions; 42 std::vector<ExtensionAction*> current_actions;
44 if (!should_show_page_actions_) 43 if (!should_show_page_actions_)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 ->permissions_data() 85 ->permissions_data()
87 ->HasAPIPermission( 86 ->HasAPIPermission(
88 extensions::APIPermission::kBookmarkManagerPrivate); 87 extensions::APIPermission::kBookmarkManagerPrivate);
89 }); 88 });
90 return current_actions; 89 return current_actions;
91 } 90 }
92 91
93 void LocationBarController::OnExtensionLoaded( 92 void LocationBarController::OnExtensionLoaded(
94 content::BrowserContext* browser_context, 93 content::BrowserContext* browser_context,
95 const Extension* extension) { 94 const Extension* extension) {
96 if (action_manager_->GetPageAction(*extension)) { 95 if (should_show_page_actions_ && action_manager_->GetPageAction(*extension)) {
97 ExtensionActionAPI::Get(browser_context)-> 96 ExtensionActionAPI::Get(browser_context)->
98 NotifyPageActionsChanged(web_contents_); 97 NotifyPageActionsChanged(web_contents_);
99 } 98 }
100 99
101 // We might also need to update the location bar if the extension can remove 100 // We might also need to update the location bar if the extension can remove
102 // the bookmark star. 101 // the bookmark star.
103 if (UIOverrides::RemovesBookmarkButton(extension)) { 102 if (UIOverrides::RemovesBookmarkButton(extension)) {
104 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); 103 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
105 // In a perfect world, this can never be NULL. Unfortunately, since a 104 // In a perfect world, this can never be NULL. Unfortunately, since a
106 // LocationBarController is attached to most WebContents, we can't make that 105 // LocationBarController is attached to most WebContents, we can't make that
107 // guarantee. 106 // guarantee.
108 if (!browser) 107 if (!browser)
109 return; 108 return;
110 // window() can be NULL if this is called before CreateBrowserWindow() 109 // window() can be NULL if this is called before CreateBrowserWindow()
111 // completes, and there won't be a location bar if the window has no toolbar 110 // completes, and there won't be a location bar if the window has no toolbar
112 // (e.g., and app window). 111 // (e.g., and app window).
113 LocationBar* location_bar = 112 LocationBar* location_bar =
114 browser->window() ? browser->window()->GetLocationBar() : NULL; 113 browser->window() ? browser->window()->GetLocationBar() : NULL;
115 if (!location_bar) 114 if (!location_bar)
116 return; 115 return;
117 location_bar->UpdateBookmarkStarVisibility(); 116 location_bar->UpdateBookmarkStarVisibility();
118 } 117 }
119 } 118 }
120 119
121 void LocationBarController::OnExtensionUnloaded( 120 void LocationBarController::OnExtensionUnloaded(
122 content::BrowserContext* browser_context, 121 content::BrowserContext* browser_context,
123 const Extension* extension, 122 const Extension* extension,
124 UnloadedExtensionInfo::Reason reason) { 123 UnloadedExtensionInfo::Reason reason) {
125 if (action_manager_->GetPageAction(*extension)) { 124 if (should_show_page_actions_ && action_manager_->GetPageAction(*extension)) {
126 ExtensionActionAPI::Get(browser_context)-> 125 ExtensionActionAPI::Get(browser_context)->
127 NotifyPageActionsChanged(web_contents_); 126 NotifyPageActionsChanged(web_contents_);
128 } 127 }
129 } 128 }
130 129
131 } // namespace extensions 130 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698