Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ui/javascript_dialogs/javascript_dialog_tab_helper.h" | 5 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| 11 #include "chrome/browser/engagement/site_engagement_service.h" | 11 #include "chrome/browser/engagement/site_engagement_service.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 15 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
| 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 17 #include "chrome/common/chrome_features.h" | 17 #include "chrome/common/chrome_features.h" |
| 18 #include "components/app_modal/javascript_dialog_manager.h" | 18 #include "components/app_modal/javascript_dialog_manager.h" |
| 19 #include "content/public/browser/navigation_handle.h" | 19 #include "content/public/browser/navigation_handle.h" |
| 20 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
| 21 | 21 |
| 22 DEFINE_WEB_CONTENTS_USER_DATA_KEY(JavaScriptDialogTabHelper); | 22 DEFINE_WEB_CONTENTS_USER_DATA_KEY(JavaScriptDialogTabHelper); |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 bool IsEnabled() { | 26 bool IsEnabled() { |
| 27 #if defined(GOOGLE_CHROME_BUILD) | |
| 27 return base::FeatureList::IsEnabled(features::kAutoDismissingDialogs); | 28 return base::FeatureList::IsEnabled(features::kAutoDismissingDialogs); |
| 29 #else | |
| 30 return true; | |
| 31 #endif | |
|
nasko
2017/03/28 17:29:19
It isn't very obvious, but the right way to enable
Avi (use Gerrit)
2017/03/28 19:58:51
The more you know...
(how do you know this?)
| |
| 28 } | 32 } |
| 29 | 33 |
| 30 app_modal::JavaScriptDialogManager* AppModalDialogManager() { | 34 app_modal::JavaScriptDialogManager* AppModalDialogManager() { |
| 31 return app_modal::JavaScriptDialogManager::GetInstance(); | 35 return app_modal::JavaScriptDialogManager::GetInstance(); |
| 32 } | 36 } |
| 33 | 37 |
| 34 bool IsWebContentsForemost(content::WebContents* web_contents) { | 38 bool IsWebContentsForemost(content::WebContents* web_contents) { |
| 35 Browser* browser = BrowserList::GetInstance()->GetLastActive(); | 39 Browser* browser = BrowserList::GetInstance()->GetLastActive(); |
| 36 DCHECK(browser); | 40 DCHECK(browser); |
| 37 return browser->tab_strip_model()->GetActiveWebContents() == web_contents; | 41 return browser->tab_strip_model()->GetActiveWebContents() == web_contents; |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 328 dialog_callback_.Run(success, user_input); | 332 dialog_callback_.Run(success, user_input); |
| 329 | 333 |
| 330 ClearDialogInfo(); | 334 ClearDialogInfo(); |
| 331 } | 335 } |
| 332 | 336 |
| 333 void JavaScriptDialogTabHelper::ClearDialogInfo() { | 337 void JavaScriptDialogTabHelper::ClearDialogInfo() { |
| 334 dialog_.reset(); | 338 dialog_.reset(); |
| 335 dialog_callback_.Reset(); | 339 dialog_callback_.Reset(); |
| 336 BrowserList::RemoveObserver(this); | 340 BrowserList::RemoveObserver(this); |
| 337 } | 341 } |
| OLD | NEW |