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

Side by Side Diff: chrome/browser/ui/startup/session_crashed_prompt.cc

Issue 10837230: Move StoragePartition into content/public and remove BrowserContext::GetDOMStorageContext(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove DISALLOW_COPY_AND_ASSIGN, and change RPH::CreateMessageFilters() to not suddenly isolate all… Created 8 years, 4 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 | Annotate | Revision Log
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/startup/session_crashed_prompt.h" 5 #include "chrome/browser/ui/startup/session_crashed_prompt.h"
6 6
7 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" 7 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h"
8 #include "chrome/browser/infobars/infobar_tab_helper.h" 8 #include "chrome/browser/infobars/infobar_tab_helper.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.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/browser_tabstrip.h" 13 #include "chrome/browser/ui/browser_tabstrip.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents.h" 14 #include "chrome/browser/ui/tab_contents/tab_contents.h"
15 #include "chrome/common/chrome_notification_types.h" 15 #include "chrome/common/chrome_notification_types.h"
16 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
17 #include "content/public/browser/dom_storage_context.h" 17 #include "content/public/browser/dom_storage_context.h"
18 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/storage_partition.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "grit/chromium_strings.h" 21 #include "grit/chromium_strings.h"
21 #include "grit/generated_resources.h" 22 #include "grit/generated_resources.h"
22 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
23 #include "ui/base/l10n/l10n_util.h" 24 #include "ui/base/l10n/l10n_util.h"
24 #include "ui/base/resource/resource_bundle.h" 25 #include "ui/base/resource/resource_bundle.h"
25 26
26 namespace { 27 namespace {
27 28
28 // A delegate for the InfoBar shown when the previous session has crashed. 29 // A delegate for the InfoBar shown when the previous session has crashed.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // initiate the session storage scavenging only in the destructor. (Currently, 66 // initiate the session storage scavenging only in the destructor. (Currently,
66 // info bars are leaked if they get closed while they're in background tabs.) 67 // info bars are leaked if they get closed while they're in background tabs.)
67 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, 68 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
68 content::NotificationService::AllSources()); 69 content::NotificationService::AllSources());
69 } 70 }
70 71
71 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { 72 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
72 // If the info bar wasn't accepted, it was either dismissed or expired. In 73 // If the info bar wasn't accepted, it was either dismissed or expired. In
73 // that case, session restore won't happen. 74 // that case, session restore won't happen.
74 if (!accepted_ && !removed_notification_received_) { 75 if (!accepted_ && !removed_notification_received_) {
75 content::BrowserContext::GetDefaultDOMStorageContext( 76 content::BrowserContext::GetDefaultStoragePartition(browser_->profile())->
76 browser_->profile())->StartScavengingUnusedSessionStorage(); 77 GetDOMStorageContext()->StartScavengingUnusedSessionStorage();
77 } 78 }
78 } 79 }
79 80
80 gfx::Image* SessionCrashedInfoBarDelegate::GetIcon() const { 81 gfx::Image* SessionCrashedInfoBarDelegate::GetIcon() const {
81 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 82 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
82 IDR_INFOBAR_RESTORE_SESSION); 83 IDR_INFOBAR_RESTORE_SESSION);
83 } 84 }
84 85
85 string16 SessionCrashedInfoBarDelegate::GetMessageText() const { 86 string16 SessionCrashedInfoBarDelegate::GetMessageText() const {
86 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE); 87 return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE);
(...skipping 26 matching lines...) Expand all
113 114
114 void SessionCrashedInfoBarDelegate::Observe( 115 void SessionCrashedInfoBarDelegate::Observe(
115 int type, 116 int type,
116 const content::NotificationSource& source, 117 const content::NotificationSource& source,
117 const content::NotificationDetails& details) { 118 const content::NotificationDetails& details) {
118 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); 119 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED);
119 if (content::Details<std::pair<InfoBarDelegate*, bool> >(details)->first != 120 if (content::Details<std::pair<InfoBarDelegate*, bool> >(details)->first !=
120 this) 121 this)
121 return; 122 return;
122 if (!accepted_) { 123 if (!accepted_) {
123 content::BrowserContext::GetDefaultDOMStorageContext( 124 content::BrowserContext::GetDefaultStoragePartition(browser_->profile())->
124 browser_->profile())->StartScavengingUnusedSessionStorage(); 125 GetDOMStorageContext()->StartScavengingUnusedSessionStorage();
125 removed_notification_received_ = true; 126 removed_notification_received_ = true;
126 } 127 }
127 } 128 }
128 129
129 } // namespace 130 } // namespace
130 131
131 namespace chrome { 132 namespace chrome {
132 133
133 void ShowSessionCrashedPrompt(Browser* browser) { 134 void ShowSessionCrashedPrompt(Browser* browser) {
134 // Assume that if the user is launching incognito they were previously 135 // Assume that if the user is launching incognito they were previously
135 // running incognito so that we have nothing to restore from. 136 // running incognito so that we have nothing to restore from.
136 if (browser->profile()->IsOffTheRecord()) 137 if (browser->profile()->IsOffTheRecord())
137 return; 138 return;
138 139
139 // In ChromeBot tests, there might be a race. This line appears to get 140 // In ChromeBot tests, there might be a race. This line appears to get
140 // called during shutdown and |tab| can be NULL. 141 // called during shutdown and |tab| can be NULL.
141 TabContents* tab = chrome::GetActiveTabContents(browser); 142 TabContents* tab = chrome::GetActiveTabContents(browser);
142 if (!tab) 143 if (!tab)
143 return; 144 return;
144 145
145 // Don't show the info-bar if there are already info-bars showing. 146 // Don't show the info-bar if there are already info-bars showing.
146 if (tab->infobar_tab_helper()->infobar_count() > 0) 147 if (tab->infobar_tab_helper()->infobar_count() > 0)
147 return; 148 return;
148 149
149 tab->infobar_tab_helper()->AddInfoBar( 150 tab->infobar_tab_helper()->AddInfoBar(
150 new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper())); 151 new SessionCrashedInfoBarDelegate(tab->infobar_tab_helper()));
151 } 152 }
152 153
153 } // namespace chrome 154 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore.cc ('k') | chrome/browser/ui/startup/startup_browser_creator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698