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

Side by Side Diff: chrome/browser/ui/views/simple_message_box_views.cc

Issue 1169503002: Do not record startup metrics when non-browser UI was displayed (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 5 years, 5 months 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/simple_message_box.h" 5 #include "chrome/browser/ui/simple_message_box.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "chrome/browser/ui/simple_message_box_internal.h"
11 #include "chrome/grit/generated_resources.h" 12 #include "chrome/grit/generated_resources.h"
12 #include "components/constrained_window/constrained_window_views.h" 13 #include "components/constrained_window/constrained_window_views.h"
14 #include "components/startup_metric_utils/startup_metric_utils.h"
13 #include "ui/base/l10n/l10n_util.h" 15 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
16 #include "ui/views/controls/message_box_view.h" 18 #include "ui/views/controls/message_box_view.h"
17 #include "ui/views/widget/widget.h" 19 #include "ui/views/widget/widget.h"
18 #include "ui/views/window/dialog_delegate.h" 20 #include "ui/views/window/dialog_delegate.h"
19 21
20 #if defined(OS_WIN) 22 #if defined(OS_WIN)
21 #include "ui/base/win/message_box_win.h" 23 #include "ui/base/win/message_box_win.h"
22 #include "ui/views/win/hwnd_util.h" 24 #include "ui/views/win/hwnd_util.h"
(...skipping 23 matching lines...) Expand all
46 48
47 // Overridden from views::WidgetDelegate: 49 // Overridden from views::WidgetDelegate:
48 base::string16 GetWindowTitle() const override; 50 base::string16 GetWindowTitle() const override;
49 void DeleteDelegate() override; 51 void DeleteDelegate() override;
50 ui::ModalType GetModalType() const override; 52 ui::ModalType GetModalType() const override;
51 views::View* GetContentsView() override; 53 views::View* GetContentsView() override;
52 views::Widget* GetWidget() override; 54 views::Widget* GetWidget() override;
53 const views::Widget* GetWidget() const override; 55 const views::Widget* GetWidget() const override;
54 56
55 private: 57 private:
56
57 // This terminates the nested message-loop. 58 // This terminates the nested message-loop.
58 void Done(); 59 void Done();
59 60
60 const base::string16 window_title_; 61 const base::string16 window_title_;
61 const MessageBoxType type_; 62 const MessageBoxType type_;
62 base::string16 yes_text_; 63 base::string16 yes_text_;
63 base::string16 no_text_; 64 base::string16 no_text_;
64 MessageBoxResult* result_; 65 MessageBoxResult* result_;
65 bool is_system_modal_; 66 bool is_system_modal_;
66 views::MessageBoxView* message_box_view_; 67 views::MessageBoxView* message_box_view_;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return flags | MB_OK | MB_ICONWARNING; 199 return flags | MB_OK | MB_ICONWARNING;
199 } 200 }
200 #endif 201 #endif
201 202
202 MessageBoxResult ShowMessageBoxImpl(gfx::NativeWindow parent, 203 MessageBoxResult ShowMessageBoxImpl(gfx::NativeWindow parent,
203 const base::string16& title, 204 const base::string16& title,
204 const base::string16& message, 205 const base::string16& message,
205 MessageBoxType type, 206 MessageBoxType type,
206 const base::string16& yes_text, 207 const base::string16& yes_text,
207 const base::string16& no_text) { 208 const base::string16& no_text) {
209 startup_metric_utils::SetNonBrowserUIDisplayed();
210 if (internal::g_should_skip_message_box_for_test)
211 return MESSAGE_BOX_RESULT_YES;
212
208 // Views dialogs cannot be shown outside the UI thread message loop or if the 213 // Views dialogs cannot be shown outside the UI thread message loop or if the
209 // ResourceBundle is not initialized yet. 214 // ResourceBundle is not initialized yet.
210 // Fallback to logging with a default response or a Windows MessageBox. 215 // Fallback to logging with a default response or a Windows MessageBox.
211 #if defined(OS_WIN) 216 #if defined(OS_WIN)
212 if (!base::MessageLoopForUI::IsCurrent() || 217 if (!base::MessageLoopForUI::IsCurrent() ||
213 !base::MessageLoopForUI::current()->is_running() || 218 !base::MessageLoopForUI::current()->is_running() ||
214 !ResourceBundle::HasSharedInstance()) { 219 !ResourceBundle::HasSharedInstance()) {
215 int result = ui::MessageBox(views::HWNDForNativeWindow(parent), message, 220 int result = ui::MessageBox(views::HWNDForNativeWindow(parent), message,
216 title, GetMessageBoxFlagsFromType(type)); 221 title, GetMessageBoxFlagsFromType(type));
217 return (result == IDYES || result == IDOK) ? 222 return (result == IDYES || result == IDOK) ?
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 MessageBoxResult ShowMessageBoxWithButtonText(gfx::NativeWindow parent, 259 MessageBoxResult ShowMessageBoxWithButtonText(gfx::NativeWindow parent,
255 const base::string16& title, 260 const base::string16& title,
256 const base::string16& message, 261 const base::string16& message,
257 const base::string16& yes_text, 262 const base::string16& yes_text,
258 const base::string16& no_text) { 263 const base::string16& no_text) {
259 return ShowMessageBoxImpl( 264 return ShowMessageBoxImpl(
260 parent, title, message, MESSAGE_BOX_TYPE_QUESTION, yes_text, no_text); 265 parent, title, message, MESSAGE_BOX_TYPE_QUESTION, yes_text, no_text);
261 } 266 }
262 267
263 } // namespace chrome 268 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698