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

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

Powered by Google App Engine
This is Rietveld 408576698