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

Side by Side Diff: chrome/browser/ui/browser_init.cc

Issue 7857014: patch for global error bubbles (view/gtk) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/browser_init.h" 5 #include "chrome/browser/ui/browser_init.h"
6 6
7 #include <algorithm> // For max(). 7 #include <algorithm> // For max().
8 8
9 #include "base/timer.h"
9 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
10 #include "base/environment.h" 11 #include "base/environment.h"
11 #include "base/event_recorder.h" 12 #include "base/event_recorder.h"
12 #include "base/file_path.h" 13 #include "base/file_path.h"
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
15 #include "base/path_service.h" 16 #include "base/path_service.h"
16 #include "base/string_number_conversions.h" 17 #include "base/string_number_conversions.h"
17 #include "base/string_split.h" 18 #include "base/string_split.h"
18 #include "base/threading/thread_restrictions.h" 19 #include "base/threading/thread_restrictions.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "chrome/browser/sessions/session_service_factory.h" 51 #include "chrome/browser/sessions/session_service_factory.h"
51 #include "chrome/browser/shell_integration.h" 52 #include "chrome/browser/shell_integration.h"
52 #include "chrome/browser/tab_contents/link_infobar_delegate.h" 53 #include "chrome/browser/tab_contents/link_infobar_delegate.h"
53 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 54 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
54 #include "chrome/browser/tabs/pinned_tab_codec.h" 55 #include "chrome/browser/tabs/pinned_tab_codec.h"
55 #include "chrome/browser/tabs/tab_strip_model.h" 56 #include "chrome/browser/tabs/tab_strip_model.h"
56 #include "chrome/browser/ui/browser_list.h" 57 #include "chrome/browser/ui/browser_list.h"
57 #include "chrome/browser/ui/browser_navigator.h" 58 #include "chrome/browser/ui/browser_navigator.h"
58 #include "chrome/browser/ui/browser_window.h" 59 #include "chrome/browser/ui/browser_window.h"
59 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 60 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
61 #include "chrome/browser/ui/global_error_delegate.h"
62 #include "chrome/browser/ui/global_error_service.h"
63 #include "chrome/browser/ui/global_error_service_factory.h"
60 #include "chrome/common/chrome_constants.h" 64 #include "chrome/common/chrome_constants.h"
61 #include "chrome/common/chrome_paths.h" 65 #include "chrome/common/chrome_paths.h"
62 #include "chrome/common/chrome_result_codes.h" 66 #include "chrome/common/chrome_result_codes.h"
63 #include "chrome/common/chrome_switches.h" 67 #include "chrome/common/chrome_switches.h"
64 #include "chrome/common/extensions/extension_constants.h" 68 #include "chrome/common/extensions/extension_constants.h"
65 #include "chrome/common/pref_names.h" 69 #include "chrome/common/pref_names.h"
66 #include "chrome/common/url_constants.h" 70 #include "chrome/common/url_constants.h"
67 #include "chrome/installer/util/browser_distribution.h" 71 #include "chrome/installer/util/browser_distribution.h"
68 #include "content/browser/browser_thread.h" 72 #include "content/browser/browser_thread.h"
69 #include "content/browser/child_process_security_policy.h" 73 #include "content/browser/child_process_security_policy.h"
(...skipping 1020 matching lines...) Expand 10 before | Expand all | Expand 10 after
1090 if (!browser || !profile_ || browser->tab_count() == 0) 1094 if (!browser || !profile_ || browser->tab_count() == 0)
1091 return; 1095 return;
1092 1096
1093 TabContentsWrapper* tab_contents = browser->GetSelectedTabContentsWrapper(); 1097 TabContentsWrapper* tab_contents = browser->GetSelectedTabContentsWrapper();
1094 AddCrashedInfoBarIfNecessary(browser, tab_contents); 1098 AddCrashedInfoBarIfNecessary(browser, tab_contents);
1095 AddBadFlagsInfoBarIfNecessary(tab_contents); 1099 AddBadFlagsInfoBarIfNecessary(tab_contents);
1096 AddDNSCertProvenanceCheckingWarningInfoBarIfNecessary(tab_contents); 1100 AddDNSCertProvenanceCheckingWarningInfoBarIfNecessary(tab_contents);
1097 AddObsoleteSystemInfoBarIfNecessary(tab_contents); 1101 AddObsoleteSystemInfoBarIfNecessary(tab_contents);
1098 } 1102 }
1099 1103
1104 class TestError : public GlobalErrorDelegate {
1105 bool HasBadge() { return true; }
1106 bool HasMenuItem() { return true; }
1107 int MenuItemCommandID() { return 123456; }
1108 string16 MenuItemLabel() { return UTF8ToUTF16("Hello world"); }
1109 void ExecuteMenuItem(Browser* browser) { fprintf(stderr, "%s\n", __func__); }
1110
1111 virtual bool HasBubbleView() { return true; }
1112 virtual string16 GetBubbleViewTitle() {
1113 return UTF8ToUTF16("Error Title");
1114 }
1115 virtual string16 GetBubbleViewMessage() {
1116 return UTF8ToUTF16("Your sparble needs fargling - "
1117 "marble tarble warble faable?");
1118 }
1119 virtual string16 GetBubbleViewAcceptButtonLabel() {
1120 return UTF8ToUTF16("Nargle");
1121 }
1122 virtual string16 GetBubbleViewCancelButtonLabel() {
1123 return UTF8ToUTF16("Cancel");
1124 }
1125 virtual void BubbleViewDidClose() { }
1126 virtual void BubbleViewAcceptButtonPressed() {
1127 fprintf(stderr, "%s\n", __func__);
1128 }
1129 virtual void BubbleViewCancelButtonPressed() {
1130 fprintf(stderr, "%s\n", __func__);
1131 }
1132
1133 public:
1134 void OnTimer() {
1135 gfx::Rect rect;
1136 Browser* browser = BrowserList::GetLastActive();
1137 ShowBubbleView(browser, rect);
1138 }
1139
1140 base::OneShotTimer<TestError> timer_;
1141 };
1142
1100 void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary( 1143 void BrowserInit::LaunchWithProfile::AddCrashedInfoBarIfNecessary(
1101 Browser* browser, 1144 Browser* browser,
1102 TabContentsWrapper* tab) { 1145 TabContentsWrapper* tab) {
1146 fprintf(stderr, "%s\n", __func__);
1147 TestError* error = new TestError();
1148 GlobalErrorServiceFactory::GetForProfile(
1149 browser->profile())->AddGlobalError(error);
1150 error->timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(2000), error,
1151 &TestError::OnTimer);
1152
1153
1103 // Assume that if the user is launching incognito they were previously 1154 // Assume that if the user is launching incognito they were previously
1104 // running incognito so that we have nothing to restore from. 1155 // running incognito so that we have nothing to restore from.
1105 if (!profile_->DidLastSessionExitCleanly() && !profile_->IsOffTheRecord()) { 1156 if (!profile_->DidLastSessionExitCleanly() && !profile_->IsOffTheRecord()) {
1106 // The last session didn't exit cleanly. Show an infobar to the user 1157 // The last session didn't exit cleanly. Show an infobar to the user
1107 // so that they can restore if they want. The delegate deletes itself when 1158 // so that they can restore if they want. The delegate deletes itself when
1108 // it is closed. 1159 // it is closed.
1109 tab->infobar_tab_helper()->AddInfoBar( 1160 tab->infobar_tab_helper()->AddInfoBar(
1110 new SessionCrashedInfoBarDelegate(profile_, tab->tab_contents())); 1161 new SessionCrashedInfoBarDelegate(profile_, tab->tab_contents()));
1111 } 1162 }
1112 } 1163 }
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 return false; 1552 return false;
1502 automation->SetExpectedTabCount(expected_tabs); 1553 automation->SetExpectedTabCount(expected_tabs);
1503 1554
1504 AutomationProviderList* list = 1555 AutomationProviderList* list =
1505 g_browser_process->InitAutomationProviderList(); 1556 g_browser_process->InitAutomationProviderList();
1506 DCHECK(list); 1557 DCHECK(list);
1507 list->AddProvider(automation); 1558 list->AddProvider(automation);
1508 1559
1509 return true; 1560 return true;
1510 } 1561 }
OLDNEW
« no previous file with comments | « chrome/app/nibs/GlobalErrorBubble.xib ('k') | chrome/browser/ui/cocoa/global_error_bubble_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698