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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 if (!app_name_.empty()) | 367 if (!app_name_.empty()) |
368 chrome::RegisterAppPrefs(app_name_, profile_); | 368 chrome::RegisterAppPrefs(app_name_, profile_); |
369 tab_strip_model_->AddObserver(this); | 369 tab_strip_model_->AddObserver(this); |
370 | 370 |
371 toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get())); | 371 toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get())); |
372 search_model_.reset(new chrome::search::SearchModel(NULL)); | 372 search_model_.reset(new chrome::search::SearchModel(NULL)); |
373 search_delegate_.reset( | 373 search_delegate_.reset( |
374 new chrome::search::SearchDelegate(search_model_.get(), | 374 new chrome::search::SearchDelegate(search_model_.get(), |
375 toolbar_model_.get())); | 375 toolbar_model_.get())); |
376 | 376 |
| 377 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, |
| 378 content::NotificationService::AllSources()); |
377 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 379 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
378 content::Source<Profile>(profile_->GetOriginalProfile())); | 380 content::Source<Profile>(profile_->GetOriginalProfile())); |
379 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 381 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
380 content::Source<Profile>(profile_->GetOriginalProfile())); | 382 content::Source<Profile>(profile_->GetOriginalProfile())); |
381 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, | 383 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
382 content::Source<Profile>(profile_->GetOriginalProfile())); | 384 content::Source<Profile>(profile_->GetOriginalProfile())); |
383 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 385 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
384 content::NotificationService::AllSources()); | 386 content::NotificationService::AllSources()); |
385 #if defined(ENABLE_THEMES) | 387 #if defined(ENABLE_THEMES) |
386 registrar_.Add( | 388 registrar_.Add( |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 747 |
746 //////////////////////////////////////////////////////////////////////////////// | 748 //////////////////////////////////////////////////////////////////////////////// |
747 // Browser, Tab adding/showing functions: | 749 // Browser, Tab adding/showing functions: |
748 | 750 |
749 void Browser::WindowFullscreenStateChanged() { | 751 void Browser::WindowFullscreenStateChanged() { |
750 fullscreen_controller_->WindowFullscreenStateChanged(); | 752 fullscreen_controller_->WindowFullscreenStateChanged(); |
751 command_controller_->FullscreenStateChanged(); | 753 command_controller_->FullscreenStateChanged(); |
752 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); | 754 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); |
753 } | 755 } |
754 | 756 |
755 void Browser::VisibleSSLStateChanged(content::WebContents* web_contents) { | |
756 // When the current tab's SSL state changes, we need to update the URL | |
757 // bar to reflect the new state. | |
758 DCHECK(web_contents); | |
759 if (tab_strip_model_->GetActiveWebContents() == web_contents) | |
760 UpdateToolbar(false); | |
761 } | |
762 | |
763 /////////////////////////////////////////////////////////////////////////////// | 757 /////////////////////////////////////////////////////////////////////////////// |
764 // Browser, Assorted browser commands: | 758 // Browser, Assorted browser commands: |
765 | 759 |
766 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { | 760 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { |
767 fullscreen_controller_->ToggleFullscreenModeWithExtension(extension_url); | 761 fullscreen_controller_->ToggleFullscreenModeWithExtension(extension_url); |
768 } | 762 } |
769 | 763 |
770 bool Browser::SupportsWindowFeature(WindowFeature feature) const { | 764 bool Browser::SupportsWindowFeature(WindowFeature feature) const { |
771 return SupportsWindowFeatureImpl(feature, true); | 765 return SupportsWindowFeatureImpl(feature, true); |
772 } | 766 } |
(...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 false)); | 1749 false)); |
1756 } | 1750 } |
1757 | 1751 |
1758 /////////////////////////////////////////////////////////////////////////////// | 1752 /////////////////////////////////////////////////////////////////////////////// |
1759 // Browser, content::NotificationObserver implementation: | 1753 // Browser, content::NotificationObserver implementation: |
1760 | 1754 |
1761 void Browser::Observe(int type, | 1755 void Browser::Observe(int type, |
1762 const content::NotificationSource& source, | 1756 const content::NotificationSource& source, |
1763 const content::NotificationDetails& details) { | 1757 const content::NotificationDetails& details) { |
1764 switch (type) { | 1758 switch (type) { |
| 1759 case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED: |
| 1760 // When the current tab's SSL state changes, we need to update the URL |
| 1761 // bar to reflect the new state. Note that it's possible for the selected |
| 1762 // tab contents to be NULL. This is because we listen for all sources |
| 1763 // (NavigationControllers) for convenience, so the notification could |
| 1764 // actually be for a different window while we're doing asynchronous |
| 1765 // closing of this one. |
| 1766 if (tab_strip_model_->GetActiveWebContents() && |
| 1767 &tab_strip_model_->GetActiveWebContents()->GetController() == |
| 1768 content::Source<NavigationController>(source).ptr()) |
| 1769 UpdateToolbar(false); |
| 1770 break; |
| 1771 |
1765 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 1772 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { |
1766 if (window()->GetLocationBar()) | 1773 if (window()->GetLocationBar()) |
1767 window()->GetLocationBar()->UpdatePageActions(); | 1774 window()->GetLocationBar()->UpdatePageActions(); |
1768 | 1775 |
1769 // Close any tabs from the unloaded extension, unless it's terminated, | 1776 // Close any tabs from the unloaded extension, unless it's terminated, |
1770 // in which case let the sad tabs remain. | 1777 // in which case let the sad tabs remain. |
1771 if (content::Details<extensions::UnloadedExtensionInfo>( | 1778 if (content::Details<extensions::UnloadedExtensionInfo>( |
1772 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { | 1779 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { |
1773 const Extension* extension = | 1780 const Extension* extension = |
1774 content::Details<extensions::UnloadedExtensionInfo>( | 1781 content::Details<extensions::UnloadedExtensionInfo>( |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2271 if (contents && !allow_js_access) { | 2278 if (contents && !allow_js_access) { |
2272 contents->web_contents()->GetController().LoadURL( | 2279 contents->web_contents()->GetController().LoadURL( |
2273 target_url, | 2280 target_url, |
2274 content::Referrer(), | 2281 content::Referrer(), |
2275 content::PAGE_TRANSITION_LINK, | 2282 content::PAGE_TRANSITION_LINK, |
2276 std::string()); // No extra headers. | 2283 std::string()); // No extra headers. |
2277 } | 2284 } |
2278 | 2285 |
2279 return contents != NULL; | 2286 return contents != NULL; |
2280 } | 2287 } |
OLD | NEW |