| OLD | NEW |
| 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/startup/session_crashed_infobar_delegate.h" | 5 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/app/vector_icons/vector_icons.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/search.h" | 11 #include "chrome/browser/search/search.h" |
| 11 #include "chrome/browser/sessions/session_restore.h" | 12 #include "chrome/browser/sessions/session_restore.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_finder.h" | 14 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 15 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 16 #include "chrome/grit/chromium_strings.h" | 17 #include "chrome/grit/chromium_strings.h" |
| 17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 18 #include "components/infobars/core/infobar.h" | 19 #include "components/infobars/core/infobar.h" |
| 19 #include "components/strings/grit/components_chromium_strings.h" | 20 #include "components/strings/grit/components_chromium_strings.h" |
| 20 #include "components/strings/grit/components_strings.h" | 21 #include "components/strings/grit/components_strings.h" |
| 21 #include "content/public/browser/dom_storage_context.h" | 22 #include "content/public/browser/dom_storage_context.h" |
| 22 #include "content/public/browser/storage_partition.h" | 23 #include "content/public/browser/storage_partition.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/gfx/vector_icons_public.h" | |
| 25 | 25 |
| 26 // static | 26 // static |
| 27 void SessionCrashedInfoBarDelegate::Create(Browser* browser) { | 27 void SessionCrashedInfoBarDelegate::Create(Browser* browser) { |
| 28 // Assume that if the user is launching incognito they were previously running | 28 // Assume that if the user is launching incognito they were previously running |
| 29 // incognito so that we have nothing to restore from. | 29 // incognito so that we have nothing to restore from. |
| 30 // Also, in ChromeBot tests, there might be a race. This code appears to be | 30 // Also, in ChromeBot tests, there might be a race. This code appears to be |
| 31 // called during shutdown when there is no active WebContents. | 31 // called during shutdown when there is no active WebContents. |
| 32 Profile* profile = browser->profile(); | 32 Profile* profile = browser->profile(); |
| 33 content::WebContents* web_contents = | 33 content::WebContents* web_contents = |
| 34 browser->tab_strip_model()->GetActiveWebContents(); | 34 browser->tab_strip_model()->GetActiveWebContents(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 55 content::BrowserContext::GetDefaultStoragePartition(profile_)-> | 55 content::BrowserContext::GetDefaultStoragePartition(profile_)-> |
| 56 GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); | 56 GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 infobars::InfoBarDelegate::InfoBarIdentifier | 60 infobars::InfoBarDelegate::InfoBarIdentifier |
| 61 SessionCrashedInfoBarDelegate::GetIdentifier() const { | 61 SessionCrashedInfoBarDelegate::GetIdentifier() const { |
| 62 return SESSION_CRASHED_INFOBAR_DELEGATE; | 62 return SESSION_CRASHED_INFOBAR_DELEGATE; |
| 63 } | 63 } |
| 64 | 64 |
| 65 gfx::VectorIconId SessionCrashedInfoBarDelegate::GetVectorIconId() const { | 65 const gfx::VectorIcon& SessionCrashedInfoBarDelegate::GetVectorIcon() const { |
| 66 return gfx::VectorIconId::SAD_TAB; | 66 return kSadTabIcon; |
| 67 } | 67 } |
| 68 | 68 |
| 69 base::string16 SessionCrashedInfoBarDelegate::GetMessageText() const { | 69 base::string16 SessionCrashedInfoBarDelegate::GetMessageText() const { |
| 70 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE); | 70 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE); |
| 71 } | 71 } |
| 72 | 72 |
| 73 int SessionCrashedInfoBarDelegate::GetButtons() const { | 73 int SessionCrashedInfoBarDelegate::GetButtons() const { |
| 74 return BUTTON_OK; | 74 return BUTTON_OK; |
| 75 } | 75 } |
| 76 | 76 |
| 77 base::string16 SessionCrashedInfoBarDelegate::GetButtonLabel( | 77 base::string16 SessionCrashedInfoBarDelegate::GetButtonLabel( |
| 78 InfoBarButton button) const { | 78 InfoBarButton button) const { |
| 79 DCHECK_EQ(BUTTON_OK, button); | 79 DCHECK_EQ(BUTTON_OK, button); |
| 80 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); | 80 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); |
| 81 } | 81 } |
| 82 | 82 |
| 83 bool SessionCrashedInfoBarDelegate::Accept() { | 83 bool SessionCrashedInfoBarDelegate::Accept() { |
| 84 Browser* browser = chrome::FindBrowserWithWebContents( | 84 Browser* browser = chrome::FindBrowserWithWebContents( |
| 85 InfoBarService::WebContentsFromInfoBar(infobar())); | 85 InfoBarService::WebContentsFromInfoBar(infobar())); |
| 86 SessionRestore::RestoreSessionAfterCrash(browser); | 86 SessionRestore::RestoreSessionAfterCrash(browser); |
| 87 accepted_ = true; | 87 accepted_ = true; |
| 88 return true; | 88 return true; |
| 89 } | 89 } |
| OLD | NEW |