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

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

Issue 9479008: Re-factor location bar/toolbar code to get rid of the browser dependency. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments fix Created 8 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 // OS_WIN 10 #endif // OS_WIN
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 #include "chrome/browser/tab_contents/retargeting_details.h" 97 #include "chrome/browser/tab_contents/retargeting_details.h"
98 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" 98 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h"
99 #include "chrome/browser/tab_contents/tab_util.h" 99 #include "chrome/browser/tab_contents/tab_util.h"
100 #include "chrome/browser/tabs/tab_finder.h" 100 #include "chrome/browser/tabs/tab_finder.h"
101 #include "chrome/browser/tabs/tab_strip_model.h" 101 #include "chrome/browser/tabs/tab_strip_model.h"
102 #include "chrome/browser/themes/theme_service.h" 102 #include "chrome/browser/themes/theme_service.h"
103 #include "chrome/browser/themes/theme_service_factory.h" 103 #include "chrome/browser/themes/theme_service_factory.h"
104 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" 104 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h"
105 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" 105 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
106 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" 106 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h"
107 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
107 #include "chrome/browser/ui/browser_dialogs.h" 108 #include "chrome/browser/ui/browser_dialogs.h"
108 #include "chrome/browser/ui/browser_list.h" 109 #include "chrome/browser/ui/browser_list.h"
109 #include "chrome/browser/ui/browser_navigator.h" 110 #include "chrome/browser/ui/browser_navigator.h"
111 #include "chrome/browser/ui/browser_tab_contents_wrapper_container.h"
110 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h" 112 #include "chrome/browser/ui/browser_tab_restore_service_delegate.h"
111 #include "chrome/browser/ui/browser_window.h" 113 #include "chrome/browser/ui/browser_window.h"
112 #include "chrome/browser/ui/constrained_window_tab_helper.h" 114 #include "chrome/browser/ui/constrained_window_tab_helper.h"
113 #include "chrome/browser/ui/extensions/shell_window.h" 115 #include "chrome/browser/ui/extensions/shell_window.h"
114 #include "chrome/browser/ui/find_bar/find_bar.h" 116 #include "chrome/browser/ui/find_bar/find_bar.h"
115 #include "chrome/browser/ui/find_bar/find_bar_controller.h" 117 #include "chrome/browser/ui/find_bar/find_bar_controller.h"
116 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 118 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
117 #include "chrome/browser/ui/fullscreen_controller.h" 119 #include "chrome/browser/ui/fullscreen_controller.h"
118 #include "chrome/browser/ui/global_error.h" 120 #include "chrome/browser/ui/global_error.h"
119 #include "chrome/browser/ui/global_error_service.h" 121 #include "chrome/browser/ui/global_error_service.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 /////////////////////////////////////////////////////////////////////////////// 335 ///////////////////////////////////////////////////////////////////////////////
334 // Browser, Constructors, Creation, Showing: 336 // Browser, Constructors, Creation, Showing:
335 337
336 Browser::Browser(Type type, Profile* profile) 338 Browser::Browser(Type type, Profile* profile)
337 : type_(type), 339 : type_(type),
338 profile_(profile), 340 profile_(profile),
339 window_(NULL), 341 window_(NULL),
340 ALLOW_THIS_IN_INITIALIZER_LIST( 342 ALLOW_THIS_IN_INITIALIZER_LIST(
341 tab_handler_(TabHandler::CreateTabHandler(this))), 343 tab_handler_(TabHandler::CreateTabHandler(this))),
342 command_updater_(this), 344 command_updater_(this),
343 toolbar_model_(this),
344 chrome_updater_factory_(this), 345 chrome_updater_factory_(this),
345 is_attempting_to_close_browser_(false), 346 is_attempting_to_close_browser_(false),
346 cancel_download_confirmation_state_(NOT_PROMPTED), 347 cancel_download_confirmation_state_(NOT_PROMPTED),
347 show_state_(ui::SHOW_STATE_DEFAULT), 348 show_state_(ui::SHOW_STATE_DEFAULT),
348 is_session_restore_(false), 349 is_session_restore_(false),
349 weak_factory_(this), 350 weak_factory_(this),
350 block_command_execution_(false), 351 block_command_execution_(false),
351 last_blocked_command_id_(-1), 352 last_blocked_command_id_(-1),
352 last_blocked_command_disposition_(CURRENT_TAB), 353 last_blocked_command_disposition_(CURRENT_TAB),
353 pending_web_app_action_(NONE), 354 pending_web_app_action_(NONE),
354 ALLOW_THIS_IN_INITIALIZER_LIST( 355 ALLOW_THIS_IN_INITIALIZER_LIST(
356 content_setting_bubble_model_delegate_(
357 new BrowserContentSettingBubbleModelDelegate(this))),
358 ALLOW_THIS_IN_INITIALIZER_LIST(
359 tab_contents_wrapper_container_(
360 new BrowserTabContentsWrapperContainer(this))),
361 ALLOW_THIS_IN_INITIALIZER_LIST(
355 tab_restore_service_delegate_( 362 tab_restore_service_delegate_(
356 new BrowserTabRestoreServiceDelegate(this))), 363 new BrowserTabRestoreServiceDelegate(this))),
357 ALLOW_THIS_IN_INITIALIZER_LIST( 364 ALLOW_THIS_IN_INITIALIZER_LIST(
358 synced_window_delegate_( 365 synced_window_delegate_(
359 new BrowserSyncedWindowDelegate(this))), 366 new BrowserSyncedWindowDelegate(this))),
360 bookmark_bar_state_(BookmarkBar::HIDDEN), 367 bookmark_bar_state_(BookmarkBar::HIDDEN),
361 window_has_shown_(false) { 368 window_has_shown_(false) {
369 toolbar_model_.reset(new ToolbarModel(tab_contents_wrapper_container()));
370
362 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED, 371 registrar_.Add(this, content::NOTIFICATION_SSL_VISIBLE_STATE_CHANGED,
363 content::NotificationService::AllSources()); 372 content::NotificationService::AllSources());
364 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, 373 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED,
365 content::Source<Profile>(profile_->GetOriginalProfile())); 374 content::Source<Profile>(profile_->GetOriginalProfile()));
366 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, 375 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED,
367 content::Source<Profile>(profile_->GetOriginalProfile())); 376 content::Source<Profile>(profile_->GetOriginalProfile()));
368 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, 377 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
369 content::Source<Profile>(profile_->GetOriginalProfile())); 378 content::Source<Profile>(profile_->GetOriginalProfile()));
370 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 379 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
371 content::Source<Profile>(profile_->GetOriginalProfile())); 380 content::Source<Profile>(profile_->GetOriginalProfile()));
(...skipping 1482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 1863
1855 service->RestoreMostRecentEntry(tab_restore_service_delegate()); 1864 service->RestoreMostRecentEntry(tab_restore_service_delegate());
1856 } 1865 }
1857 1866
1858 void Browser::WriteCurrentURLToClipboard() { 1867 void Browser::WriteCurrentURLToClipboard() {
1859 // TODO(ericu): There isn't currently a metric for this. Should there be? 1868 // TODO(ericu): There isn't currently a metric for this. Should there be?
1860 // We don't appear to track the action when it comes from the 1869 // We don't appear to track the action when it comes from the
1861 // RenderContextViewMenu. 1870 // RenderContextViewMenu.
1862 1871
1863 WebContents* contents = GetSelectedWebContents(); 1872 WebContents* contents = GetSelectedWebContents();
1864 if (!toolbar_model_.ShouldDisplayURL()) 1873 if (!toolbar_model_->ShouldDisplayURL())
1865 return; 1874 return;
1866 1875
1867 chrome_browser_net::WriteURLToClipboard( 1876 chrome_browser_net::WriteURLToClipboard(
1868 contents->GetURL(), 1877 contents->GetURL(),
1869 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), 1878 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
1870 g_browser_process->clipboard()); 1879 g_browser_process->clipboard());
1871 } 1880 }
1872 1881
1873 void Browser::ConvertPopupToTabbedBrowser() { 1882 void Browser::ConvertPopupToTabbedBrowser() {
1874 content::RecordAction(UserMetricsAction("ShowAsTab")); 1883 content::RecordAction(UserMetricsAction("ShowAsTab"));
(...skipping 3026 matching lines...) Expand 10 before | Expand all | Expand 10 after
4901 // Window management commands 4910 // Window management commands
4902 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB, 4911 command_updater_.UpdateCommandEnabled(IDC_DUPLICATE_TAB,
4903 !is_app() && CanDuplicateContentsAt(active_index())); 4912 !is_app() && CanDuplicateContentsAt(active_index()));
4904 4913
4905 // Page-related commands 4914 // Page-related commands
4906 window_->SetStarredState( 4915 window_->SetStarredState(
4907 current_tab_wrapper->bookmark_tab_helper()->is_starred()); 4916 current_tab_wrapper->bookmark_tab_helper()->is_starred());
4908 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE, 4917 command_updater_.UpdateCommandEnabled(IDC_VIEW_SOURCE,
4909 current_tab->GetController().CanViewSource()); 4918 current_tab->GetController().CanViewSource());
4910 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION, 4919 command_updater_.UpdateCommandEnabled(IDC_EMAIL_PAGE_LOCATION,
4911 toolbar_model_.ShouldDisplayURL() && current_tab->GetURL().is_valid()); 4920 toolbar_model_->ShouldDisplayURL() && current_tab->GetURL().is_valid());
4912 if (is_devtools()) 4921 if (is_devtools())
4913 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false); 4922 command_updater_.UpdateCommandEnabled(IDC_OPEN_FILE, false);
4914 4923
4915 // Changing the encoding is not possible on Chrome-internal webpages. 4924 // Changing the encoding is not possible on Chrome-internal webpages.
4916 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) || 4925 bool is_chrome_internal = HasInternalURL(nc.GetActiveEntry()) ||
4917 current_tab->ShowingInterstitialPage(); 4926 current_tab->ShowingInterstitialPage();
4918 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU, 4927 command_updater_.UpdateCommandEnabled(IDC_ENCODING_MENU,
4919 !is_chrome_internal && current_tab->IsSavable()); 4928 !is_chrome_internal && current_tab->IsSavable());
4920 4929
4921 // Show various bits of UI 4930 // Show various bits of UI
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
5648 ShowSingletonTabOverwritingNTP(params); 5657 ShowSingletonTabOverwritingNTP(params);
5649 } else { 5658 } else {
5650 LoginUIServiceFactory::GetForProfile( 5659 LoginUIServiceFactory::GetForProfile(
5651 profile()->GetOriginalProfile())->ShowLoginUI(); 5660 profile()->GetOriginalProfile())->ShowLoginUI();
5652 } 5661 }
5653 } 5662 }
5654 5663
5655 void Browser::ToggleSpeechInput() { 5664 void Browser::ToggleSpeechInput() {
5656 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput(); 5665 GetSelectedWebContents()->GetRenderViewHost()->ToggleSpeechInput();
5657 } 5666 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698