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

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

Issue 190063006: Infobar Componentization Proof of Concept (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor fixes Created 6 years, 9 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
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_infobar_delegate.h" 5 #include "chrome/browser/ui/startup/session_crashed_infobar_delegate.h"
6 6
7 #include "chrome/browser/infobars/infobar.h" 7 #include "chrome/browser/infobars/infobar.h"
8 #include "chrome/browser/infobars/infobar_manager.h"
9 #include "chrome/browser/infobars/infobar_service.h"
8 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/search/search.h" 11 #include "chrome/browser/search/search.h"
10 #include "chrome/browser/sessions/session_restore.h" 12 #include "chrome/browser/sessions/session_restore.h"
11 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" 15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
14 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
15 #include "content/public/browser/dom_storage_context.h" 17 #include "content/public/browser/dom_storage_context.h"
16 #include "content/public/browser/storage_partition.h" 18 #include "content/public/browser/storage_partition.h"
17 #include "grit/chromium_strings.h" 19 #include "grit/chromium_strings.h"
18 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
19 #include "grit/theme_resources.h" 21 #include "grit/theme_resources.h"
20 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
21 23
22 24
23 // static 25 // static
24 void SessionCrashedInfoBarDelegate::Create(Browser* browser) { 26 void SessionCrashedInfoBarDelegate::Create(Browser* browser) {
25 // Assume that if the user is launching incognito they were previously running 27 // Assume that if the user is launching incognito they were previously running
26 // incognito so that we have nothing to restore from. 28 // incognito so that we have nothing to restore from.
27 // Also, in ChromeBot tests, there might be a race. This code appears to be 29 // Also, in ChromeBot tests, there might be a race. This code appears to be
28 // called during shutdown when there is no active WebContents. 30 // called during shutdown when there is no active WebContents.
29 Profile* profile = browser->profile(); 31 Profile* profile = browser->profile();
30 content::WebContents* web_contents = 32 content::WebContents* web_contents =
31 browser->tab_strip_model()->GetActiveWebContents(); 33 browser->tab_strip_model()->GetActiveWebContents();
32 if (profile->IsOffTheRecord() || !web_contents) 34 if (profile->IsOffTheRecord() || !web_contents)
33 return; 35 return;
34 36
35 InfoBarService::FromWebContents(web_contents)->AddInfoBar( 37 InfoBarService::FromWebContents(web_contents)->AddInfoBar(
36 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>( 38 ConfirmInfoBarDelegate::CreateInfoBar(scoped_ptr<ConfirmInfoBarDelegate>(
37 new SessionCrashedInfoBarDelegate(profile)))); 39 new SessionCrashedInfoBarDelegate(profile, web_contents))));
38 } 40 }
39 41
40 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(Profile* profile) 42 SessionCrashedInfoBarDelegate::SessionCrashedInfoBarDelegate(
41 : ConfirmInfoBarDelegate(), 43 Profile* profile,
44 content::WebContents* web_contents)
45 : ContentConfirmInfoBarDelegate(web_contents),
42 accepted_(false), 46 accepted_(false),
43 profile_(profile) { 47 profile_(profile) {}
44 }
45 48
46 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() { 49 SessionCrashedInfoBarDelegate::~SessionCrashedInfoBarDelegate() {
47 // If the info bar wasn't accepted, it was either dismissed or expired. In 50 // If the info bar wasn't accepted, it was either dismissed or expired. In
48 // that case, session restore won't happen. 51 // that case, session restore won't happen.
49 if (!accepted_) { 52 if (!accepted_) {
50 content::BrowserContext::GetDefaultStoragePartition(profile_)-> 53 content::BrowserContext::GetDefaultStoragePartition(profile_)->
51 GetDOMStorageContext()->StartScavengingUnusedSessionStorage(); 54 GetDOMStorageContext()->StartScavengingUnusedSessionStorage();
52 } 55 }
53 } 56 }
54 57
(...skipping 27 matching lines...) Expand all
82 // clobber it. 85 // clobber it.
83 behavior = SessionRestore::CLOBBER_CURRENT_TAB; 86 behavior = SessionRestore::CLOBBER_CURRENT_TAB;
84 } 87 }
85 } 88 }
86 SessionRestore::RestoreSession(browser->profile(), browser, 89 SessionRestore::RestoreSession(browser->profile(), browser,
87 browser->host_desktop_type(), behavior, 90 browser->host_desktop_type(), behavior,
88 std::vector<GURL>()); 91 std::vector<GURL>());
89 accepted_ = true; 92 accepted_ = true;
90 return true; 93 return true;
91 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698