Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: chrome/browser/ui/browser_commands.cc

Issue 2400503002: [Translate] Integrate TranslateEventProto UMA logging into TranslateManager. (Closed)
Patch Set: fix trybots Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 44 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
45 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 45 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
46 #include "chrome/browser/ui/location_bar/location_bar.h" 46 #include "chrome/browser/ui/location_bar/location_bar.h"
47 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 47 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
48 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 48 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
49 #include "chrome/browser/ui/search/search_tab_helper.h" 49 #include "chrome/browser/ui/search/search_tab_helper.h"
50 #include "chrome/browser/ui/status_bubble.h" 50 #include "chrome/browser/ui/status_bubble.h"
51 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 51 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
52 #include "chrome/browser/ui/tab_dialogs.h" 52 #include "chrome/browser/ui/tab_dialogs.h"
53 #include "chrome/browser/ui/tabs/tab_strip_model.h" 53 #include "chrome/browser/ui/tabs/tab_strip_model.h"
54 #include "chrome/browser/ui/translate/translate_bubble_view_state_transition.h"
54 #include "chrome/browser/upgrade_detector.h" 55 #include "chrome/browser/upgrade_detector.h"
55 #include "chrome/common/content_restriction.h" 56 #include "chrome/common/content_restriction.h"
56 #include "chrome/common/features.h" 57 #include "chrome/common/features.h"
57 #include "chrome/common/pref_names.h" 58 #include "chrome/common/pref_names.h"
58 #include "components/bookmarks/browser/bookmark_model.h" 59 #include "components/bookmarks/browser/bookmark_model.h"
59 #include "components/bookmarks/browser/bookmark_utils.h" 60 #include "components/bookmarks/browser/bookmark_utils.h"
60 #include "components/bookmarks/common/bookmark_pref_names.h" 61 #include "components/bookmarks/common/bookmark_pref_names.h"
61 #include "components/favicon/content/content_favicon_driver.h" 62 #include "components/favicon/content/content_favicon_driver.h"
62 #include "components/google/core/browser/google_util.h" 63 #include "components/google/core/browser/google_util.h"
63 #include "components/prefs/pref_service.h" 64 #include "components/prefs/pref_service.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 112
112 #if defined(ENABLE_RLZ) 113 #if defined(ENABLE_RLZ)
113 #include "components/rlz/rlz_tracker.h" // nogncheck 114 #include "components/rlz/rlz_tracker.h" // nogncheck
114 #endif 115 #endif
115 116
116 #if defined(ENABLE_MEDIA_ROUTER) 117 #if defined(ENABLE_MEDIA_ROUTER)
117 #include "chrome/browser/media/router/media_router_dialog_controller.h" // nogn check 118 #include "chrome/browser/media/router/media_router_dialog_controller.h" // nogn check
118 #endif 119 #endif
119 120
120 namespace { 121 namespace {
122
121 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3"; 123 const char kOsOverrideForTabletSite[] = "Linux; Android 4.0.3";
124
125 translate::TranslateBubbleUiEvent TranslateBubbleResultToUiEvent(
126 ShowTranslateBubbleResult result) {
127 switch (result) {
128 default:
129 NOTREACHED();
130 // Fall through.
131 case ShowTranslateBubbleResult::SUCCESS:
132 return translate::TranslateBubbleUiEvent::BUBBLE_SHOWN;
133 case ShowTranslateBubbleResult::BROWSER_WINDOW_NOT_VALID:
134 return translate::TranslateBubbleUiEvent::
135 BUBBLE_NOT_SHOWN_WINDOW_NOT_VALID;
136 case ShowTranslateBubbleResult::BROWSER_WINDOW_MINIMIZED:
137 return translate::TranslateBubbleUiEvent::
138 BUBBLE_NOT_SHOWN_WINDOW_MINIMIZED;
139 case ShowTranslateBubbleResult::BROWSER_WINDOW_NOT_ACTIVE:
140 return translate::TranslateBubbleUiEvent::
141 BUBBLE_NOT_SHOWN_WINDOW_NOT_ACTIVE;
142 case ShowTranslateBubbleResult::WEB_CONTENTS_NOT_ACTIVE:
143 return translate::TranslateBubbleUiEvent::
144 BUBBLE_NOT_SHOWN_WEB_CONTENTS_NOT_ACTIVE;
145 case ShowTranslateBubbleResult::EDITABLE_FIELD_IS_ACTIVE:
146 return translate::TranslateBubbleUiEvent::
147 BUBBLE_NOT_SHOWN_EDITABLE_FIELD_IS_ACTIVE;
148 }
122 } 149 }
123 150
151 } // namespace
152
124 using base::UserMetricsAction; 153 using base::UserMetricsAction;
125 using bookmarks::BookmarkModel; 154 using bookmarks::BookmarkModel;
126 using content::NavigationController; 155 using content::NavigationController;
127 using content::NavigationEntry; 156 using content::NavigationEntry;
128 using content::OpenURLParams; 157 using content::OpenURLParams;
129 using content::Referrer; 158 using content::Referrer;
130 using content::WebContents; 159 using content::WebContents;
131 160
132 namespace chrome { 161 namespace chrome {
133 namespace { 162 namespace {
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 ChromeTranslateClient* chrome_translate_client = 850 ChromeTranslateClient* chrome_translate_client =
822 ChromeTranslateClient::FromWebContents(web_contents); 851 ChromeTranslateClient::FromWebContents(web_contents);
823 852
824 translate::TranslateStep step = translate::TRANSLATE_STEP_BEFORE_TRANSLATE; 853 translate::TranslateStep step = translate::TRANSLATE_STEP_BEFORE_TRANSLATE;
825 if (chrome_translate_client) { 854 if (chrome_translate_client) {
826 if (chrome_translate_client->GetLanguageState().translation_pending()) 855 if (chrome_translate_client->GetLanguageState().translation_pending())
827 step = translate::TRANSLATE_STEP_TRANSLATING; 856 step = translate::TRANSLATE_STEP_TRANSLATING;
828 else if (chrome_translate_client->GetLanguageState().IsPageTranslated()) 857 else if (chrome_translate_client->GetLanguageState().IsPageTranslated())
829 step = translate::TRANSLATE_STEP_AFTER_TRANSLATE; 858 step = translate::TRANSLATE_STEP_AFTER_TRANSLATE;
830 } 859 }
831 browser->window()->ShowTranslateBubble( 860 ShowTranslateBubbleResult result = browser->window()->ShowTranslateBubble(
832 web_contents, step, translate::TranslateErrors::NONE, true); 861 web_contents, step, translate::TranslateErrors::NONE, true);
862 if (result != ShowTranslateBubbleResult::SUCCESS)
863 translate::ReportUiAction(TranslateBubbleResultToUiEvent(result));
833 } 864 }
834 865
835 void ManagePasswordsForPage(Browser* browser) { 866 void ManagePasswordsForPage(Browser* browser) {
836 WebContents* web_contents = 867 WebContents* web_contents =
837 browser->tab_strip_model()->GetActiveWebContents(); 868 browser->tab_strip_model()->GetActiveWebContents();
838 ManagePasswordsUIController* controller = 869 ManagePasswordsUIController* controller =
839 ManagePasswordsUIController::FromWebContents(web_contents); 870 ManagePasswordsUIController::FromWebContents(web_contents);
840 TabDialogs::FromWebContents(web_contents)->ShowManagePasswordsBubble( 871 TabDialogs::FromWebContents(web_contents)->ShowManagePasswordsBubble(
841 !controller->IsAutomaticallyOpeningBubble()); 872 !controller->IsAutomaticallyOpeningBubble());
842 } 873 }
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 app_name, true /* trusted_source */, gfx::Rect(), browser->profile())); 1330 app_name, true /* trusted_source */, gfx::Rect(), browser->profile()));
1300 app_browser->tab_strip_model()->AppendWebContents(contents, true); 1331 app_browser->tab_strip_model()->AppendWebContents(contents, true);
1301 1332
1302 contents->GetMutableRendererPrefs()->can_accept_load_drops = false; 1333 contents->GetMutableRendererPrefs()->can_accept_load_drops = false;
1303 contents->GetRenderViewHost()->SyncRendererPrefs(); 1334 contents->GetRenderViewHost()->SyncRendererPrefs();
1304 app_browser->window()->Show(); 1335 app_browser->window()->Show();
1305 } 1336 }
1306 #endif // BUILDFLAG(ENABLE_EXTENSIONS) 1337 #endif // BUILDFLAG(ENABLE_EXTENSIONS)
1307 1338
1308 } // namespace chrome 1339 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_manager_render_view_host_unittest.cc ('k') | chrome/browser/ui/browser_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698