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

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

Issue 496403003: Remove NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase 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 | Annotate | Revision Log
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/api/extension_action/extension_action_api.h"
9 #include "chrome/browser/extensions/page_action_controller.h" 10 #include "chrome/browser/extensions/page_action_controller.h"
10 #include "chrome/browser/ui/browser_finder.h"
11 #include "chrome/browser/ui/browser_window.h"
12 #include "chrome/browser/ui/location_bar/location_bar.h"
13 #include "chrome/common/extensions/api/extension_action/action_info.h" 11 #include "chrome/common/extensions/api/extension_action/action_info.h"
14 #include "content/public/browser/invalidate_type.h"
15 #include "content/public/browser/navigation_details.h" 12 #include "content/public/browser/navigation_details.h"
16 #include "content/public/browser/notification_service.h"
17 #include "content/public/browser/notification_source.h"
18 #include "content/public/browser/web_contents.h" 13 #include "content/public/browser/web_contents.h"
19 #include "extensions/browser/extension_registry.h" 14 #include "extensions/browser/extension_registry.h"
20 #include "extensions/browser/notification_types.h"
21 15
22 namespace extensions { 16 namespace extensions {
23 17
24 LocationBarController::LocationBarController( 18 LocationBarController::LocationBarController(
25 content::WebContents* web_contents) 19 content::WebContents* web_contents)
26 : WebContentsObserver(web_contents), 20 : WebContentsObserver(web_contents),
27 web_contents_(web_contents), 21 web_contents_(web_contents),
28 active_script_controller_(new ActiveScriptController(web_contents_)), 22 active_script_controller_(new ActiveScriptController(web_contents_)),
29 page_action_controller_(new PageActionController(web_contents_)), 23 page_action_controller_(new PageActionController(web_contents_)),
30 extension_registry_observer_(this) { 24 extension_registry_observer_(this) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 ExtensionAction::ShowAction active_script_action = 65 ExtensionAction::ShowAction active_script_action =
72 active_script_controller_->GetActionForExtension(extension) ? 66 active_script_controller_->GetActionForExtension(extension) ?
73 active_script_controller_->OnClicked(extension) : 67 active_script_controller_->OnClicked(extension) :
74 ExtensionAction::ACTION_NONE; 68 ExtensionAction::ACTION_NONE;
75 69
76 // PageAction response takes priority. 70 // PageAction response takes priority.
77 return page_action != ExtensionAction::ACTION_NONE ? page_action : 71 return page_action != ExtensionAction::ACTION_NONE ? page_action :
78 active_script_action; 72 active_script_action;
79 } 73 }
80 74
81 // static
82 void LocationBarController::NotifyChange(content::WebContents* web_contents) {
83 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
84 if (!browser)
85 return;
86 LocationBar* location_bar =
87 browser->window() ? browser->window()->GetLocationBar() : NULL;
88 if (!location_bar)
89 return;
90 location_bar->UpdatePageActions();
91
92 content::NotificationService::current()->Notify(
93 NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED,
94 content::Source<content::WebContents>(web_contents),
95 content::NotificationService::NoDetails());
96 }
97
98 void LocationBarController::DidNavigateMainFrame( 75 void LocationBarController::DidNavigateMainFrame(
99 const content::LoadCommittedDetails& details, 76 const content::LoadCommittedDetails& details,
100 const content::FrameNavigateParams& params) { 77 const content::FrameNavigateParams& params) {
101 if (details.is_in_page) 78 if (details.is_in_page)
102 return; 79 return;
103 80
104 page_action_controller_->OnNavigated(); 81 page_action_controller_->OnNavigated();
105 active_script_controller_->OnNavigated(); 82 active_script_controller_->OnNavigated();
106 } 83 }
107 84
108 void LocationBarController::OnExtensionUnloaded( 85 void LocationBarController::OnExtensionUnloaded(
109 content::BrowserContext* browser_context, 86 content::BrowserContext* browser_context,
110 const Extension* extension, 87 const Extension* extension,
111 UnloadedExtensionInfo::Reason reason) { 88 UnloadedExtensionInfo::Reason reason) {
112 bool should_update = false; 89 bool should_update = false;
113 if (page_action_controller_->GetActionForExtension(extension)) { 90 if (page_action_controller_->GetActionForExtension(extension)) {
114 page_action_controller_->OnExtensionUnloaded(extension); 91 page_action_controller_->OnExtensionUnloaded(extension);
115 should_update = true; 92 should_update = true;
116 } 93 }
117 if (active_script_controller_->GetActionForExtension(extension)) { 94 if (active_script_controller_->GetActionForExtension(extension)) {
118 active_script_controller_->OnExtensionUnloaded(extension); 95 active_script_controller_->OnExtensionUnloaded(extension);
119 should_update = true; 96 should_update = true;
120 } 97 }
121 98
122 if (should_update) 99 if (should_update) {
123 NotifyChange(web_contents()); 100 ExtensionActionAPI::Get(browser_context)->
101 NotifyPageActionsChanged(web_contents());
102 }
124 } 103 }
125 104
126 } // namespace extensions 105 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698