Chromium Code Reviews| 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/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 #include "chrome/common/features.h" | 102 #include "chrome/common/features.h" |
| 103 #include "chrome/common/pref_names.h" | 103 #include "chrome/common/pref_names.h" |
| 104 #include "chrome/common/url_constants.h" | 104 #include "chrome/common/url_constants.h" |
| 105 #include "chrome/grit/chromium_strings.h" | 105 #include "chrome/grit/chromium_strings.h" |
| 106 #include "chrome/grit/generated_resources.h" | 106 #include "chrome/grit/generated_resources.h" |
| 107 #include "chrome/grit/locale_settings.h" | 107 #include "chrome/grit/locale_settings.h" |
| 108 #include "chrome/grit/theme_resources.h" | 108 #include "chrome/grit/theme_resources.h" |
| 109 #include "components/app_modal/app_modal_dialog.h" | 109 #include "components/app_modal/app_modal_dialog.h" |
| 110 #include "components/app_modal/app_modal_dialog_queue.h" | 110 #include "components/app_modal/app_modal_dialog_queue.h" |
| 111 #include "components/app_modal/native_app_modal_dialog.h" | 111 #include "components/app_modal/native_app_modal_dialog.h" |
| 112 #include "components/metrics/proto/translate_event.pb.h" | |
| 112 #include "components/omnibox/browser/omnibox_popup_model.h" | 113 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 113 #include "components/omnibox/browser/omnibox_popup_view.h" | 114 #include "components/omnibox/browser/omnibox_popup_view.h" |
| 114 #include "components/omnibox/browser/omnibox_view.h" | 115 #include "components/omnibox/browser/omnibox_view.h" |
| 115 #include "components/prefs/pref_service.h" | 116 #include "components/prefs/pref_service.h" |
| 116 #include "components/sessions/core/tab_restore_service.h" | 117 #include "components/sessions/core/tab_restore_service.h" |
| 117 #include "components/signin/core/common/profile_management_switches.h" | 118 #include "components/signin/core/common/profile_management_switches.h" |
| 118 #include "components/translate/core/browser/language_state.h" | 119 #include "components/translate/core/browser/language_state.h" |
| 120 #include "components/translate/core/browser/translate_manager.h" | |
| 119 #include "content/public/browser/download_manager.h" | 121 #include "content/public/browser/download_manager.h" |
| 120 #include "content/public/browser/notification_service.h" | 122 #include "content/public/browser/notification_service.h" |
| 121 #include "content/public/browser/render_frame_host.h" | 123 #include "content/public/browser/render_frame_host.h" |
| 122 #include "content/public/browser/render_view_host.h" | 124 #include "content/public/browser/render_view_host.h" |
| 123 #include "content/public/browser/render_widget_host_view.h" | 125 #include "content/public/browser/render_widget_host_view.h" |
| 124 #include "content/public/browser/user_metrics.h" | 126 #include "content/public/browser/user_metrics.h" |
| 125 #include "content/public/browser/web_contents.h" | 127 #include "content/public/browser/web_contents.h" |
| 126 #include "content/public/common/content_switches.h" | 128 #include "content/public/common/content_switches.h" |
| 127 #include "ui/accessibility/ax_view_state.h" | 129 #include "ui/accessibility/ax_view_state.h" |
| 128 #include "ui/base/accelerators/accelerator.h" | 130 #include "ui/base/accelerators/accelerator.h" |
| (...skipping 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1250 bool is_user_gesture) { | 1252 bool is_user_gesture) { |
| 1251 return toolbar_->ShowSaveCreditCardBubble(web_contents, controller, | 1253 return toolbar_->ShowSaveCreditCardBubble(web_contents, controller, |
| 1252 is_user_gesture); | 1254 is_user_gesture); |
| 1253 } | 1255 } |
| 1254 | 1256 |
| 1255 void BrowserView::ShowTranslateBubble( | 1257 void BrowserView::ShowTranslateBubble( |
| 1256 content::WebContents* web_contents, | 1258 content::WebContents* web_contents, |
| 1257 translate::TranslateStep step, | 1259 translate::TranslateStep step, |
| 1258 translate::TranslateErrors::Type error_type, | 1260 translate::TranslateErrors::Type error_type, |
| 1259 bool is_user_gesture) { | 1261 bool is_user_gesture) { |
| 1262 ChromeTranslateClient* translate_client = | |
|
sky
2016/10/14 23:26:59
Can this code move to browser_commands so that it'
Roger McFarlane (Chromium)
2016/10/24 19:01:52
How does the browser_commands Translate get trigge
sky
2016/10/24 20:45:00
From the bubble? I could be wrong, but this seems
Roger McFarlane (Chromium)
2016/11/07 20:51:58
browser_commands responds to the user bringing up
| |
| 1263 ChromeTranslateClient::FromWebContents(web_contents); | |
| 1264 translate::TranslateManager* translate_manager = | |
| 1265 translate_client->GetTranslateManager(); | |
| 1266 | |
| 1260 if (contents_web_view_->HasFocus() && | 1267 if (contents_web_view_->HasFocus() && |
| 1261 !GetLocationBarView()->IsMouseHovered()) { | 1268 !GetLocationBarView()->IsMouseHovered()) { |
| 1262 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); | 1269 content::RenderViewHost* rvh = web_contents->GetRenderViewHost(); |
| 1263 if (rvh->IsFocusedElementEditable()) | 1270 if (rvh->IsFocusedElementEditable()) { |
| 1271 if (translate_manager && | |
| 1272 step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { | |
| 1273 translate_manager->RecordTranslateEvent( | |
| 1274 metrics::TranslateEventProto::EDITABLE_FIELD_IN_FOCUS); | |
| 1275 } | |
| 1264 return; | 1276 return; |
| 1277 } | |
| 1265 } | 1278 } |
| 1266 | 1279 |
| 1267 translate::LanguageState& language_state = | 1280 translate::LanguageState& language_state = |
| 1268 ChromeTranslateClient::FromWebContents(web_contents)->GetLanguageState(); | 1281 translate_client->GetLanguageState(); |
| 1269 language_state.SetTranslateEnabled(true); | 1282 language_state.SetTranslateEnabled(true); |
| 1270 | 1283 |
| 1271 if (!IsMinimized()) { | 1284 if (IsMinimized()) { |
| 1272 toolbar_->ShowTranslateBubble(web_contents, step, error_type, | 1285 if (translate_manager && |
| 1273 is_user_gesture); | 1286 step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { |
| 1287 translate_manager->RecordTranslateEvent( | |
| 1288 metrics::TranslateEventProto::BROWSER_WINDOW_MINIMIZED); | |
| 1289 } | |
| 1290 return; | |
| 1274 } | 1291 } |
| 1292 | |
| 1293 toolbar_->ShowTranslateBubble(web_contents, step, error_type, | |
| 1294 is_user_gesture); | |
| 1275 } | 1295 } |
| 1276 | 1296 |
| 1277 #if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN) | 1297 #if BUILDFLAG(ENABLE_ONE_CLICK_SIGNIN) |
| 1278 void BrowserView::ShowOneClickSigninConfirmation( | 1298 void BrowserView::ShowOneClickSigninConfirmation( |
| 1279 const base::string16& email, | 1299 const base::string16& email, |
| 1280 const StartSyncCallback& start_sync_callback) { | 1300 const StartSyncCallback& start_sync_callback) { |
| 1281 std::unique_ptr<OneClickSigninLinksDelegate> delegate( | 1301 std::unique_ptr<OneClickSigninLinksDelegate> delegate( |
| 1282 new OneClickSigninLinksDelegateImpl(browser())); | 1302 new OneClickSigninLinksDelegateImpl(browser())); |
| 1283 OneClickSigninDialogView::ShowDialog(email, std::move(delegate), | 1303 OneClickSigninDialogView::ShowDialog(email, std::move(delegate), |
| 1284 GetNativeWindow(), start_sync_callback); | 1304 GetNativeWindow(), start_sync_callback); |
| (...skipping 1351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2636 } | 2656 } |
| 2637 | 2657 |
| 2638 extensions::ActiveTabPermissionGranter* | 2658 extensions::ActiveTabPermissionGranter* |
| 2639 BrowserView::GetActiveTabPermissionGranter() { | 2659 BrowserView::GetActiveTabPermissionGranter() { |
| 2640 content::WebContents* web_contents = GetActiveWebContents(); | 2660 content::WebContents* web_contents = GetActiveWebContents(); |
| 2641 if (!web_contents) | 2661 if (!web_contents) |
| 2642 return nullptr; | 2662 return nullptr; |
| 2643 return extensions::TabHelper::FromWebContents(web_contents) | 2663 return extensions::TabHelper::FromWebContents(web_contents) |
| 2644 ->active_tab_permission_granter(); | 2664 ->active_tab_permission_granter(); |
| 2645 } | 2665 } |
| OLD | NEW |