diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-09 19:35:31 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-09 19:35:31 +0000 |
commit | c4b3858cc5dbae4bb28bf8c8a9bf9b7d0ca146d0 (patch) | |
tree | 5857d77fcf503a60350cf7798964c2417e659208 | |
parent | ac164c49d7975299229ff38615ae701e8b7766da (diff) | |
download | chromium_src-c4b3858cc5dbae4bb28bf8c8a9bf9b7d0ca146d0.zip chromium_src-c4b3858cc5dbae4bb28bf8c8a9bf9b7d0ca146d0.tar.gz chromium_src-c4b3858cc5dbae4bb28bf8c8a9bf9b7d0ca146d0.tar.bz2 |
Add 3 more flavors of the try chrome toast
- Different strings, pretty much the same deal.
- One case removes the radio buttons.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/198038
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25769 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/browser_main.cc | 7 | ||||
-rw-r--r-- | chrome/browser/first_run.h | 3 | ||||
-rw-r--r-- | chrome/browser/first_run_win.cc | 92 | ||||
-rw-r--r-- | chrome/common/temp_scaffolding_stubs.cc | 2 |
4 files changed, 80 insertions, 24 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index f9dd85d..d470dbf 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -459,8 +459,11 @@ int BrowserMain(const MainFunctionParams& parameters) { #if defined(OS_WIN) // This is experimental code. See first_run_win.cc for more info. - if (parsed_command_line.HasSwitch(switches::kTryChromeAgain)) { - Upgrade::TryResult answer = Upgrade::ShowTryChromeDialog(); + std::wstring try_chrome = + parsed_command_line.GetSwitchValue(switches::kTryChromeAgain); + if (!try_chrome.empty()) { + Upgrade::TryResult answer = + Upgrade::ShowTryChromeDialog(StringToInt(try_chrome)); if (answer == Upgrade::TD_NOT_NOW) return ResultCodes::NORMAL_EXIT_EXP1; if (answer == Upgrade::TD_UNINSTALL_CHROME) diff --git a/chrome/browser/first_run.h b/chrome/browser/first_run.h index 41aba0c..c9471e8 100644 --- a/chrome/browser/first_run.h +++ b/chrome/browser/first_run.h @@ -126,7 +126,8 @@ class Upgrade { // Shows a modal dialog asking the user to give chrome another try. See // above for the possible outcomes of the function. This is an experimental, // non-localized dialog. - static TryResult ShowTryChromeDialog(); + // |version| can be 0, 1 or 2 and selects what strings to present. + static TryResult ShowTryChromeDialog(size_t version); }; // A subclass of BrowserProcessImpl that does not have a GoogleURLTracker diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc index 14ffc76..34329fe 100644 --- a/chrome/browser/first_run_win.cc +++ b/chrome/browser/first_run_win.cc @@ -625,21 +625,53 @@ namespace { // These strings are used by TryChromeDialog. They will need to be localized // if we use it for other locales. -const wchar_t kHeading[] = - L"You stopped using Google Chrome. Would you like to ..."; -const wchar_t kGiveChromeATry[] = - L"Give the new version a try (already installed)"; -const wchar_t kNahUninstallIt[] = L"Uninstall Google Chrome"; +const wchar_t* kHeading[] = { + L"You stopped using Google Chrome. Would you like to ...", + L"Google Chrome misses you.", + L"There is a new version of Google Chrome available.", + L"Google Chrome has been updated, but you haven't tried it yet" +}; + +const wchar_t* kGiveChromeATry[] = { + L"Give the new version a try (already installed)", + L"Give it a second chance", + L"Try it out (already installed)" +}; + +const wchar_t* kNahUninstallIt[] = { + L"Uninstall Google Chrome", + L"Uninstall Google Chrome, it had its chance" +}; + +const wchar_t* kOKButn[] = { + L"OK", + L"Try it" +}; + const wchar_t kDontBugMe[] = L"Don't bug me"; -const wchar_t kOKButn[] = L"OK"; const wchar_t kWhyThis[] = L"Why am I seeing this?"; const wchar_t kHelpCenterUrl[] = L"http://www.google.com/support/chrome/bin/answer.py?hl=en&answer=150752"; +// This structure and the following constant defines how the dialog looks with +// respect of buttons and text, but does not fundamentally change the behavior. +struct VersionConfig { + int heading_index; + int try_index; + int uninstall_index; + int ok_button_index; +}; + +const VersionConfig kDialogVersion[] = { + {0, 0, 0, 0}, // 0 is classic. + {1, 1, 1, 0}, // 1 is humorous. + {2, 2, 0, 0}, // 2 is update-focused. + {3, -1, -1, 1} // 3 is simpler (no radio buttons). +}; // This class displays a modal dialog using the views system. The dialog asks // the user to give chrome another try. This class only handles the UI so the -// resulting actions are up to the caller. It looks like this: +// resulting actions are up to the caller. One version looks like this: // // /----------------------------------------\ // | |icon| You stopped using Google [x] | @@ -652,11 +684,15 @@ const wchar_t kHelpCenterUrl[] = class TryChromeDialog : public views::ButtonListener, public views::LinkController { public: - TryChromeDialog() - : popup_(NULL), + TryChromeDialog(size_t version) + : version_(version), + popup_(NULL), try_chrome_(NULL), kill_chrome_(NULL), result_(Upgrade::TD_LAST_ENUM) { + // In case of doubt, use the first version of the dialog. + if (version_ >= arraysize(kHeading)) + version_ = 0; } virtual ~TryChromeDialog() { @@ -738,7 +774,8 @@ class TryChromeDialog : public views::ButtonListener, // First row views. layout->StartRow(0, 0); layout->AddView(icon); - views::Label* label = new views::Label(kHeading); + views::Label* label = + new views::Label(kHeading[kDialogVersion[version_].heading_index]); label->SetFont(rb.GetFont(ResourceBundle::MediumBoldFont)); label->SetMultiLine(true); label->SizeToFit(200); @@ -754,17 +791,24 @@ class TryChromeDialog : public views::ButtonListener, close_button->set_tag(BT_CLOSE_BUTTON); layout->AddView(close_button); // Second row views. - layout->StartRowWithPadding(0, 1, 0, 10); - try_chrome_ = new views::RadioButton(kGiveChromeATry, 1); - try_chrome_->SetChecked(true); - layout->AddView(try_chrome_); + if (kDialogVersion[version_].try_index >= 0) { + layout->StartRowWithPadding(0, 1, 0, 10); + try_chrome_ = new views::RadioButton( + kGiveChromeATry[kDialogVersion[version_].try_index], 1); + try_chrome_->SetChecked(true); + layout->AddView(try_chrome_); + } // Third row views. - layout->StartRow(0, 2); - kill_chrome_ = new views::RadioButton(kNahUninstallIt, 1); - layout->AddView(kill_chrome_); + if (kDialogVersion[version_].try_index >= 0) { + layout->StartRow(0, 2); + kill_chrome_ = new views::RadioButton( + kNahUninstallIt[kDialogVersion[version_].uninstall_index], 1); + layout->AddView(kill_chrome_); + } // Fourth row views. layout->StartRowWithPadding(0, 3, 0, 10); - views::Button* accept_button = new views::NativeButton(this, kOKButn); + views::Button* accept_button = new views::NativeButton(this, + kOKButn[kDialogVersion[version_].ok_button_index]); accept_button->set_tag(BT_OK_BUTTON); layout->AddView(accept_button); views::Button* cancel_button = new views::NativeButton(this, kDontBugMe); @@ -799,8 +843,13 @@ class TryChromeDialog : public views::ButtonListener, // end the modal loop. virtual void ButtonPressed(views::Button* sender, const views::Event& event) { if (sender->tag() == BT_CLOSE_BUTTON) { + // The user pressed cancel or the [x] button. result_ = Upgrade::TD_NOT_NOW; + } else if (!try_chrome_) { + // We don't have radio buttons, the user pressed ok. + result_ = Upgrade::TD_TRY_CHROME; } else { + // The outcome is according to the selected ratio button. result_ = try_chrome_->checked() ? Upgrade::TD_TRY_CHROME : Upgrade::TD_UNINSTALL_CHROME; } @@ -856,6 +905,9 @@ class TryChromeDialog : public views::ButtonListener, ::SetWindowRgn(window, region, FALSE); } + // controls which version of the text to use. + size_t version_; + // We don't own any of this pointers. The |popup_| owns itself and owns // the other views. views::WidgetWin* popup_; @@ -868,7 +920,7 @@ class TryChromeDialog : public views::ButtonListener, } // namespace -Upgrade::TryResult Upgrade::ShowTryChromeDialog() { - TryChromeDialog td; +Upgrade::TryResult Upgrade::ShowTryChromeDialog(size_t version) { + TryChromeDialog td(version); return td.ShowModal(); } diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc index 4357d99..9b1ed6d 100644 --- a/chrome/common/temp_scaffolding_stubs.cc +++ b/chrome/common/temp_scaffolding_stubs.cc @@ -176,7 +176,7 @@ bool Upgrade::SwapNewChromeExeIfPresent() { } // static -Upgrade::TryResult ShowTryChromeDialog() { +Upgrade::TryResult ShowTryChromeDialog(size_t version) { return Upgrade::TD_NOT_NOW; } |