OLD | NEW |
---|---|
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 "ios/chrome/browser/infobars/infobar_manager_impl.h" | 5 #include "ios/chrome/browser/infobars/infobar_manager_impl.h" |
6 | 6 |
7 #include "components/infobars/core/confirm_infobar_delegate.h" | 7 #include "components/infobars/core/confirm_infobar_delegate.h" |
8 #include "components/infobars/core/infobar.h" | 8 #include "components/infobars/core/infobar.h" |
9 #include "components/infobars/core/infobar_delegate.h" | 9 #include "components/infobars/core/infobar_delegate.h" |
10 #include "ios/chrome/browser/infobars/infobar_utils.h" | 10 #include "ios/chrome/browser/infobars/infobar_utils.h" |
11 #include "ios/web/public/load_committed_details.h" | 11 #include "ios/web/public/load_committed_details.h" |
12 #include "ios/web/public/navigation_item.h" | 12 #include "ios/web/public/navigation_item.h" |
13 #include "ios/web/public/navigation_manager.h" | 13 #include "ios/web/public/navigation_manager.h" |
14 #include "ios/web/public/web_state/web_state.h" | 14 #include "ios/web/public/web_state/web_state.h" |
15 #include "ui/base/page_transition_types.h" | 15 #include "ui/base/page_transition_types.h" |
16 | 16 |
17 DEFINE_WEB_STATE_USER_DATA_KEY(InfoBarManagerImpl); | 17 DEFINE_WEB_STATE_USER_DATA_KEY(InfoBarManagerImpl); |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 infobars::InfoBarDelegate::NavigationDetails | 21 infobars::InfoBarDelegate::NavigationDetails |
22 NavigationDetailsFromLoadCommittedDetails( | 22 NavigationDetailsFromLoadCommittedDetails( |
23 const web::LoadCommittedDetails& load_details) { | 23 const web::LoadCommittedDetails& load_details) { |
24 infobars::InfoBarDelegate::NavigationDetails navigation_details; | |
Peter Kasting
2015/06/05 03:02:39
I reordered the code here so as to match the simil
| |
25 navigation_details.entry_id = load_details.item->GetUniqueID(); | |
24 const ui::PageTransition transition = load_details.item->GetTransitionType(); | 26 const ui::PageTransition transition = load_details.item->GetTransitionType(); |
25 infobars::InfoBarDelegate::NavigationDetails navigation_details; | 27 navigation_details.is_navigation_to_different_page = |
26 navigation_details.is_main_frame = ui::PageTransitionIsMainFrame(transition); | 28 ui::PageTransitionIsMainFrame(transition) && !load_details.is_in_page; |
29 // web::LoadCommittedDetails doesn't store this information, default to false. | |
30 navigation_details.did_replace_entry = false; | |
27 navigation_details.is_redirect = ui::PageTransitionIsRedirect(transition); | 31 navigation_details.is_redirect = ui::PageTransitionIsRedirect(transition); |
28 navigation_details.is_reload = | |
29 ui::PageTransitionCoreTypeIs(transition, ui::PAGE_TRANSITION_RELOAD); | |
30 | |
31 // web::LoadCommittedDetails don't store this information, default to false. | |
32 navigation_details.did_replace_entry = false; | |
33 navigation_details.entry_id = load_details.item->GetUniqueID(); | |
34 navigation_details.is_navigation_to_different_page = | |
35 navigation_details.is_main_frame && !load_details.is_in_page; | |
36 | 32 |
37 return navigation_details; | 33 return navigation_details; |
38 } | 34 } |
39 | 35 |
40 } // namespace | 36 } // namespace |
41 | 37 |
42 // static | 38 // static |
43 web::WebState* InfoBarManagerImpl::WebStateFromInfoBar( | 39 web::WebState* InfoBarManagerImpl::WebStateFromInfoBar( |
44 infobars::InfoBar* infobar) { | 40 infobars::InfoBar* infobar) { |
45 if (!infobar || !infobar->owner()) | 41 if (!infobar || !infobar->owner()) |
(...skipping 27 matching lines...) Expand all Loading... | |
73 } | 69 } |
74 | 70 |
75 void InfoBarManagerImpl::WebStateDestroyed() { | 71 void InfoBarManagerImpl::WebStateDestroyed() { |
76 // The WebState is going away; be aggressively paranoid and delete this | 72 // The WebState is going away; be aggressively paranoid and delete this |
77 // InfoBarManagerImpl lest other parts of the system attempt to add infobars | 73 // InfoBarManagerImpl lest other parts of the system attempt to add infobars |
78 // or use it otherwise during the destruction. | 74 // or use it otherwise during the destruction. |
79 web_state()->RemoveUserData(UserDataKey()); | 75 web_state()->RemoveUserData(UserDataKey()); |
80 // That was the equivalent of "delete this". This object is now destroyed; | 76 // That was the equivalent of "delete this". This object is now destroyed; |
81 // returning from this function is the only safe thing to do. | 77 // returning from this function is the only safe thing to do. |
82 } | 78 } |
OLD | NEW |