OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/page_action_controller.h" | 5 #include "chrome/browser/extensions/page_action_controller.h" |
6 | 6 |
7 #include "chrome/browser/extensions/browser_event_router.h" | 7 #include "chrome/browser/extensions/browser_event_router.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.h" |
10 #include "chrome/browser/extensions/tab_helper.h" | 10 #include "chrome/browser/extensions/tab_helper.h" |
11 #include "chrome/browser/extensions/extension_tab_util.h" | 11 #include "chrome/browser/extensions/extension_tab_util.h" |
12 #include "chrome/browser/sessions/session_id.h" | 12 #include "chrome/browser/sessions/session_id.h" |
13 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
14 #include "chrome/common/extensions/extension_set.h" | 14 #include "chrome/common/extensions/extension_set.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "content/public/browser/invalidate_type.h" | 16 #include "content/public/browser/invalidate_type.h" |
17 #include "content/public/browser/navigation_details.h" | |
17 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
19 | 20 |
20 namespace extensions { | 21 namespace extensions { |
21 | 22 |
22 PageActionController::PageActionController(TabContents* tab_contents) | 23 PageActionController::PageActionController(TabContents* tab_contents) |
23 : content::WebContentsObserver(tab_contents->web_contents()), | 24 : content::WebContentsObserver(tab_contents->web_contents()), |
24 tab_contents_(tab_contents) {} | 25 tab_contents_(tab_contents) {} |
25 | 26 |
26 PageActionController::~PageActionController() {} | 27 PageActionController::~PageActionController() {} |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 } | 80 } |
80 | 81 |
81 void PageActionController::NotifyChange() { | 82 void PageActionController::NotifyChange() { |
82 tab_contents_->web_contents()->NotifyNavigationStateChanged( | 83 tab_contents_->web_contents()->NotifyNavigationStateChanged( |
83 content::INVALIDATE_TYPE_PAGE_ACTIONS); | 84 content::INVALIDATE_TYPE_PAGE_ACTIONS); |
84 } | 85 } |
85 | 86 |
86 void PageActionController::DidNavigateMainFrame( | 87 void PageActionController::DidNavigateMainFrame( |
87 const content::LoadCommittedDetails& details, | 88 const content::LoadCommittedDetails& details, |
88 const content::FrameNavigateParams& params) { | 89 const content::FrameNavigateParams& params) { |
90 if (details.is_in_page) | |
91 return; | |
92 | |
89 const std::vector<ExtensionAction*> current_actions = GetCurrentActions(); | 93 const std::vector<ExtensionAction*> current_actions = GetCurrentActions(); |
not at google - send to devlin
2012/08/06 22:09:19
remind me why we clear page actions on navigation?
Jeffrey Yasskin
2012/08/06 22:24:25
I believe a page action is a statement that an ext
| |
90 | 94 |
91 if (current_actions.empty()) | 95 if (current_actions.empty()) |
92 return; | 96 return; |
93 | 97 |
94 for (size_t i = 0; i < current_actions.size(); ++i) { | 98 for (size_t i = 0; i < current_actions.size(); ++i) { |
95 current_actions[i]->ClearAllValuesForTab( | 99 current_actions[i]->ClearAllValuesForTab( |
96 SessionID::IdForTab(tab_contents_)); | 100 SessionID::IdForTab(tab_contents_)); |
97 } | 101 } |
98 | 102 |
99 NotifyChange(); | 103 NotifyChange(); |
100 } | 104 } |
101 | 105 |
102 ExtensionService* PageActionController::GetExtensionService() const { | 106 ExtensionService* PageActionController::GetExtensionService() const { |
103 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); | 107 return ExtensionSystem::Get(tab_contents_->profile())->extension_service(); |
104 } | 108 } |
105 | 109 |
106 } // namespace extensions | 110 } // namespace extensions |
OLD | NEW |