OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/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 // defined(OS_WIN) | 10 #endif // defined(OS_WIN) |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 | 370 |
371 if (!app_name_.empty()) | 371 if (!app_name_.empty()) |
372 chrome::RegisterAppPrefs(app_name_, profile_); | 372 chrome::RegisterAppPrefs(app_name_, profile_); |
373 tab_strip_model_->AddObserver(this); | 373 tab_strip_model_->AddObserver(this); |
374 | 374 |
375 toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get())); | 375 toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get())); |
376 search_model_.reset(new SearchModel()); | 376 search_model_.reset(new SearchModel()); |
377 search_delegate_.reset(new SearchDelegate(search_model_.get())); | 377 search_delegate_.reset(new SearchDelegate(search_model_.get())); |
378 | 378 |
379 registrar_.Add(this, | 379 registrar_.Add(this, |
380 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 380 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
381 content::Source<Profile>(profile_->GetOriginalProfile())); | |
382 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | |
383 content::Source<Profile>(profile_->GetOriginalProfile())); | 381 content::Source<Profile>(profile_->GetOriginalProfile())); |
384 registrar_.Add(this, | 382 registrar_.Add(this, |
385 chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, | 383 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
386 content::Source<Profile>(profile_->GetOriginalProfile())); | 384 content::Source<Profile>(profile_->GetOriginalProfile())); |
387 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 385 registrar_.Add(this, |
| 386 extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED, |
| 387 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 388 registrar_.Add(this, |
| 389 extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
388 content::NotificationService::AllSources()); | 390 content::NotificationService::AllSources()); |
389 #if defined(ENABLE_THEMES) | 391 #if defined(ENABLE_THEMES) |
390 registrar_.Add( | 392 registrar_.Add( |
391 this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 393 this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
392 content::Source<ThemeService>( | 394 content::Source<ThemeService>( |
393 ThemeServiceFactory::GetForProfile(profile_))); | 395 ThemeServiceFactory::GetForProfile(profile_))); |
394 #endif | 396 #endif |
395 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, | 397 registrar_.Add(this, chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, |
396 content::NotificationService::AllSources()); | 398 content::NotificationService::AllSources()); |
397 | 399 |
(...skipping 1513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); | 1913 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_TYPED, false)); |
1912 } | 1914 } |
1913 | 1915 |
1914 /////////////////////////////////////////////////////////////////////////////// | 1916 /////////////////////////////////////////////////////////////////////////////// |
1915 // Browser, content::NotificationObserver implementation: | 1917 // Browser, content::NotificationObserver implementation: |
1916 | 1918 |
1917 void Browser::Observe(int type, | 1919 void Browser::Observe(int type, |
1918 const content::NotificationSource& source, | 1920 const content::NotificationSource& source, |
1919 const content::NotificationDetails& details) { | 1921 const content::NotificationDetails& details) { |
1920 switch (type) { | 1922 switch (type) { |
1921 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 1923 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
1922 chrome::UpdateCommandEnabled( | 1924 chrome::UpdateCommandEnabled( |
1923 this, | 1925 this, |
1924 IDC_BOOKMARK_PAGE, | 1926 IDC_BOOKMARK_PAGE, |
1925 !chrome::ShouldRemoveBookmarkThisPageUI(profile_)); | 1927 !chrome::ShouldRemoveBookmarkThisPageUI(profile_)); |
1926 chrome::UpdateCommandEnabled( | 1928 chrome::UpdateCommandEnabled( |
1927 this, | 1929 this, |
1928 IDC_BOOKMARK_ALL_TABS, | 1930 IDC_BOOKMARK_ALL_TABS, |
1929 !chrome::ShouldRemoveBookmarkOpenPagesUI(profile_)); | 1931 !chrome::ShouldRemoveBookmarkOpenPagesUI(profile_)); |
1930 | 1932 |
1931 if (window()->GetLocationBar()) | 1933 if (window()->GetLocationBar()) |
(...skipping 20 matching lines...) Expand all Loading... |
1952 web_contents->GetURL().host() == extension->id()) || | 1954 web_contents->GetURL().host() == extension->id()) || |
1953 (extensions::TabHelper::FromWebContents( | 1955 (extensions::TabHelper::FromWebContents( |
1954 web_contents)->extension_app() == extension)) { | 1956 web_contents)->extension_app() == extension)) { |
1955 tab_strip_model_->CloseWebContentsAt(i, TabStripModel::CLOSE_NONE); | 1957 tab_strip_model_->CloseWebContentsAt(i, TabStripModel::CLOSE_NONE); |
1956 } | 1958 } |
1957 } | 1959 } |
1958 } | 1960 } |
1959 break; | 1961 break; |
1960 } | 1962 } |
1961 | 1963 |
1962 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { | 1964 case extensions::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { |
1963 Profile* profile = content::Source<Profile>(source).ptr(); | 1965 Profile* profile = content::Source<Profile>(source).ptr(); |
1964 if (profile_->IsSameProfile(profile) && window()->GetLocationBar()) | 1966 if (profile_->IsSameProfile(profile) && window()->GetLocationBar()) |
1965 window()->GetLocationBar()->InvalidatePageActions(); | 1967 window()->GetLocationBar()->InvalidatePageActions(); |
1966 break; | 1968 break; |
1967 } | 1969 } |
1968 | 1970 |
1969 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: | 1971 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: |
1970 chrome::UpdateCommandEnabled( | 1972 chrome::UpdateCommandEnabled( |
1971 this, | 1973 this, |
1972 IDC_BOOKMARK_PAGE, | 1974 IDC_BOOKMARK_PAGE, |
1973 !chrome::ShouldRemoveBookmarkThisPageUI(profile_)); | 1975 !chrome::ShouldRemoveBookmarkThisPageUI(profile_)); |
1974 chrome::UpdateCommandEnabled( | 1976 chrome::UpdateCommandEnabled( |
1975 this, | 1977 this, |
1976 IDC_BOOKMARK_ALL_TABS, | 1978 IDC_BOOKMARK_ALL_TABS, |
1977 !chrome::ShouldRemoveBookmarkOpenPagesUI(profile_)); | 1979 !chrome::ShouldRemoveBookmarkOpenPagesUI(profile_)); |
1978 // fallthrough | 1980 // fallthrough |
1979 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: | 1981 case extensions::NOTIFICATION_EXTENSION_UNINSTALLED_DEPRECATED: |
1980 // During window creation on Windows we may end up calling into | 1982 // During window creation on Windows we may end up calling into |
1981 // SHAppBarMessage, which internally spawns a nested message loop. This | 1983 // SHAppBarMessage, which internally spawns a nested message loop. This |
1982 // makes it possible for us to end up here before window creation has | 1984 // makes it possible for us to end up here before window creation has |
1983 // completed, at which point window_ is NULL. See 94752 for details. | 1985 // completed, at which point window_ is NULL. See 94752 for details. |
1984 if (window() && window()->GetLocationBar()) | 1986 if (window() && window()->GetLocationBar()) |
1985 window()->GetLocationBar()->UpdatePageActions(); | 1987 window()->GetLocationBar()->UpdatePageActions(); |
1986 break; | 1988 break; |
1987 | 1989 |
1988 #if defined(ENABLE_THEMES) | 1990 #if defined(ENABLE_THEMES) |
1989 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: | 1991 case chrome::NOTIFICATION_BROWSER_THEME_CHANGED: |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2457 if (contents && !allow_js_access) { | 2459 if (contents && !allow_js_access) { |
2458 contents->web_contents()->GetController().LoadURL( | 2460 contents->web_contents()->GetController().LoadURL( |
2459 target_url, | 2461 target_url, |
2460 content::Referrer(), | 2462 content::Referrer(), |
2461 content::PAGE_TRANSITION_LINK, | 2463 content::PAGE_TRANSITION_LINK, |
2462 std::string()); // No extra headers. | 2464 std::string()); // No extra headers. |
2463 } | 2465 } |
2464 | 2466 |
2465 return contents != NULL; | 2467 return contents != NULL; |
2466 } | 2468 } |
OLD | NEW |