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

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

Issue 12041059: content: convert SSL notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 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 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if (!app_name_.empty()) 372 if (!app_name_.empty())
373 chrome::RegisterAppPrefs(app_name_, profile_); 373 chrome::RegisterAppPrefs(app_name_, profile_);
374 tab_strip_model_->AddObserver(this); 374 tab_strip_model_->AddObserver(this);
375 375
376 toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get())); 376 toolbar_model_.reset(new ToolbarModelImpl(toolbar_model_delegate_.get()));
377 search_model_.reset(new chrome::search::SearchModel(NULL)); 377 search_model_.reset(new chrome::search::SearchModel(NULL));
378 search_delegate_.reset( 378 search_delegate_.reset(
379 new chrome::search::SearchDelegate(search_model_.get(), 379 new chrome::search::SearchDelegate(search_model_.get(),
380 toolbar_model_.get())); 380 toolbar_model_.get()));
381 381
382 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED,
383 content::NotificationService::AllSources());
384 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 382 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
385 content::Source<Profile>(profile_->GetOriginalProfile())); 383 content::Source<Profile>(profile_->GetOriginalProfile()));
386 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 384 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
387 content::Source<Profile>(profile_->GetOriginalProfile())); 385 content::Source<Profile>(profile_->GetOriginalProfile()));
388 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 386 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
389 content::Source<Profile>(profile_->GetOriginalProfile())); 387 content::Source<Profile>(profile_->GetOriginalProfile()));
390 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, 388 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
391 content::NotificationService::AllSources()); 389 content::NotificationService::AllSources());
392 #if defined(ENABLE_THEMES) 390 #if defined(ENABLE_THEMES)
393 registrar_.Add( 391 registrar_.Add(
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 751
754 //////////////////////////////////////////////////////////////////////////////// 752 ////////////////////////////////////////////////////////////////////////////////
755 // Browser, Tab adding/showing functions: 753 // Browser, Tab adding/showing functions:
756 754
757 void Browser::WindowFullscreenStateChanged() { 755 void Browser::WindowFullscreenStateChanged() {
758 fullscreen_controller_->WindowFullscreenStateChanged(); 756 fullscreen_controller_->WindowFullscreenStateChanged();
759 command_controller_->FullscreenStateChanged(); 757 command_controller_->FullscreenStateChanged();
760 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN); 758 UpdateBookmarkBarState(BOOKMARK_BAR_STATE_CHANGE_TOGGLE_FULLSCREEN);
761 } 759 }
762 760
761 void Browser::VisibleSSLStateChanged(content::WebContents* web_contents) {
762 // When the current tab's SSL state changes, we need to update the URL
763 // bar to reflect the new state.
764 DCHECK(web_contents);
765 if (tab_strip_model_->GetActiveWebContents() == web_contents)
766 UpdateToolbar(false);
767 }
768
763 /////////////////////////////////////////////////////////////////////////////// 769 ///////////////////////////////////////////////////////////////////////////////
764 // Browser, Assorted browser commands: 770 // Browser, Assorted browser commands:
765 771
766 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) { 772 void Browser::ToggleFullscreenModeWithExtension(const GURL& extension_url) {
767 fullscreen_controller_->ToggleFullscreenModeWithExtension(extension_url); 773 fullscreen_controller_->ToggleFullscreenModeWithExtension(extension_url);
768 } 774 }
769 775
770 #if defined(OS_MACOSX) 776 #if defined(OS_MACOSX)
771 void Browser::TogglePresentationMode() { 777 void Browser::TogglePresentationMode() {
772 fullscreen_controller_->TogglePresentationMode(); 778 fullscreen_controller_->TogglePresentationMode();
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
1814 false)); 1820 false));
1815 } 1821 }
1816 1822
1817 /////////////////////////////////////////////////////////////////////////////// 1823 ///////////////////////////////////////////////////////////////////////////////
1818 // Browser, content::NotificationObserver implementation: 1824 // Browser, content::NotificationObserver implementation:
1819 1825
1820 void Browser::Observe(int type, 1826 void Browser::Observe(int type,
1821 const content::NotificationSource& source, 1827 const content::NotificationSource& source,
1822 const content::NotificationDetails& details) { 1828 const content::NotificationDetails& details) {
1823 switch (type) { 1829 switch (type) {
1824 case content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED:
1825 // When the current tab's SSL state changes, we need to update the URL
1826 // bar to reflect the new state. Note that it's possible for the selected
1827 // tab contents to be NULL. This is because we listen for all sources
1828 // (NavigationControllers) for convenience, so the notification could
1829 // actually be for a different window while we're doing asynchronous
1830 // closing of this one.
1831 if (tab_strip_model_->GetActiveWebContents() &&
1832 &tab_strip_model_->GetActiveWebContents()->GetController() ==
1833 content::Source<NavigationController>(source).ptr())
1834 UpdateToolbar(false);
1835 break;
1836
1837 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { 1830 case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
1838 if (window()->GetLocationBar()) 1831 if (window()->GetLocationBar())
1839 window()->GetLocationBar()->UpdatePageActions(); 1832 window()->GetLocationBar()->UpdatePageActions();
1840 1833
1841 // Close any tabs from the unloaded extension, unless it's terminated, 1834 // Close any tabs from the unloaded extension, unless it's terminated,
1842 // in which case let the sad tabs remain. 1835 // in which case let the sad tabs remain.
1843 if (content::Details<extensions::UnloadedExtensionInfo>( 1836 if (content::Details<extensions::UnloadedExtensionInfo>(
1844 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) { 1837 details)->reason != extension_misc::UNLOAD_REASON_TERMINATE) {
1845 const Extension* extension = 1838 const Extension* extension =
1846 content::Details<extensions::UnloadedExtensionInfo>( 1839 content::Details<extensions::UnloadedExtensionInfo>(
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 if (contents && !allow_js_access) { 2333 if (contents && !allow_js_access) {
2341 contents->web_contents()->GetController().LoadURL( 2334 contents->web_contents()->GetController().LoadURL(
2342 target_url, 2335 target_url,
2343 content::Referrer(), 2336 content::Referrer(),
2344 content::PAGE_TRANSITION_LINK, 2337 content::PAGE_TRANSITION_LINK,
2345 std::string()); // No extra headers. 2338 std::string()); // No extra headers.
2346 } 2339 }
2347 2340
2348 return contents != NULL; 2341 return contents != NULL;
2349 } 2342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698