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

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

Issue 7810002: Move infobar handling to a tab helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes 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
« no previous file with comments | « chrome/browser/ui/autologin_infobar_delegate.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.h" 5 #include "chrome/browser/ui/browser.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shellapi.h> 9 #include <shellapi.h>
10 #endif // OS_WIN 10 #endif // OS_WIN
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "chrome/browser/extensions/extension_host.h" 44 #include "chrome/browser/extensions/extension_host.h"
45 #include "chrome/browser/extensions/extension_prefs.h" 45 #include "chrome/browser/extensions/extension_prefs.h"
46 #include "chrome/browser/extensions/extension_service.h" 46 #include "chrome/browser/extensions/extension_service.h"
47 #include "chrome/browser/extensions/extension_tab_helper.h" 47 #include "chrome/browser/extensions/extension_tab_helper.h"
48 #include "chrome/browser/extensions/extension_tabs_module.h" 48 #include "chrome/browser/extensions/extension_tabs_module.h"
49 #include "chrome/browser/favicon/favicon_tab_helper.h" 49 #include "chrome/browser/favicon/favicon_tab_helper.h"
50 #include "chrome/browser/file_select_helper.h" 50 #include "chrome/browser/file_select_helper.h"
51 #include "chrome/browser/first_run/first_run.h" 51 #include "chrome/browser/first_run/first_run.h"
52 #include "chrome/browser/google/google_url_tracker.h" 52 #include "chrome/browser/google/google_url_tracker.h"
53 #include "chrome/browser/google/google_util.h" 53 #include "chrome/browser/google/google_util.h"
54 #include "chrome/browser/infobars/infobar_tab_helper.h"
54 #include "chrome/browser/instant/instant_controller.h" 55 #include "chrome/browser/instant/instant_controller.h"
55 #include "chrome/browser/instant/instant_unload_handler.h" 56 #include "chrome/browser/instant/instant_unload_handler.h"
56 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h" 57 #include "chrome/browser/intents/register_intent_handler_infobar_delegate.h"
57 #include "chrome/browser/net/browser_url_util.h" 58 #include "chrome/browser/net/browser_url_util.h"
58 #include "chrome/browser/net/url_fixer_upper.h" 59 #include "chrome/browser/net/url_fixer_upper.h"
59 #include "chrome/browser/notifications/notification_ui_manager.h" 60 #include "chrome/browser/notifications/notification_ui_manager.h"
60 #include "chrome/browser/platform_util.h" 61 #include "chrome/browser/platform_util.h"
61 #include "chrome/browser/prefs/incognito_mode_prefs.h" 62 #include "chrome/browser/prefs/incognito_mode_prefs.h"
62 #include "chrome/browser/prefs/pref_service.h" 63 #include "chrome/browser/prefs/pref_service.h"
63 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" 64 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 file_select_helper->EnumerateDirectory(request_id, 2425 file_select_helper->EnumerateDirectory(request_id,
2425 tab->render_view_host(), 2426 tab->render_view_host(),
2426 path); 2427 path);
2427 } 2428 }
2428 2429
2429 // static 2430 // static
2430 void Browser::JSOutOfMemoryHelper(TabContents* tab) { 2431 void Browser::JSOutOfMemoryHelper(TabContents* tab) {
2431 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( 2432 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents(
2432 tab); 2433 tab);
2433 if (tcw) { 2434 if (tcw) {
2434 tcw->AddInfoBar(new SimpleAlertInfoBarDelegate( 2435 tcw->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate(
2435 tab, NULL, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), 2436 tab, NULL, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT),
2436 true)); 2437 true));
2437 } 2438 }
2438 } 2439 }
2439 2440
2440 // static 2441 // static
2441 void Browser::RegisterProtocolHandlerHelper(TabContents* tab, 2442 void Browser::RegisterProtocolHandlerHelper(TabContents* tab,
2442 const std::string& protocol, 2443 const std::string& protocol,
2443 const GURL& url, 2444 const GURL& url,
2444 const string16& title) { 2445 const string16& title) {
(...skipping 13 matching lines...) Expand all
2458 ProtocolHandlerRegistry* registry = 2459 ProtocolHandlerRegistry* registry =
2459 tcw->profile()->GetProtocolHandlerRegistry(); 2460 tcw->profile()->GetProtocolHandlerRegistry();
2460 if (!registry->enabled() || registry->IsRegistered(handler) || 2461 if (!registry->enabled() || registry->IsRegistered(handler) ||
2461 registry->IsIgnored(handler)) 2462 registry->IsIgnored(handler))
2462 return; 2463 return;
2463 2464
2464 if (!handler.IsEmpty() && 2465 if (!handler.IsEmpty() &&
2465 registry->CanSchemeBeOverridden(handler.protocol())) { 2466 registry->CanSchemeBeOverridden(handler.protocol())) {
2466 UserMetrics::RecordAction( 2467 UserMetrics::RecordAction(
2467 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); 2468 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown"));
2468 tcw->AddInfoBar(new RegisterProtocolHandlerInfoBarDelegate(tab, 2469 tcw->infobar_tab_helper()->AddInfoBar(
2469 registry, 2470 new RegisterProtocolHandlerInfoBarDelegate(tab, registry, handler));
2470 handler));
2471 } 2471 }
2472 } 2472 }
2473 2473
2474 // static 2474 // static
2475 void Browser::RegisterIntentHandlerHelper(TabContents* tab, 2475 void Browser::RegisterIntentHandlerHelper(TabContents* tab,
2476 const string16& action, 2476 const string16& action,
2477 const string16& type, 2477 const string16& type,
2478 const string16& href, 2478 const string16& href,
2479 const string16& title) { 2479 const string16& title) {
2480 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( 2480 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents(
2481 tab); 2481 tab);
2482 if (!tcw || tcw->profile()->IsOffTheRecord()) 2482 if (!tcw || tcw->profile()->IsOffTheRecord())
2483 return; 2483 return;
2484 2484
2485 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) 2485 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
2486 return; 2486 return;
2487 2487
2488 GURL service_url(href); 2488 GURL service_url(href);
2489 if (!service_url.is_valid()) { 2489 if (!service_url.is_valid()) {
2490 const GURL& url = tab->GetURL(); 2490 const GURL& url = tab->GetURL();
2491 service_url = url.Resolve(href); 2491 service_url = url.Resolve(href);
2492 } 2492 }
2493 2493
2494 WebIntentData intent; 2494 WebIntentData intent;
2495 intent.service_url = service_url; 2495 intent.service_url = service_url;
2496 intent.action = action; 2496 intent.action = action;
2497 intent.type = type; 2497 intent.type = type;
2498 intent.title = title; 2498 intent.title = title;
2499 tcw->AddInfoBar(new RegisterIntentHandlerInfoBarDelegate(tab, intent)); 2499 tcw->infobar_tab_helper()->AddInfoBar(
2500 new RegisterIntentHandlerInfoBarDelegate(tab, intent));
2500 } 2501 }
2501 2502
2502 // static 2503 // static
2503 void Browser::WebIntentDispatchHelper(TabContents* tab, 2504 void Browser::WebIntentDispatchHelper(TabContents* tab,
2504 int routing_id, 2505 int routing_id,
2505 const string16& action, 2506 const string16& action,
2506 const string16& type, 2507 const string16& type,
2507 const string16& data, 2508 const string16& data,
2508 int intent_id) { 2509 int intent_id) {
2509 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) 2510 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after
3694 browser::ShowHungRendererDialog(source); 3695 browser::ShowHungRendererDialog(source);
3695 } 3696 }
3696 3697
3697 void Browser::RendererResponsive(TabContents* source) { 3698 void Browser::RendererResponsive(TabContents* source) {
3698 browser::HideHungRendererDialog(source); 3699 browser::HideHungRendererDialog(source);
3699 } 3700 }
3700 3701
3701 void Browser::WorkerCrashed(TabContents* source) { 3702 void Browser::WorkerCrashed(TabContents* source) {
3702 TabContentsWrapper* wrapper = 3703 TabContentsWrapper* wrapper =
3703 TabContentsWrapper::GetCurrentWrapperForContents(source); 3704 TabContentsWrapper::GetCurrentWrapperForContents(source);
3704 wrapper->AddInfoBar(new SimpleAlertInfoBarDelegate( 3705 wrapper->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate(
3705 source, NULL, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), 3706 source, NULL, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT),
3706 true)); 3707 true));
3707 } 3708 }
3708 3709
3709 void Browser::DidNavigateMainFramePostCommit(TabContents* tab) { 3710 void Browser::DidNavigateMainFramePostCommit(TabContents* tab) {
3710 if (tab == GetSelectedTabContents()) 3711 if (tab == GetSelectedTabContents())
3711 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); 3712 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
3712 } 3713 }
3713 3714
3714 void Browser::DidNavigateToPendingEntry(TabContents* tab) { 3715 void Browser::DidNavigateToPendingEntry(TabContents* tab) {
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after
5125 } 5126 }
5126 5127
5127 void Browser::ShowSyncSetup() { 5128 void Browser::ShowSyncSetup() {
5128 ProfileSyncService* service = 5129 ProfileSyncService* service =
5129 profile()->GetOriginalProfile()->GetProfileSyncService(); 5130 profile()->GetOriginalProfile()->GetProfileSyncService();
5130 if (service->HasSyncSetupCompleted()) 5131 if (service->HasSyncSetupCompleted())
5131 ShowOptionsTab(chrome::kSyncSetupSubPage); 5132 ShowOptionsTab(chrome::kSyncSetupSubPage);
5132 else 5133 else
5133 service->ShowLoginDialog(); 5134 service->ShowLoginDialog();
5134 } 5135 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/autologin_infobar_delegate.cc ('k') | chrome/browser/ui/browser_init.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698