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/chrome_switches.h" |
9 #include "chrome/common/render_messages.h" | 10 #include "chrome/common/render_messages.h" |
10 #include "components/infobars/core/infobar.h" | 11 #include "components/infobars/core/infobar.h" |
11 #include "content/public/browser/navigation_details.h" | 12 #include "content/public/browser/navigation_details.h" |
12 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
13 #include "content/public/browser/navigation_handle.h" | 14 #include "content/public/browser/navigation_handle.h" |
14 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
15 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
16 #include "ui/base/page_transition_types.h" | 17 #include "ui/base/page_transition_types.h" |
17 | 18 |
18 | 19 |
(...skipping 22 matching lines...) Expand all Loading... |
41 return NULL; | 42 return NULL; |
42 InfoBarService* infobar_service = | 43 InfoBarService* infobar_service = |
43 static_cast<InfoBarService*>(infobar->owner()); | 44 static_cast<InfoBarService*>(infobar->owner()); |
44 return infobar_service->web_contents(); | 45 return infobar_service->web_contents(); |
45 } | 46 } |
46 | 47 |
47 InfoBarService::InfoBarService(content::WebContents* web_contents) | 48 InfoBarService::InfoBarService(content::WebContents* web_contents) |
48 : content::WebContentsObserver(web_contents), | 49 : content::WebContentsObserver(web_contents), |
49 ignore_next_reload_(false) { | 50 ignore_next_reload_(false) { |
50 DCHECK(web_contents); | 51 DCHECK(web_contents); |
| 52 // Infobar animations cause viewport resizes. Disable them for automated |
| 53 // tests, since they could lead to flakiness. |
| 54 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 55 switches::kEnableAutomation)) |
| 56 set_animations_enabled(false); |
51 } | 57 } |
52 | 58 |
53 InfoBarService::~InfoBarService() { | 59 InfoBarService::~InfoBarService() { |
54 ShutDown(); | 60 ShutDown(); |
55 } | 61 } |
56 | 62 |
57 int InfoBarService::GetActiveEntryID() { | 63 int InfoBarService::GetActiveEntryID() { |
58 content::NavigationEntry* active_entry = | 64 content::NavigationEntry* active_entry = |
59 web_contents()->GetController().GetActiveEntry(); | 65 web_contents()->GetController().GetActiveEntry(); |
60 return active_entry ? active_entry->GetUniqueID() : 0; | 66 return active_entry ? active_entry->GetUniqueID() : 0; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // A normal user click on an infobar URL will result in a CURRENT_TAB | 127 // A normal user click on an infobar URL will result in a CURRENT_TAB |
122 // disposition; turn that into a NEW_FOREGROUND_TAB so that we don't end up | 128 // disposition; turn that into a NEW_FOREGROUND_TAB so that we don't end up |
123 // smashing the page the user is looking at. | 129 // smashing the page the user is looking at. |
124 web_contents()->OpenURL( | 130 web_contents()->OpenURL( |
125 content::OpenURLParams(url, content::Referrer(), | 131 content::OpenURLParams(url, content::Referrer(), |
126 (disposition == WindowOpenDisposition::CURRENT_TAB) | 132 (disposition == WindowOpenDisposition::CURRENT_TAB) |
127 ? WindowOpenDisposition::NEW_FOREGROUND_TAB | 133 ? WindowOpenDisposition::NEW_FOREGROUND_TAB |
128 : disposition, | 134 : disposition, |
129 ui::PAGE_TRANSITION_LINK, false)); | 135 ui::PAGE_TRANSITION_LINK, false)); |
130 } | 136 } |
OLD | NEW |