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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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.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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 92 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
93 #include "chrome/browser/ui/tabs/dock_info.h" 93 #include "chrome/browser/ui/tabs/dock_info.h"
94 #include "chrome/browser/ui/tabs/tab_menu_model.h" 94 #include "chrome/browser/ui/tabs/tab_menu_model.h"
95 #include "chrome/browser/ui/web_applications/web_app_ui.h" 95 #include "chrome/browser/ui/web_applications/web_app_ui.h"
96 #include "chrome/browser/ui/webui/bug_report_ui.h" 96 #include "chrome/browser/ui/webui/bug_report_ui.h"
97 #include "chrome/browser/ui/webui/options/content_settings_handler.h" 97 #include "chrome/browser/ui/webui/options/content_settings_handler.h"
98 #include "chrome/browser/ui/window_sizer.h" 98 #include "chrome/browser/ui/window_sizer.h"
99 #include "chrome/browser/upgrade_detector.h" 99 #include "chrome/browser/upgrade_detector.h"
100 #include "chrome/browser/web_applications/web_app.h" 100 #include "chrome/browser/web_applications/web_app.h"
101 #include "chrome/common/chrome_constants.h" 101 #include "chrome/common/chrome_constants.h"
102 #include "chrome/common/chrome_notification_types.h"
102 #include "chrome/common/chrome_switches.h" 103 #include "chrome/common/chrome_switches.h"
103 #include "chrome/common/extensions/extension.h" 104 #include "chrome/common/extensions/extension.h"
104 #include "chrome/common/extensions/extension_constants.h" 105 #include "chrome/common/extensions/extension_constants.h"
105 #include "chrome/common/pref_names.h" 106 #include "chrome/common/pref_names.h"
106 #include "chrome/common/profiling.h" 107 #include "chrome/common/profiling.h"
107 #include "chrome/common/url_constants.h" 108 #include "chrome/common/url_constants.h"
108 #include "chrome/common/web_apps.h" 109 #include "chrome/common/web_apps.h"
109 #include "content/browser/debugger/devtools_manager.h" 110 #include "content/browser/debugger/devtools_manager.h"
110 #include "content/browser/debugger/devtools_toggle_action.h" 111 #include "content/browser/debugger/devtools_toggle_action.h"
111 #include "content/browser/debugger/devtools_window.h" 112 #include "content/browser/debugger/devtools_window.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 block_command_execution_(false), 246 block_command_execution_(false),
246 last_blocked_command_id_(-1), 247 last_blocked_command_id_(-1),
247 last_blocked_command_disposition_(CURRENT_TAB), 248 last_blocked_command_disposition_(CURRENT_TAB),
248 pending_web_app_action_(NONE), 249 pending_web_app_action_(NONE),
249 ALLOW_THIS_IN_INITIALIZER_LIST( 250 ALLOW_THIS_IN_INITIALIZER_LIST(
250 tab_restore_service_delegate_( 251 tab_restore_service_delegate_(
251 new BrowserTabRestoreServiceDelegate(this))), 252 new BrowserTabRestoreServiceDelegate(this))),
252 bookmark_bar_state_(BookmarkBar::HIDDEN) { 253 bookmark_bar_state_(BookmarkBar::HIDDEN) {
253 registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED, 254 registrar_.Add(this, NotificationType::SSL_VISIBLE_STATE_CHANGED,
254 NotificationService::AllSources()); 255 NotificationService::AllSources());
255 registrar_.Add(this, NotificationType::EXTENSION_UPDATE_DISABLED, 256 registrar_.Add(this, chrome::EXTENSION_UPDATE_DISABLED,
256 NotificationService::AllSources()); 257 NotificationService::AllSources());
257 registrar_.Add(this, NotificationType::EXTENSION_LOADED, 258 registrar_.Add(this, chrome::EXTENSION_LOADED,
258 NotificationService::AllSources()); 259 NotificationService::AllSources());
259 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, 260 registrar_.Add(this, chrome::EXTENSION_UNLOADED,
260 NotificationService::AllSources()); 261 NotificationService::AllSources());
261 registrar_.Add(this, NotificationType::EXTENSION_UNINSTALLED, 262 registrar_.Add(this, chrome::EXTENSION_UNINSTALLED,
262 NotificationService::AllSources()); 263 NotificationService::AllSources());
263 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, 264 registrar_.Add(this, chrome::EXTENSION_PROCESS_TERMINATED,
264 NotificationService::AllSources()); 265 NotificationService::AllSources());
265 registrar_.Add( 266 registrar_.Add(
266 this, NotificationType::BROWSER_THEME_CHANGED, 267 this, chrome::BROWSER_THEME_CHANGED,
267 Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_))); 268 Source<ThemeService>(ThemeServiceFactory::GetForProfile(profile_)));
268 registrar_.Add(this, NotificationType::TAB_CONTENT_SETTINGS_CHANGED, 269 registrar_.Add(this, chrome::TAB_CONTENT_SETTINGS_CHANGED,
269 NotificationService::AllSources()); 270 NotificationService::AllSources());
270 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, 271 registrar_.Add(this, chrome::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED,
271 NotificationService::AllSources()); 272 NotificationService::AllSources());
272 273
273 // Need to know when to alert the user of theme install delay. 274 // Need to know when to alert the user of theme install delay.
274 registrar_.Add(this, NotificationType::EXTENSION_READY_FOR_INSTALL, 275 registrar_.Add(this, chrome::EXTENSION_READY_FOR_INSTALL,
275 NotificationService::AllSources()); 276 NotificationService::AllSources());
276 277
277 PrefService* local_state = g_browser_process->local_state(); 278 PrefService* local_state = g_browser_process->local_state();
278 if (local_state) { 279 if (local_state) {
279 local_pref_registrar_.Init(local_state); 280 local_pref_registrar_.Init(local_state);
280 local_pref_registrar_.Add(prefs::kPrintingEnabled, this); 281 local_pref_registrar_.Add(prefs::kPrintingEnabled, this);
281 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this); 282 local_pref_registrar_.Add(prefs::kAllowFileSelectionDialogs, this);
282 } 283 }
283 284
284 profile_pref_registrar_.Init(profile_->GetPrefs()); 285 profile_pref_registrar_.Init(profile_->GetPrefs());
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 // name. See http://crbug.com/7028. 461 // name. See http://crbug.com/7028.
461 ui::win::SetAppIdForWindow( 462 ui::win::SetAppIdForWindow(
462 is_app() ? 463 is_app() ?
463 ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) : 464 ShellIntegration::GetAppId(UTF8ToWide(app_name_), profile_->GetPath()) :
464 ShellIntegration::GetChromiumAppId(profile_->GetPath()), 465 ShellIntegration::GetChromiumAppId(profile_->GetPath()),
465 window()->GetNativeHandle()); 466 window()->GetNativeHandle());
466 } 467 }
467 #endif 468 #endif
468 469
469 NotificationService::current()->Notify( 470 NotificationService::current()->Notify(
470 NotificationType::BROWSER_WINDOW_READY, 471 chrome::BROWSER_WINDOW_READY,
471 Source<Browser>(this), 472 Source<Browser>(this),
472 NotificationService::NoDetails()); 473 NotificationService::NoDetails());
473 474
474 if (use_compact_navigation_bar_.GetValue()) { 475 if (use_compact_navigation_bar_.GetValue()) {
475 // This enables the compact navigation bar host. 476 // This enables the compact navigation bar host.
476 UseCompactNavigationBarChanged(); 477 UseCompactNavigationBarChanged();
477 } 478 }
478 479
479 // Show the First Run information bubble if we've been told to. 480 // Show the First Run information bubble if we've been told to.
480 PrefService* local_state = g_browser_process->local_state(); 481 PrefService* local_state = g_browser_process->local_state();
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 if (session_service) 995 if (session_service)
995 session_service->WindowClosing(session_id()); 996 session_service->WindowClosing(session_id());
996 997
997 TabRestoreService* tab_restore_service = 998 TabRestoreService* tab_restore_service =
998 TabRestoreServiceFactory::GetForProfile(profile()); 999 TabRestoreServiceFactory::GetForProfile(profile());
999 if (tab_restore_service && is_type_tabbed() && tab_count()) 1000 if (tab_restore_service && is_type_tabbed() && tab_count())
1000 tab_restore_service->BrowserClosing(tab_restore_service_delegate()); 1001 tab_restore_service->BrowserClosing(tab_restore_service_delegate());
1001 1002
1002 // TODO(sky): convert session/tab restore to use notification. 1003 // TODO(sky): convert session/tab restore to use notification.
1003 NotificationService::current()->Notify( 1004 NotificationService::current()->Notify(
1004 NotificationType::BROWSER_CLOSING, 1005 chrome::BROWSER_CLOSING,
1005 Source<Browser>(this), 1006 Source<Browser>(this),
1006 Details<bool>(&exiting)); 1007 Details<bool>(&exiting));
1007 1008
1008 CloseAllTabs(); 1009 CloseAllTabs();
1009 } 1010 }
1010 1011
1011 void Browser::OnWindowActivated() { 1012 void Browser::OnWindowActivated() {
1012 // On some platforms we want to automatically reload tabs that are 1013 // On some platforms we want to automatically reload tabs that are
1013 // killed when the user selects them. 1014 // killed when the user selects them.
1014 TabContents* contents = GetSelectedTabContents(); 1015 TabContents* contents = GetSelectedTabContents();
(...skipping 2210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3225 } 3226 }
3226 tabstrip_model()->SetTabBlocked(index, blocked); 3227 tabstrip_model()->SetTabBlocked(index, blocked);
3227 } 3228 }
3228 3229
3229 void Browser::TabContentsFocused(TabContents* tab_content) { 3230 void Browser::TabContentsFocused(TabContents* tab_content) {
3230 window_->TabContentsFocused(tab_content); 3231 window_->TabContentsFocused(tab_content);
3231 } 3232 }
3232 3233
3233 bool Browser::TakeFocus(bool reverse) { 3234 bool Browser::TakeFocus(bool reverse) {
3234 NotificationService::current()->Notify( 3235 NotificationService::current()->Notify(
3235 NotificationType::FOCUS_RETURNED_TO_BROWSER, 3236 chrome::FOCUS_RETURNED_TO_BROWSER,
3236 Source<Browser>(this), 3237 Source<Browser>(this),
3237 NotificationService::NoDetails()); 3238 NotificationService::NoDetails());
3238 return false; 3239 return false;
3239 } 3240 }
3240 3241
3241 bool Browser::IsApplication() const { 3242 bool Browser::IsApplication() const {
3242 return is_app(); 3243 return is_app();
3243 } 3244 }
3244 3245
3245 void Browser::ConvertContentsToApplication(TabContents* contents) { 3246 void Browser::ConvertContentsToApplication(TabContents* contents) {
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
3553 // tab contents to be NULL. This is because we listen for all sources 3554 // tab contents to be NULL. This is because we listen for all sources
3554 // (NavigationControllers) for convenience, so the notification could 3555 // (NavigationControllers) for convenience, so the notification could
3555 // actually be for a different window while we're doing asynchronous 3556 // actually be for a different window while we're doing asynchronous
3556 // closing of this one. 3557 // closing of this one.
3557 if (GetSelectedTabContents() && 3558 if (GetSelectedTabContents() &&
3558 &GetSelectedTabContents()->controller() == 3559 &GetSelectedTabContents()->controller() ==
3559 Source<NavigationController>(source).ptr()) 3560 Source<NavigationController>(source).ptr())
3560 UpdateToolbar(false); 3561 UpdateToolbar(false);
3561 break; 3562 break;
3562 3563
3563 case NotificationType::EXTENSION_UPDATE_DISABLED: { 3564 case chrome::EXTENSION_UPDATE_DISABLED: {
3564 // Show the UI if the extension was disabled for escalated permissions. 3565 // Show the UI if the extension was disabled for escalated permissions.
3565 Profile* profile = Source<Profile>(source).ptr(); 3566 Profile* profile = Source<Profile>(source).ptr();
3566 if (profile_->IsSameProfile(profile)) { 3567 if (profile_->IsSameProfile(profile)) {
3567 ExtensionService* service = profile->GetExtensionService(); 3568 ExtensionService* service = profile->GetExtensionService();
3568 DCHECK(service); 3569 DCHECK(service);
3569 const Extension* extension = Details<const Extension>(details).ptr(); 3570 const Extension* extension = Details<const Extension>(details).ptr();
3570 if (service->extension_prefs()->DidExtensionEscalatePermissions( 3571 if (service->extension_prefs()->DidExtensionEscalatePermissions(
3571 extension->id())) 3572 extension->id()))
3572 ShowExtensionDisabledUI(service, profile_, extension); 3573 ShowExtensionDisabledUI(service, profile_, extension);
3573 } 3574 }
3574 break; 3575 break;
3575 } 3576 }
3576 3577
3577 case NotificationType::EXTENSION_UNLOADED: { 3578 case chrome::EXTENSION_UNLOADED: {
3578 if (window()->GetLocationBar()) 3579 if (window()->GetLocationBar())
3579 window()->GetLocationBar()->UpdatePageActions(); 3580 window()->GetLocationBar()->UpdatePageActions();
3580 3581
3581 // Close any tabs from the unloaded extension. 3582 // Close any tabs from the unloaded extension.
3582 const Extension* extension = 3583 const Extension* extension =
3583 Details<UnloadedExtensionInfo>(details)->extension; 3584 Details<UnloadedExtensionInfo>(details)->extension;
3584 TabStripModel* model = tab_handler_->GetTabStripModel(); 3585 TabStripModel* model = tab_handler_->GetTabStripModel();
3585 for (int i = model->count() - 1; i >= 0; --i) { 3586 for (int i = model->count() - 1; i >= 0; --i) {
3586 TabContents* tc = model->GetTabContentsAt(i)->tab_contents(); 3587 TabContents* tc = model->GetTabContentsAt(i)->tab_contents();
3587 if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) && 3588 if (tc->GetURL().SchemeIs(chrome::kExtensionScheme) &&
3588 tc->GetURL().host() == extension->id()) { 3589 tc->GetURL().host() == extension->id()) {
3589 CloseTabContents(tc); 3590 CloseTabContents(tc);
3590 } 3591 }
3591 } 3592 }
3592 3593
3593 break; 3594 break;
3594 } 3595 }
3595 3596
3596 case NotificationType::EXTENSION_PROCESS_TERMINATED: { 3597 case chrome::EXTENSION_PROCESS_TERMINATED: {
3597 if (window()->GetLocationBar()) 3598 if (window()->GetLocationBar())
3598 window()->GetLocationBar()->InvalidatePageActions(); 3599 window()->GetLocationBar()->InvalidatePageActions();
3599 break; 3600 break;
3600 } 3601 }
3601 3602
3602 case NotificationType::EXTENSION_UNINSTALLED: 3603 case chrome::EXTENSION_UNINSTALLED:
3603 case NotificationType::EXTENSION_LOADED: 3604 case chrome::EXTENSION_LOADED:
3604 if (window()->GetLocationBar()) 3605 if (window()->GetLocationBar())
3605 window()->GetLocationBar()->UpdatePageActions(); 3606 window()->GetLocationBar()->UpdatePageActions();
3606 break; 3607 break;
3607 3608
3608 case NotificationType::BROWSER_THEME_CHANGED: 3609 case chrome::BROWSER_THEME_CHANGED:
3609 window()->UserChangedTheme(); 3610 window()->UserChangedTheme();
3610 break; 3611 break;
3611 3612
3612 case NotificationType::EXTENSION_READY_FOR_INSTALL: { 3613 case chrome::EXTENSION_READY_FOR_INSTALL: {
3613 // Handle EXTENSION_READY_FOR_INSTALL for last active tabbed browser. 3614 // Handle EXTENSION_READY_FOR_INSTALL for last active tabbed browser.
3614 if (BrowserList::FindTabbedBrowser(profile(), true) != this) 3615 if (BrowserList::FindTabbedBrowser(profile(), true) != this)
3615 break; 3616 break;
3616 3617
3617 // We only want to show the loading dialog for themes, but we don't want 3618 // We only want to show the loading dialog for themes, but we don't want
3618 // to wait until unpack to find out an extension is a theme, so we test 3619 // to wait until unpack to find out an extension is a theme, so we test
3619 // the download_url GURL instead. This means that themes in the extensions 3620 // the download_url GURL instead. This means that themes in the extensions
3620 // gallery won't get the loading dialog. 3621 // gallery won't get the loading dialog.
3621 GURL download_url = *(Details<GURL>(details).ptr()); 3622 GURL download_url = *(Details<GURL>(details).ptr());
3622 if (ExtensionService::IsDownloadFromMiniGallery(download_url)) 3623 if (ExtensionService::IsDownloadFromMiniGallery(download_url))
3623 window()->ShowThemeInstallBubble(); 3624 window()->ShowThemeInstallBubble();
3624 break; 3625 break;
3625 } 3626 }
3626 3627
3627 case NotificationType::PREF_CHANGED: { 3628 case chrome::PREF_CHANGED: {
3628 const std::string& pref_name = *Details<std::string>(details).ptr(); 3629 const std::string& pref_name = *Details<std::string>(details).ptr();
3629 if (pref_name == prefs::kUseVerticalTabs) { 3630 if (pref_name == prefs::kUseVerticalTabs) {
3630 UseVerticalTabsChanged(); 3631 UseVerticalTabsChanged();
3631 } else if (pref_name == prefs::kUseCompactNavigationBar) { 3632 } else if (pref_name == prefs::kUseCompactNavigationBar) {
3632 UseCompactNavigationBarChanged(); 3633 UseCompactNavigationBarChanged();
3633 } else if (pref_name == prefs::kPrintingEnabled) { 3634 } else if (pref_name == prefs::kPrintingEnabled) {
3634 UpdatePrintingState(GetContentRestrictionsForSelectedTab()); 3635 UpdatePrintingState(GetContentRestrictionsForSelectedTab());
3635 } else if (pref_name == prefs::kInstantEnabled) { 3636 } else if (pref_name == prefs::kInstantEnabled) {
3636 if (!InstantController::IsEnabled(profile())) { 3637 if (!InstantController::IsEnabled(profile())) {
3637 if (instant()) { 3638 if (instant()) {
(...skipping 16 matching lines...) Expand all
3654 UpdateCommandsForBookmarkEditing(); 3655 UpdateCommandsForBookmarkEditing();
3655 } else if (pref_name == prefs::kAllowFileSelectionDialogs) { 3656 } else if (pref_name == prefs::kAllowFileSelectionDialogs) {
3656 UpdateSaveAsState(GetContentRestrictionsForSelectedTab()); 3657 UpdateSaveAsState(GetContentRestrictionsForSelectedTab());
3657 UpdateOpenFileState(); 3658 UpdateOpenFileState();
3658 } else { 3659 } else {
3659 NOTREACHED(); 3660 NOTREACHED();
3660 } 3661 }
3661 break; 3662 break;
3662 } 3663 }
3663 3664
3664 case NotificationType::TAB_CONTENT_SETTINGS_CHANGED: { 3665 case chrome::TAB_CONTENT_SETTINGS_CHANGED: {
3665 TabContents* tab_contents = Source<TabContents>(source).ptr(); 3666 TabContents* tab_contents = Source<TabContents>(source).ptr();
3666 if (tab_contents == GetSelectedTabContents()) { 3667 if (tab_contents == GetSelectedTabContents()) {
3667 LocationBar* location_bar = window()->GetLocationBar(); 3668 LocationBar* location_bar = window()->GetLocationBar();
3668 if (location_bar) 3669 if (location_bar)
3669 location_bar->UpdateContentSettingsIcons(); 3670 location_bar->UpdateContentSettingsIcons();
3670 } 3671 }
3671 break; 3672 break;
3672 } 3673 }
3673 3674
3674 case NotificationType::INTERSTITIAL_ATTACHED: 3675 case NotificationType::INTERSTITIAL_ATTACHED:
3675 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE); 3676 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TAB_STATE);
3676 break; 3677 break;
3677 3678
3678 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: 3679 case chrome::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED:
3679 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE); 3680 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE);
3680 break; 3681 break;
3681 3682
3682 default: 3683 default:
3683 NOTREACHED() << "Got a notification we didn't register for."; 3684 NOTREACHED() << "Got a notification we didn't register for.";
3684 } 3685 }
3685 } 3686 }
3686 3687
3687 /////////////////////////////////////////////////////////////////////////////// 3688 ///////////////////////////////////////////////////////////////////////////////
3688 // Browser, ProfileSyncServiceObserver implementation: 3689 // Browser, ProfileSyncServiceObserver implementation:
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
4745 // end up querying state once they process the tab switch. 4746 // end up querying state once they process the tab switch.
4746 return; 4747 return;
4747 } 4748 }
4748 4749
4749 BookmarkBar::AnimateChangeType animate_type = 4750 BookmarkBar::AnimateChangeType animate_type =
4750 (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE) ? 4751 (reason == BOOKMARK_BAR_STATE_CHANGE_PREF_CHANGE) ?
4751 BookmarkBar::ANIMATE_STATE_CHANGE : 4752 BookmarkBar::ANIMATE_STATE_CHANGE :
4752 BookmarkBar::DONT_ANIMATE_STATE_CHANGE; 4753 BookmarkBar::DONT_ANIMATE_STATE_CHANGE;
4753 window_->BookmarkBarStateChanged(animate_type); 4754 window_->BookmarkBarStateChanged(animate_type);
4754 } 4755 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698