OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/browser_commands.h" | 5 #include "chrome/browser/ui/browser_commands.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 #include "chrome/browser/web_applications/web_app.h" | 57 #include "chrome/browser/web_applications/web_app.h" |
58 #include "chrome/common/chrome_switches.h" | 58 #include "chrome/common/chrome_switches.h" |
59 #include "chrome/common/chrome_version_info.h" | 59 #include "chrome/common/chrome_version_info.h" |
60 #include "chrome/common/content_restriction.h" | 60 #include "chrome/common/content_restriction.h" |
61 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 61 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
62 #include "chrome/common/pref_names.h" | 62 #include "chrome/common/pref_names.h" |
63 #include "components/bookmarks/browser/bookmark_model.h" | 63 #include "components/bookmarks/browser/bookmark_model.h" |
64 #include "components/bookmarks/browser/bookmark_utils.h" | 64 #include "components/bookmarks/browser/bookmark_utils.h" |
65 #include "components/google/core/browser/google_util.h" | 65 #include "components/google/core/browser/google_util.h" |
66 #include "components/translate/core/browser/language_state.h" | 66 #include "components/translate/core/browser/language_state.h" |
67 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 67 #include "components/web_modal/popup_manager.h" |
68 #include "content/public/browser/devtools_agent_host.h" | 68 #include "content/public/browser/devtools_agent_host.h" |
69 #include "content/public/browser/navigation_controller.h" | 69 #include "content/public/browser/navigation_controller.h" |
70 #include "content/public/browser/navigation_entry.h" | 70 #include "content/public/browser/navigation_entry.h" |
71 #include "content/public/browser/notification_service.h" | 71 #include "content/public/browser/notification_service.h" |
72 #include "content/public/browser/page_navigator.h" | 72 #include "content/public/browser/page_navigator.h" |
73 #include "content/public/browser/render_view_host.h" | 73 #include "content/public/browser/render_view_host.h" |
74 #include "content/public/browser/render_widget_host_view.h" | 74 #include "content/public/browser/render_widget_host_view.h" |
75 #include "content/public/browser/user_metrics.h" | 75 #include "content/public/browser/user_metrics.h" |
76 #include "content/public/browser/web_contents.h" | 76 #include "content/public/browser/web_contents.h" |
77 #include "content/public/common/renderer_preferences.h" | 77 #include "content/public/common/renderer_preferences.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
102 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; | 102 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; |
103 } | 103 } |
104 | 104 |
105 using base::UserMetricsAction; | 105 using base::UserMetricsAction; |
106 using content::NavigationController; | 106 using content::NavigationController; |
107 using content::NavigationEntry; | 107 using content::NavigationEntry; |
108 using content::OpenURLParams; | 108 using content::OpenURLParams; |
109 using content::Referrer; | 109 using content::Referrer; |
110 using content::SSLStatus; | 110 using content::SSLStatus; |
111 using content::WebContents; | 111 using content::WebContents; |
112 using web_modal::WebContentsModalDialogManager; | |
113 | 112 |
114 namespace chrome { | 113 namespace chrome { |
115 namespace { | 114 namespace { |
116 | 115 |
117 bool CanBookmarkCurrentPageInternal(const Browser* browser, | 116 bool CanBookmarkCurrentPageInternal(const Browser* browser, |
118 bool check_remove_bookmark_ui) { | 117 bool check_remove_bookmark_ui) { |
119 BookmarkModel* model = | 118 BookmarkModel* model = |
120 BookmarkModelFactory::GetForProfile(browser->profile()); | 119 BookmarkModelFactory::GetForProfile(browser->profile()); |
121 return browser_defaults::bookmarks_enabled && | 120 return browser_defaults::bookmarks_enabled && |
122 browser->profile()->GetPrefs()->GetBoolean( | 121 browser->profile()->GetPrefs()->GetBoolean( |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
244 else | 243 else |
245 new_tab->GetController().Reload(true); | 244 new_tab->GetController().Reload(true); |
246 } | 245 } |
247 | 246 |
248 bool IsShowingWebContentsModalDialog(const Browser* browser) { | 247 bool IsShowingWebContentsModalDialog(const Browser* browser) { |
249 WebContents* web_contents = | 248 WebContents* web_contents = |
250 browser->tab_strip_model()->GetActiveWebContents(); | 249 browser->tab_strip_model()->GetActiveWebContents(); |
251 if (!web_contents) | 250 if (!web_contents) |
252 return false; | 251 return false; |
253 | 252 |
254 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 253 // TODO(gbillock): This gets called by the CanPrint method, and may be too |
255 WebContentsModalDialogManager::FromWebContents(web_contents); | 254 // restrictive if we allow print preview to overlap -- we should just queue |
256 return web_contents_modal_dialog_manager->IsDialogActive(); | 255 // print requests or attach a user gesture or whatever we know. |
Peter Kasting
2014/07/08 19:13:54
Nit: I don't know what "whatever we know" means he
Greg Billock
2014/07/09 19:28:12
Me either. This is dependent on popup policy which
Peter Kasting
2014/07/09 19:41:41
I might just rewrite the comment to be simpler the
Greg Billock
2014/07/10 18:32:03
Done.
| |
256 // Note: check because tests may not have a popup manager. | |
Peter Kasting
2014/07/08 19:13:54
Nit: Move this sentence above the TODO and rewrite
Greg Billock
2014/07/09 19:28:12
Done.
| |
257 if (!browser->popup_manager()) | |
258 return false; | |
259 | |
260 return browser->popup_manager()->IsWebModalDialogActive(web_contents); | |
257 } | 261 } |
258 | 262 |
259 bool PrintPreviewShowing(const Browser* browser) { | 263 bool PrintPreviewShowing(const Browser* browser) { |
260 #if defined(ENABLE_FULL_PRINTING) | 264 #if defined(ENABLE_FULL_PRINTING) |
261 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); | 265 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); |
262 printing::PrintPreviewDialogController* controller = | 266 printing::PrintPreviewDialogController* controller = |
263 printing::PrintPreviewDialogController::GetInstance(); | 267 printing::PrintPreviewDialogController::GetInstance(); |
264 return controller && (controller->GetPrintPreviewForContents(contents) || | 268 return controller && (controller->GetPrintPreviewForContents(contents) || |
265 controller->is_creating_print_preview_dialog()); | 269 controller->is_creating_print_preview_dialog()); |
266 #else | 270 #else |
(...skipping 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1266 browser->profile(), | 1270 browser->profile(), |
1267 browser->host_desktop_type())); | 1271 browser->host_desktop_type())); |
1268 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1272 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
1269 | 1273 |
1270 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1274 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
1271 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1275 contents->GetRenderViewHost()->SyncRendererPrefs(); |
1272 app_browser->window()->Show(); | 1276 app_browser->window()->Show(); |
1273 } | 1277 } |
1274 | 1278 |
1275 } // namespace chrome | 1279 } // namespace chrome |
OLD | NEW |