OLD | NEW |
---|---|
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 Loading... | |
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 2355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2419 file_select_helper->EnumerateDirectory(request_id, | 2420 file_select_helper->EnumerateDirectory(request_id, |
2420 tab->render_view_host(), | 2421 tab->render_view_host(), |
2421 path); | 2422 path); |
2422 } | 2423 } |
2423 | 2424 |
2424 // static | 2425 // static |
2425 void Browser::JSOutOfMemoryHelper(TabContents* tab) { | 2426 void Browser::JSOutOfMemoryHelper(TabContents* tab) { |
2426 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | 2427 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
2427 tab); | 2428 tab); |
2428 if (tcw) { | 2429 if (tcw) { |
2429 tcw->AddInfoBar(new SimpleAlertInfoBarDelegate( | 2430 tcw->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate( |
2430 tab, NULL, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), | 2431 tab, NULL, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), |
2431 true)); | 2432 true)); |
2432 } | 2433 } |
2433 } | 2434 } |
2434 | 2435 |
2435 // static | 2436 // static |
2436 void Browser::RegisterProtocolHandlerHelper(TabContents* tab, | 2437 void Browser::RegisterProtocolHandlerHelper(TabContents* tab, |
2437 const std::string& protocol, | 2438 const std::string& protocol, |
2438 const GURL& url, | 2439 const GURL& url, |
2439 const string16& title) { | 2440 const string16& title) { |
(...skipping 13 matching lines...) Expand all Loading... | |
2453 ProtocolHandlerRegistry* registry = | 2454 ProtocolHandlerRegistry* registry = |
2454 tcw->profile()->GetProtocolHandlerRegistry(); | 2455 tcw->profile()->GetProtocolHandlerRegistry(); |
2455 if (!registry->enabled() || registry->IsRegistered(handler) || | 2456 if (!registry->enabled() || registry->IsRegistered(handler) || |
2456 registry->IsIgnored(handler)) | 2457 registry->IsIgnored(handler)) |
2457 return; | 2458 return; |
2458 | 2459 |
2459 if (!handler.IsEmpty() && | 2460 if (!handler.IsEmpty() && |
2460 registry->CanSchemeBeOverridden(handler.protocol())) { | 2461 registry->CanSchemeBeOverridden(handler.protocol())) { |
2461 UserMetrics::RecordAction( | 2462 UserMetrics::RecordAction( |
2462 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); | 2463 UserMetricsAction("RegisterProtocolHandler.InfoBar_Shown")); |
2463 tcw->AddInfoBar(new RegisterProtocolHandlerInfoBarDelegate(tab, | 2464 tcw->infobar_tab_helper()->AddInfoBar( |
2464 registry, | 2465 new RegisterProtocolHandlerInfoBarDelegate(tab, registry, handler)); |
2465 handler)); | |
2466 } | 2466 } |
2467 } | 2467 } |
2468 | 2468 |
2469 // static | 2469 // static |
2470 void Browser::RegisterIntentHandlerHelper(TabContents* tab, | 2470 void Browser::RegisterIntentHandlerHelper(TabContents* tab, |
2471 const string16& action, | 2471 const string16& action, |
2472 const string16& type, | 2472 const string16& type, |
2473 const string16& href, | 2473 const string16& href, |
2474 const string16& title) { | 2474 const string16& title) { |
2475 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( | 2475 TabContentsWrapper* tcw = TabContentsWrapper::GetCurrentWrapperForContents( |
2476 tab); | 2476 tab); |
2477 if (!tcw || tcw->profile()->IsOffTheRecord()) | 2477 if (!tcw || tcw->profile()->IsOffTheRecord()) |
2478 return; | 2478 return; |
2479 | 2479 |
2480 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) | 2480 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) |
2481 return; | 2481 return; |
2482 | 2482 |
2483 GURL service_url(href); | 2483 GURL service_url(href); |
2484 if (!service_url.is_valid()) { | 2484 if (!service_url.is_valid()) { |
2485 const GURL& url = tab->GetURL(); | 2485 const GURL& url = tab->GetURL(); |
2486 service_url = url.Resolve(href); | 2486 service_url = url.Resolve(href); |
2487 } | 2487 } |
2488 | 2488 |
2489 WebIntentData intent; | 2489 WebIntentData intent; |
2490 intent.service_url = service_url; | 2490 intent.service_url = service_url; |
2491 intent.action = action; | 2491 intent.action = action; |
2492 intent.type = type; | 2492 intent.type = type; |
2493 intent.title = title; | 2493 intent.title = title; |
2494 tcw->AddInfoBar(new RegisterIntentHandlerInfoBarDelegate(tab, intent)); | 2494 tcw->infobar_tab_helper()->AddInfoBar( |
2495 new RegisterIntentHandlerInfoBarDelegate(tab, intent)); | |
2495 } | 2496 } |
2496 | 2497 |
2497 // static | 2498 // static |
2498 void Browser::WebIntentDispatchHelper(TabContents* tab, | 2499 void Browser::WebIntentDispatchHelper(TabContents* tab, |
2499 int routing_id, | 2500 int routing_id, |
2500 const string16& action, | 2501 const string16& action, |
2501 const string16& type, | 2502 const string16& type, |
2502 const string16& data, | 2503 const string16& data, |
2503 int intent_id) { | 2504 int intent_id) { |
2504 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) | 2505 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents)) |
(...skipping 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3687 | 3688 |
3688 void Browser::RendererUnresponsive(TabContents* source) { | 3689 void Browser::RendererUnresponsive(TabContents* source) { |
3689 browser::ShowHungRendererDialog(source); | 3690 browser::ShowHungRendererDialog(source); |
3690 } | 3691 } |
3691 | 3692 |
3692 void Browser::RendererResponsive(TabContents* source) { | 3693 void Browser::RendererResponsive(TabContents* source) { |
3693 browser::HideHungRendererDialog(source); | 3694 browser::HideHungRendererDialog(source); |
3694 } | 3695 } |
3695 | 3696 |
3696 void Browser::WorkerCrashed(TabContents* source) { | 3697 void Browser::WorkerCrashed(TabContents* source) { |
3697 TabContentsWrapper* wrapper = | 3698 TabContentsWrapper* wrapper = |
Peter Kasting
2011/08/31 18:47:32
Nit: Collapse these two lines together
| |
3698 TabContentsWrapper::GetCurrentWrapperForContents(source); | 3699 TabContentsWrapper::GetCurrentWrapperForContents(source); |
3699 wrapper->AddInfoBar(new SimpleAlertInfoBarDelegate( | 3700 wrapper->infobar_tab_helper()->AddInfoBar(new SimpleAlertInfoBarDelegate( |
3700 source, NULL, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), | 3701 source, NULL, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), |
3701 true)); | 3702 true)); |
3702 } | 3703 } |
3703 | 3704 |
3704 void Browser::DidNavigateMainFramePostCommit(TabContents* tab) { | 3705 void Browser::DidNavigateMainFramePostCommit(TabContents* tab) { |
3705 if (tab == GetSelectedTabContents()) | 3706 if (tab == GetSelectedTabContents()) |
3706 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); | 3707 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); |
3707 } | 3708 } |
3708 | 3709 |
3709 void Browser::DidNavigateToPendingEntry(TabContents* tab) { | 3710 void Browser::DidNavigateToPendingEntry(TabContents* tab) { |
(...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5120 } | 5121 } |
5121 | 5122 |
5122 void Browser::ShowSyncSetup() { | 5123 void Browser::ShowSyncSetup() { |
5123 ProfileSyncService* service = | 5124 ProfileSyncService* service = |
5124 profile()->GetOriginalProfile()->GetProfileSyncService(); | 5125 profile()->GetOriginalProfile()->GetProfileSyncService(); |
5125 if (service->HasSyncSetupCompleted()) | 5126 if (service->HasSyncSetupCompleted()) |
5126 ShowOptionsTab(chrome::kSyncSetupSubPage); | 5127 ShowOptionsTab(chrome::kSyncSetupSubPage); |
5127 else | 5128 else |
5128 service->ShowLoginDialog(); | 5129 service->ShowLoginDialog(); |
5129 } | 5130 } |
OLD | NEW |