| 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 23 matching lines...) Expand all Loading... |
| 101 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; | 101 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; |
| 102 } | 102 } |
| 103 | 103 |
| 104 using base::UserMetricsAction; | 104 using base::UserMetricsAction; |
| 105 using content::NavigationController; | 105 using content::NavigationController; |
| 106 using content::NavigationEntry; | 106 using content::NavigationEntry; |
| 107 using content::OpenURLParams; | 107 using content::OpenURLParams; |
| 108 using content::Referrer; | 108 using content::Referrer; |
| 109 using content::SSLStatus; | 109 using content::SSLStatus; |
| 110 using content::WebContents; | 110 using content::WebContents; |
| 111 using web_modal::WebContentsModalDialogManager; | |
| 112 | 111 |
| 113 namespace chrome { | 112 namespace chrome { |
| 114 namespace { | 113 namespace { |
| 115 | 114 |
| 116 bool CanBookmarkCurrentPageInternal(const Browser* browser, | 115 bool CanBookmarkCurrentPageInternal(const Browser* browser, |
| 117 bool check_remove_bookmark_ui) { | 116 bool check_remove_bookmark_ui) { |
| 118 BookmarkModel* model = | 117 BookmarkModel* model = |
| 119 BookmarkModelFactory::GetForProfile(browser->profile()); | 118 BookmarkModelFactory::GetForProfile(browser->profile()); |
| 120 return browser_defaults::bookmarks_enabled && | 119 return browser_defaults::bookmarks_enabled && |
| 121 browser->profile()->GetPrefs()->GetBoolean( | 120 browser->profile()->GetPrefs()->GetBoolean( |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 else | 242 else |
| 244 new_tab->GetController().Reload(true); | 243 new_tab->GetController().Reload(true); |
| 245 } | 244 } |
| 246 | 245 |
| 247 bool IsShowingWebContentsModalDialog(const Browser* browser) { | 246 bool IsShowingWebContentsModalDialog(const Browser* browser) { |
| 248 WebContents* web_contents = | 247 WebContents* web_contents = |
| 249 browser->tab_strip_model()->GetActiveWebContents(); | 248 browser->tab_strip_model()->GetActiveWebContents(); |
| 250 if (!web_contents) | 249 if (!web_contents) |
| 251 return false; | 250 return false; |
| 252 | 251 |
| 253 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 252 // TODO(gbillock): This gets called by the CanPrint method, and may be too |
| 254 WebContentsModalDialogManager::FromWebContents(web_contents); | 253 // restrictive if we allow print preview to overlap -- we should just queue |
| 255 return web_contents_modal_dialog_manager->IsDialogActive(); | 254 // print requests or attach a user gesture or whatever we know. |
| 255 // Note: check because tests may not have a popup manager. |
| 256 if (!browser->popup_manager()) |
| 257 return false; |
| 258 |
| 259 return browser->popup_manager()->IsWebModalDialogActive(web_contents); |
| 256 } | 260 } |
| 257 | 261 |
| 258 bool PrintPreviewShowing(const Browser* browser) { | 262 bool PrintPreviewShowing(const Browser* browser) { |
| 259 #if defined(ENABLE_FULL_PRINTING) | 263 #if defined(ENABLE_FULL_PRINTING) |
| 260 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); | 264 WebContents* contents = browser->tab_strip_model()->GetActiveWebContents(); |
| 261 printing::PrintPreviewDialogController* controller = | 265 printing::PrintPreviewDialogController* controller = |
| 262 printing::PrintPreviewDialogController::GetInstance(); | 266 printing::PrintPreviewDialogController::GetInstance(); |
| 263 return controller && (controller->GetPrintPreviewForContents(contents) || | 267 return controller && (controller->GetPrintPreviewForContents(contents) || |
| 264 controller->is_creating_print_preview_dialog()); | 268 controller->is_creating_print_preview_dialog()); |
| 265 #else | 269 #else |
| (...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 browser->profile(), | 1268 browser->profile(), |
| 1265 browser->host_desktop_type())); | 1269 browser->host_desktop_type())); |
| 1266 app_browser->tab_strip_model()->AppendWebContents(contents, true); | 1270 app_browser->tab_strip_model()->AppendWebContents(contents, true); |
| 1267 | 1271 |
| 1268 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; | 1272 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; |
| 1269 contents->GetRenderViewHost()->SyncRendererPrefs(); | 1273 contents->GetRenderViewHost()->SyncRendererPrefs(); |
| 1270 app_browser->window()->Show(); | 1274 app_browser->window()->Show(); |
| 1271 } | 1275 } |
| 1272 | 1276 |
| 1273 } // namespace chrome | 1277 } // namespace chrome |
| OLD | NEW |