Index: chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc |
diff --git a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc |
index 42ae188e229b87be87f93d236ee9a4b3ecab198d..6450600611ebf5084f7f1ba70469d2f7eb8384b9 100644 |
--- a/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc |
+++ b/chrome/browser/ui/extensions/app_metro_infobar_delegate_win.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/ui/extensions/app_metro_infobar_delegate_win.h" |
+#include "apps/pref_names.h" |
#include "base/bind_helpers.h" |
#include "base/message_loop.h" |
#include "base/prefs/pref_service.h" |
@@ -25,7 +26,9 @@ |
namespace chrome { |
-void AppMetroInfoBarDelegateWin::CreateAndActivateMetro(Profile* profile) { |
+// static |
+void AppMetroInfoBarDelegateWin::CreateAndActivateMetroHelper( |
+ Profile* profile, Mode mode, const std::string& extension_id) { |
// Chrome should never get here via the Ash desktop, so only look for browsers |
// on the native desktop. |
CHECK(win8::IsSingleWindowMetroMode()); |
@@ -41,8 +44,8 @@ void AppMetroInfoBarDelegateWin::CreateAndActivateMetro(Profile* profile) { |
content::WebContents* web_contents = browser->OpenURL(params); |
InfoBarService* info_bar_service = |
InfoBarService::FromWebContents(web_contents); |
- info_bar_service->AddInfoBar(scoped_ptr<InfoBarDelegate>( |
- new AppMetroInfoBarDelegateWin(info_bar_service))); |
+ info_bar_service->AddInfoBar(scoped_ptr<AppMetroInfoBarDelegateWin>( |
+ new AppMetroInfoBarDelegateWin(info_bar_service, mode, extension_id))); |
// Use PostTask because we can get here in a COM SendMessage, and |
// ActivateApplication can not be sent nested (returns error |
@@ -52,9 +55,26 @@ void AppMetroInfoBarDelegateWin::CreateAndActivateMetro(Profile* profile) { |
base::Bind(base::IgnoreResult(chrome::ActivateMetroChrome))); |
} |
+// static |
+void AppMetroInfoBarDelegateWin::CreateAndActivateMetroForAppList( |
+ Profile* profile) { |
+ CreateAndActivateMetroHelper(profile, SHOW_APP_LIST, std::string()); |
+} |
+ |
+// static |
+void AppMetroInfoBarDelegateWin::CreateAndActivateMetroForApp( |
+ Profile* profile, const std::string& extension_id) { |
+ CreateAndActivateMetroHelper(profile, LAUNCH_PACKAGED_APP, extension_id); |
+} |
+ |
AppMetroInfoBarDelegateWin::AppMetroInfoBarDelegateWin( |
- InfoBarService* info_bar_service) |
- : ConfirmInfoBarDelegate(info_bar_service) { |
+ InfoBarService* info_bar_service, |
+ Mode mode, |
+ const std::string& extension_id) |
+ : ConfirmInfoBarDelegate(info_bar_service), |
+ mode_(mode), |
+ extension_id_(extension_id) { |
+ CHECK_EQ(mode_ == SHOW_APP_LIST, extension_id_.empty()); |
benwells
2013/03/15 00:39:04
Why CHECK not DCHECK?
tapted
2013/03/15 00:51:16
It has no coverage in debug mode.. (cpu@ earlier s
|
} |
AppMetroInfoBarDelegateWin::~AppMetroInfoBarDelegateWin() {} |
@@ -65,7 +85,9 @@ gfx::Image* AppMetroInfoBarDelegateWin::GetIcon() const { |
string16 AppMetroInfoBarDelegateWin::GetMessageText() const { |
return l10n_util::GetStringUTF16( |
- IDS_WIN8_INFOBAR_DESKTOP_RESTART_TO_LAUNCH_APPS); |
+ mode_ == SHOW_APP_LIST ? |
+ IDS_WIN8_INFOBAR_DESKTOP_RESTART_FOR_APP_LIST : |
benwells
2013/03/15 00:39:04
indenting
tapted
2013/03/15 00:51:16
Done.
|
+ IDS_WIN8_INFOBAR_DESKTOP_RESTART_FOR_PACKAGED_APP); |
} |
int AppMetroInfoBarDelegateWin::GetButtons() const { |
@@ -84,9 +106,15 @@ string16 AppMetroInfoBarDelegateWin::GetButtonLabel( |
} |
bool AppMetroInfoBarDelegateWin::Accept() { |
- owner()->GetWebContents()->Close(); |
PrefService* prefs = g_browser_process->local_state(); |
- prefs->SetBoolean(prefs::kRestartWithAppList, true); |
+ if (mode_ == SHOW_APP_LIST) { |
+ prefs->SetBoolean(prefs::kRestartWithAppList, true); |
+ } else { |
+ prefs->SetString(apps::prefs::kRestartFromMetroWithAppLaunch, |
+ extension_id_); |
+ } |
+ |
+ owner()->GetWebContents()->Close(); // Note: deletes |this|. |
chrome::AttemptRestartWithModeSwitch(); |
return false; |
} |