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

Side by Side Diff: chrome/browser/ui/webui/set_as_default_browser_ui.cc

Issue 2090773002: Improves first run dialog performance on Win8 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/webui/set_as_default_browser_ui.h" 5 #include "chrome/browser/ui/webui/set_as_default_browser_ui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 24 matching lines...) Expand all
35 #include "content/public/browser/browser_thread.h" 35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/web_contents.h" 36 #include "content/public/browser/web_contents.h"
37 #include "content/public/browser/web_contents_delegate.h" 37 #include "content/public/browser/web_contents_delegate.h"
38 #include "content/public/browser/web_ui.h" 38 #include "content/public/browser/web_ui.h"
39 #include "content/public/browser/web_ui_data_source.h" 39 #include "content/public/browser/web_ui_data_source.h"
40 #include "content/public/browser/web_ui_message_handler.h" 40 #include "content/public/browser/web_ui_message_handler.h"
41 #include "grit/browser_resources.h" 41 #include "grit/browser_resources.h"
42 #include "ui/base/l10n/l10n_font_util.h" 42 #include "ui/base/l10n/l10n_font_util.h"
43 #include "ui/base/l10n/l10n_util.h" 43 #include "ui/base/l10n/l10n_util.h"
44 #include "ui/gfx/font.h" 44 #include "ui/gfx/font.h"
45 #include "ui/views/widget/widget.h"
46 #include "ui/web_dialogs/web_dialog_delegate.h" 45 #include "ui/web_dialogs/web_dialog_delegate.h"
47 46
48 using content::BrowserThread; 47 using content::BrowserThread;
49 using content::WebContents; 48 using content::WebContents;
50 using content::WebUIMessageHandler; 49 using content::WebUIMessageHandler;
51 50
52 namespace { 51 namespace {
53 52
54 const char kSetAsDefaultBrowserHistogram[] = "DefaultBrowser.InteractionResult"; 53 const char kSetAsDefaultBrowserHistogram[] = "DefaultBrowser.InteractionResult";
55 54
55 views::Widget* g_dialog_widget;
grt (UTC plus 2) 2016/07/13 08:54:49 if you must use a global variable (i see you're di
zmin 2016/07/18 21:12:14 Done.
56
56 // The enum permits registering in UMA the three possible outcomes (do not 57 // The enum permits registering in UMA the three possible outcomes (do not
57 // reorder these). 58 // reorder these).
58 // ACCEPTED: user pressed Next and made Chrome default. 59 // ACCEPTED: user pressed Next and made Chrome default.
59 // DECLINED: user simply closed the dialog without making Chrome default. 60 // DECLINED: user simply closed the dialog without making Chrome default.
60 // REGRETTED: user pressed Next but then elected a different default browser. 61 // REGRETTED: user pressed Next but then elected a different default browser.
61 enum MakeChromeDefaultResult { 62 enum MakeChromeDefaultResult {
62 MAKE_CHROME_DEFAULT_ACCEPTED = 0, 63 MAKE_CHROME_DEFAULT_ACCEPTED = 0,
63 MAKE_CHROME_DEFAULT_DECLINED = 1, 64 MAKE_CHROME_DEFAULT_DECLINED = 1,
64 MAKE_CHROME_DEFAULT_REGRETTED = 2, 65 MAKE_CHROME_DEFAULT_REGRETTED = 2,
65 // MAKE_CHROME_DEFAULT_ACCEPTED_IMMERSE = 3, // Deprecated. 66 // MAKE_CHROME_DEFAULT_ACCEPTED_IMMERSE = 3, // Deprecated.
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 BrowserList::RemoveObserver(this); 240 BrowserList::RemoveObserver(this);
240 if (owns_handler_) 241 if (owns_handler_)
241 delete handler_; 242 delete handler_;
242 } 243 }
243 244
244 void SetAsDefaultBrowserDialogImpl::ShowDialog() { 245 void SetAsDefaultBrowserDialogImpl::ShowDialog() {
245 // Use a NULL parent window to make sure that the dialog will have an item 246 // Use a NULL parent window to make sure that the dialog will have an item
246 // in the Windows task bar. The code below will make it highlight if the 247 // in the Windows task bar. The code below will make it highlight if the
247 // dialog is not in the foreground. 248 // dialog is not in the foreground.
248 gfx::NativeWindow native_window = chrome::ShowWebDialog(NULL, profile_, this); 249 gfx::NativeWindow native_window = chrome::ShowWebDialog(NULL, profile_, this);
249 views::Widget* widget = views::Widget::GetWidgetForNativeWindow( 250 g_dialog_widget = views::Widget::GetWidgetForNativeWindow(native_window);
250 native_window); 251 g_dialog_widget->FlashFrame(true);
251 widget->FlashFrame(true);
252 } 252 }
253 253
254 ui::ModalType SetAsDefaultBrowserDialogImpl::GetDialogModalType() const { 254 ui::ModalType SetAsDefaultBrowserDialogImpl::GetDialogModalType() const {
255 return ui::MODAL_TYPE_SYSTEM; 255 return ui::MODAL_TYPE_SYSTEM;
256 } 256 }
257 257
258 base::string16 SetAsDefaultBrowserDialogImpl::GetDialogTitle() const { 258 base::string16 SetAsDefaultBrowserDialogImpl::GetDialogTitle() const {
259 return l10n_util::GetStringUTF16(IDS_METRO_FLOW_TAB_TITLE); 259 return l10n_util::GetStringUTF16(IDS_METRO_FLOW_TAB_TITLE);
260 } 260 }
261 261
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 Profile::FromWebUI(web_ui), CreateSetAsDefaultBrowserUIHTMLSource()); 345 Profile::FromWebUI(web_ui), CreateSetAsDefaultBrowserUIHTMLSource());
346 } 346 }
347 347
348 // static 348 // static
349 void SetAsDefaultBrowserUI::Show(Profile* profile, Browser* browser) { 349 void SetAsDefaultBrowserUI::Show(Profile* profile, Browser* browser) {
350 DCHECK_CURRENTLY_ON(BrowserThread::UI); 350 DCHECK_CURRENTLY_ON(BrowserThread::UI);
351 SetAsDefaultBrowserDialogImpl* dialog = 351 SetAsDefaultBrowserDialogImpl* dialog =
352 new SetAsDefaultBrowserDialogImpl(profile, browser); 352 new SetAsDefaultBrowserDialogImpl(profile, browser);
353 dialog->ShowDialog(); 353 dialog->ShowDialog();
354 } 354 }
355
356 // static
357 views::Widget* SetAsDefaultBrowserUI::GetDialogWidgetForTesting() {
358 return g_dialog_widget;
359 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698