| 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_prompt.h" | 5 #include "chrome/browser/ui/startup/session_crashed_prompt.h" |
| 6 | 6 |
| 7 #include "chrome/browser/infobars/infobar_service.h" | 7 #include "chrome/browser/infobars/infobar_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/search/search.h" | 9 #include "chrome/browser/search/search.h" |
| 10 #include "chrome/browser/sessions/session_restore.h" | 10 #include "chrome/browser/sessions/session_restore.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 14 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
| 15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 16 #include "content/public/browser/dom_storage_context.h" | 16 #include "content/public/browser/dom_storage_context.h" |
| 17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
| 18 #include "content/public/browser/storage_partition.h" | 18 #include "content/public/browser/storage_partition.h" |
| 19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "grit/chromium_strings.h" | 20 #include "grit/chromium_strings.h" |
| 21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 22 #include "grit/theme_resources.h" | 22 #include "grit/theme_resources.h" |
| 23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
| 24 #include "ui/base/resource/resource_bundle.h" | |
| 25 | 24 |
| 26 | 25 |
| 27 // static | 26 // static |
| 28 void SessionCrashedInfoBarDelegate::Create(Browser* browser) { | 27 void SessionCrashedInfoBarDelegate::Create(Browser* browser) { |
| 29 // Assume that if the user is launching incognito they were previously | 28 // Assume that if the user is launching incognito they were previously |
| 30 // running incognito so that we have nothing to restore from. | 29 // running incognito so that we have nothing to restore from. |
| 31 if (browser->profile()->IsOffTheRecord()) | 30 if (browser->profile()->IsOffTheRecord()) |
| 32 return; | 31 return; |
| 33 | 32 |
| 34 // In ChromeBot tests, there might be a race. This line appears to get | 33 // In ChromeBot tests, there might be a race. This line appears to get |
| (...skipping 25 matching lines...) Expand all Loading... |
| 60 | 59 |
| 61 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { | 60 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { |
| 62 // If the info bar wasn't accepted, it was either dismissed or expired. In | 61 // If the info bar wasn't accepted, it was either dismissed or expired. In |
| 63 // that case, session restore won't happen. | 62 // that case, session restore won't happen. |
| 64 if (!accepted_ && !removed_notification_received_) { | 63 if (!accepted_ && !removed_notification_received_) { |
| 65 content::BrowserContext::GetDefaultStoragePartition(profile_) | 64 content::BrowserContext::GetDefaultStoragePartition(profile_) |
| 66 ->GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); | 65 ->GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); |
| 67 } | 66 } |
| 68 } | 67 } |
| 69 | 68 |
| 70 gfx::Image* SessionCrashedInfoBarDelegate::GetIcon() const { | 69 int SessionCrashedInfoBarDelegate::GetIconID() const { |
| 71 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( | 70 return IDR_INFOBAR_RESTORE_SESSION; |
| 72 IDR_INFOBAR_RESTORE_SESSION); | |
| 73 } | 71 } |
| 74 | 72 |
| 75 string16 SessionCrashedInfoBarDelegate::GetMessageText() const { | 73 string16 SessionCrashedInfoBarDelegate::GetMessageText() const { |
| 76 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE); | 74 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE); |
| 77 } | 75 } |
| 78 | 76 |
| 79 int SessionCrashedInfoBarDelegate::GetButtons() const { | 77 int SessionCrashedInfoBarDelegate::GetButtons() const { |
| 80 return BUTTON_OK; | 78 return BUTTON_OK; |
| 81 } | 79 } |
| 82 | 80 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); | 112 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); |
| 115 if (content::Details<std::pair<InfoBarDelegate*, bool> >(details)->first != | 113 if (content::Details<std::pair<InfoBarDelegate*, bool> >(details)->first != |
| 116 this) | 114 this) |
| 117 return; | 115 return; |
| 118 if (!accepted_) { | 116 if (!accepted_) { |
| 119 content::BrowserContext::GetDefaultStoragePartition(profile_)-> | 117 content::BrowserContext::GetDefaultStoragePartition(profile_)-> |
| 120 GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); | 118 GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); |
| 121 removed_notification_received_ = true; | 119 removed_notification_received_ = true; |
| 122 } | 120 } |
| 123 } | 121 } |
| OLD | NEW |