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

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: Latest master for CQ 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 | 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 19 matching lines...) Expand all
50 page_action_controller_->GetActionForExtension(iter->get()); 44 page_action_controller_->GetActionForExtension(iter->get());
51 if (!action) 45 if (!action)
52 action = active_script_controller_->GetActionForExtension(iter->get()); 46 action = active_script_controller_->GetActionForExtension(iter->get());
53 if (action) 47 if (action)
54 current_actions.push_back(action); 48 current_actions.push_back(action);
55 } 49 }
56 50
57 return current_actions; 51 return current_actions;
58 } 52 }
59 53
60 // static
61 void LocationBarController::NotifyChange(content::WebContents* web_contents) {
62 Browser* browser = chrome::FindBrowserWithWebContents(web_contents);
63 if (!browser)
64 return;
65 LocationBar* location_bar =
66 browser->window() ? browser->window()->GetLocationBar() : NULL;
67 if (!location_bar)
68 return;
69 location_bar->UpdatePageActions();
70
71 content::NotificationService::current()->Notify(
72 NOTIFICATION_EXTENSION_PAGE_ACTIONS_UPDATED,
73 content::Source<content::WebContents>(web_contents),
74 content::NotificationService::NoDetails());
75 }
76
77 void LocationBarController::DidNavigateMainFrame( 54 void LocationBarController::DidNavigateMainFrame(
78 const content::LoadCommittedDetails& details, 55 const content::LoadCommittedDetails& details,
79 const content::FrameNavigateParams& params) { 56 const content::FrameNavigateParams& params) {
80 if (details.is_in_page) 57 if (details.is_in_page)
81 return; 58 return;
82 59
83 page_action_controller_->OnNavigated(); 60 page_action_controller_->OnNavigated();
84 active_script_controller_->OnNavigated(); 61 active_script_controller_->OnNavigated();
85 } 62 }
86 63
87 void LocationBarController::OnExtensionUnloaded( 64 void LocationBarController::OnExtensionUnloaded(
88 content::BrowserContext* browser_context, 65 content::BrowserContext* browser_context,
89 const Extension* extension, 66 const Extension* extension,
90 UnloadedExtensionInfo::Reason reason) { 67 UnloadedExtensionInfo::Reason reason) {
91 bool should_update = false; 68 bool should_update = false;
92 if (page_action_controller_->GetActionForExtension(extension)) { 69 if (page_action_controller_->GetActionForExtension(extension)) {
93 page_action_controller_->OnExtensionUnloaded(extension); 70 page_action_controller_->OnExtensionUnloaded(extension);
94 should_update = true; 71 should_update = true;
95 } 72 }
96 if (active_script_controller_->GetActionForExtension(extension)) { 73 if (active_script_controller_->GetActionForExtension(extension)) {
97 active_script_controller_->OnExtensionUnloaded(extension); 74 active_script_controller_->OnExtensionUnloaded(extension);
98 should_update = true; 75 should_update = true;
99 } 76 }
100 77
101 if (should_update) 78 if (should_update) {
102 NotifyChange(web_contents()); 79 ExtensionActionAPI::Get(browser_context)->
80 NotifyPageActionsChanged(web_contents());
81 }
103 } 82 }
104 83
105 } // namespace extensions 84 } // 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