| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/infobars/infobar_service.h" | 5 #include "chrome/browser/infobars/infobar_service.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "components/infobars/core/infobar.h" | 10 #include "components/infobars/core/infobar.h" |
| 11 #include "content/public/browser/navigation_details.h" | 11 #include "content/public/browser/navigation_details.h" |
| 12 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
| 13 #include "content/public/browser/navigation_handle.h" |
| 13 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
| 14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 15 #include "ui/base/page_transition_types.h" | 16 #include "ui/base/page_transition_types.h" |
| 16 | 17 |
| 17 | 18 |
| 18 DEFINE_WEB_CONTENTS_USER_DATA_KEY(InfoBarService); | 19 DEFINE_WEB_CONTENTS_USER_DATA_KEY(InfoBarService); |
| 19 | 20 |
| 20 // static | 21 // static |
| 21 infobars::InfoBarDelegate::NavigationDetails | 22 infobars::InfoBarDelegate::NavigationDetails |
| 22 InfoBarService::NavigationDetailsFromLoadCommittedDetails( | 23 InfoBarService::NavigationDetailsFromLoadCommittedDetails( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 content::Details<infobars::InfoBar::RemovedDetails>(&removed_details)); | 82 content::Details<infobars::InfoBar::RemovedDetails>(&removed_details)); |
| 82 } | 83 } |
| 83 | 84 |
| 84 // InfoBarService::CreateConfirmInfoBar() is implemented in platform-specific | 85 // InfoBarService::CreateConfirmInfoBar() is implemented in platform-specific |
| 85 // files. | 86 // files. |
| 86 | 87 |
| 87 void InfoBarService::RenderProcessGone(base::TerminationStatus status) { | 88 void InfoBarService::RenderProcessGone(base::TerminationStatus status) { |
| 88 RemoveAllInfoBars(true); | 89 RemoveAllInfoBars(true); |
| 89 } | 90 } |
| 90 | 91 |
| 91 void InfoBarService::DidStartNavigationToPendingEntry( | 92 void InfoBarService::DidStartNavigation( |
| 92 const GURL& url, | 93 content::NavigationHandle* navigation_handle) { |
| 93 content::ReloadType reload_type) { | 94 if (!navigation_handle->IsInMainFrame() || navigation_handle->IsSamePage()) |
| 95 return; |
| 96 |
| 94 ignore_next_reload_ = false; | 97 ignore_next_reload_ = false; |
| 95 } | 98 } |
| 96 | 99 |
| 97 void InfoBarService::NavigationEntryCommitted( | 100 void InfoBarService::NavigationEntryCommitted( |
| 98 const content::LoadCommittedDetails& load_details) { | 101 const content::LoadCommittedDetails& load_details) { |
| 99 const bool ignore = ignore_next_reload_ && | 102 const bool ignore = ignore_next_reload_ && |
| 100 ui::PageTransitionCoreTypeIs(load_details.entry->GetTransitionType(), | 103 ui::PageTransitionCoreTypeIs(load_details.entry->GetTransitionType(), |
| 101 ui::PAGE_TRANSITION_RELOAD); | 104 ui::PAGE_TRANSITION_RELOAD); |
| 102 ignore_next_reload_ = false; | 105 ignore_next_reload_ = false; |
| 103 if (!ignore) | 106 if (!ignore) |
| (...skipping 14 matching lines...) Expand all Loading... |
| 118 // A normal user click on an infobar URL will result in a CURRENT_TAB | 121 // A normal user click on an infobar URL will result in a CURRENT_TAB |
| 119 // disposition; turn that into a NEW_FOREGROUND_TAB so that we don't end up | 122 // disposition; turn that into a NEW_FOREGROUND_TAB so that we don't end up |
| 120 // smashing the page the user is looking at. | 123 // smashing the page the user is looking at. |
| 121 web_contents()->OpenURL( | 124 web_contents()->OpenURL( |
| 122 content::OpenURLParams(url, content::Referrer(), | 125 content::OpenURLParams(url, content::Referrer(), |
| 123 (disposition == WindowOpenDisposition::CURRENT_TAB) | 126 (disposition == WindowOpenDisposition::CURRENT_TAB) |
| 124 ? WindowOpenDisposition::NEW_FOREGROUND_TAB | 127 ? WindowOpenDisposition::NEW_FOREGROUND_TAB |
| 125 : disposition, | 128 : disposition, |
| 126 ui::PAGE_TRANSITION_LINK, false)); | 129 ui::PAGE_TRANSITION_LINK, false)); |
| 127 } | 130 } |
| OLD | NEW |