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

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

Issue 540483002: Fix regression in showing bookmark star when an extension should override it (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/extensions/active_script_controller.h" 7 #include "chrome/browser/extensions/active_script_controller.h"
8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
9 #include "chrome/browser/extensions/extension_action_manager.h" 9 #include "chrome/browser/extensions/extension_action_manager.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_finder.h"
12 #include "chrome/browser/ui/browser_window.h"
13 #include "chrome/browser/ui/location_bar/location_bar.h"
14 #include "chrome/common/extensions/manifest_handlers/ui_overrides_handler.h"
10 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
11 #include "extensions/browser/extension_registry.h" 16 #include "extensions/browser/extension_registry.h"
12 #include "extensions/common/feature_switch.h" 17 #include "extensions/common/feature_switch.h"
13 18
14 namespace extensions { 19 namespace extensions {
15 20
16 LocationBarController::LocationBarController( 21 LocationBarController::LocationBarController(
17 content::WebContents* web_contents) 22 content::WebContents* web_contents)
18 : web_contents_(web_contents), 23 : web_contents_(web_contents),
19 browser_context_(web_contents->GetBrowserContext()), 24 browser_context_(web_contents->GetBrowserContext()),
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return current_actions; 72 return current_actions;
68 } 73 }
69 74
70 void LocationBarController::OnExtensionLoaded( 75 void LocationBarController::OnExtensionLoaded(
71 content::BrowserContext* browser_context, 76 content::BrowserContext* browser_context,
72 const Extension* extension) { 77 const Extension* extension) {
73 if (action_manager_->GetPageAction(*extension)) { 78 if (action_manager_->GetPageAction(*extension)) {
74 ExtensionActionAPI::Get(browser_context)-> 79 ExtensionActionAPI::Get(browser_context)->
75 NotifyPageActionsChanged(web_contents_); 80 NotifyPageActionsChanged(web_contents_);
76 } 81 }
82
83 // We might also need to update the location bar if the extension can remove
84 // the bookmark star.
85 if (UIOverrides::RemovesBookmarkButton(extension)) {
86 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
87 // In a perfect world, this can never be NULL. Unfortunately, since a
88 // LocationBarController is attached to most WebContents, we can't make that
89 // guarantee.
90 if (!browser)
91 return;
92 // window() can be NULL if this is called before CreateBrowserWindow()
93 // completes, and there won't be a location bar if the window has no toolbar
94 // (e.g., and app window).
95 LocationBar* location_bar =
96 browser->window() ? browser->window()->GetLocationBar() : NULL;
97 if (!location_bar)
98 return;
99 location_bar->UpdateBookmarkStarVisibility();
100 }
77 } 101 }
78 102
79 void LocationBarController::OnExtensionUnloaded( 103 void LocationBarController::OnExtensionUnloaded(
80 content::BrowserContext* browser_context, 104 content::BrowserContext* browser_context,
81 const Extension* extension, 105 const Extension* extension,
82 UnloadedExtensionInfo::Reason reason) { 106 UnloadedExtensionInfo::Reason reason) {
83 if (action_manager_->GetPageAction(*extension)) { 107 if (action_manager_->GetPageAction(*extension)) {
84 ExtensionActionAPI::Get(browser_context)-> 108 ExtensionActionAPI::Get(browser_context)->
85 NotifyPageActionsChanged(web_contents_); 109 NotifyPageActionsChanged(web_contents_);
86 } 110 }
87 } 111 }
88 112
89 } // namespace extensions 113 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698