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

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

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

Powered by Google App Engine
This is Rietveld 408576698