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

Side by Side Diff: chrome/browser/ui/views/toolbar_view.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: call right overloaded method 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
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/views/toolbar_view.h" 5 #include "chrome/browser/ui/views/toolbar_view.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/app/chrome_command_ids.h" 9 #include "chrome/app/chrome_command_ids.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_content_setting_bubble_model_delegate.h"
13 #include "chrome/browser/ui/browser_window.h" 14 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/global_error_service.h" 15 #include "chrome/browser/ui/global_error_service.h"
15 #include "chrome/browser/ui/global_error_service_factory.h" 16 #include "chrome/browser/ui/global_error_service_factory.h"
16 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" 17 #include "chrome/browser/ui/toolbar/wrench_menu_model.h"
17 #include "chrome/browser/ui/view_ids.h" 18 #include "chrome/browser/ui/view_ids.h"
18 #include "chrome/browser/ui/views/browser_actions_container.h" 19 #include "chrome/browser/ui/views/browser_actions_container.h"
19 #include "chrome/browser/ui/views/event_utils.h" 20 #include "chrome/browser/ui/views/event_utils.h"
21 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
20 #include "chrome/browser/ui/views/window.h" 22 #include "chrome/browser/ui/views/window.h"
21 #include "chrome/browser/ui/views/wrench_menu.h" 23 #include "chrome/browser/ui/views/wrench_menu.h"
22 #include "chrome/browser/upgrade_detector.h" 24 #include "chrome/browser/upgrade_detector.h"
23 #include "chrome/common/chrome_notification_types.h" 25 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
25 #include "content/public/browser/browser_accessibility_state.h" 27 #include "content/public/browser/browser_accessibility_state.h"
26 #include "content/public/browser/notification_service.h" 28 #include "content/public/browser/notification_service.h"
27 #include "content/public/browser/user_metrics.h" 29 #include "content/public/browser/user_metrics.h"
28 #include "grit/chromium_strings.h" 30 #include "grit/chromium_strings.h"
29 #include "grit/generated_resources.h" 31 #include "grit/generated_resources.h"
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 164
163 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get()); 165 forward_ = new views::ButtonDropDown(this, forward_menu_model_.get());
164 forward_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | 166 forward_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON |
165 ui::EF_MIDDLE_MOUSE_BUTTON); 167 ui::EF_MIDDLE_MOUSE_BUTTON);
166 forward_->set_tag(IDC_FORWARD); 168 forward_->set_tag(IDC_FORWARD);
167 forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD)); 169 forward_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_FORWARD));
168 forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD)); 170 forward_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_FORWARD));
169 forward_->set_id(VIEW_ID_FORWARD_BUTTON); 171 forward_->set_id(VIEW_ID_FORWARD_BUTTON);
170 172
171 // Have to create this before |reload_| as |reload_|'s constructor needs it. 173 // Have to create this before |reload_| as |reload_|'s constructor needs it.
172 location_bar_ = new LocationBarView(browser_, model_, this, 174 location_bar_ = new LocationBarView(
175 browser_->profile(),
176 browser_->command_updater(),
177 model_,
178 this,
173 (display_mode_ == DISPLAYMODE_LOCATION) ? 179 (display_mode_ == DISPLAYMODE_LOCATION) ?
174 LocationBarView::POPUP : LocationBarView::NORMAL); 180 LocationBarView::POPUP : LocationBarView::NORMAL);
175 181
176 reload_ = new ReloadButton(location_bar_, browser_); 182 reload_ = new ReloadButton(location_bar_, browser_->command_updater());
177 reload_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | 183 reload_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON |
178 ui::EF_MIDDLE_MOUSE_BUTTON); 184 ui::EF_MIDDLE_MOUSE_BUTTON);
179 reload_->set_tag(IDC_RELOAD); 185 reload_->set_tag(IDC_RELOAD);
180 reload_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD)); 186 reload_->SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_RELOAD));
181 reload_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD)); 187 reload_->SetAccessibleName(l10n_util::GetStringUTF16(IDS_ACCNAME_RELOAD));
182 reload_->set_id(VIEW_ID_RELOAD_BUTTON); 188 reload_->set_id(VIEW_ID_RELOAD_BUTTON);
183 189
184 home_ = new views::ImageButton(this); 190 home_ = new views::ImageButton(this);
185 home_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON | 191 home_->set_triggerable_event_flags(ui::EF_LEFT_MOUSE_BUTTON |
186 ui::EF_MIDDLE_MOUSE_BUTTON); 192 ui::EF_MIDDLE_MOUSE_BUTTON);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // ToolbarView, LocationBarView::Delegate implementation: 365 // ToolbarView, LocationBarView::Delegate implementation:
360 366
361 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() const { 367 TabContentsWrapper* ToolbarView::GetTabContentsWrapper() const {
362 return browser_->GetSelectedTabContentsWrapper(); 368 return browser_->GetSelectedTabContentsWrapper();
363 } 369 }
364 370
365 InstantController* ToolbarView::GetInstant() { 371 InstantController* ToolbarView::GetInstant() {
366 return browser_->instant(); 372 return browser_->instant();
367 } 373 }
368 374
375 ContentSettingBubbleModelDelegate*
376 ToolbarView::GetContentSettingBubbleModelDelegate() {
377 return browser_->content_setting_bubble_model_delegate();
378 }
379
380 void ToolbarView::ShowPageInfo(content::WebContents* web_contents,
381 const GURL& url,
382 const content::SSLStatus& ssl,
383 bool show_history) {
384 browser_->ShowPageInfo(web_contents, url, ssl, show_history);
385 }
386
387 views::Widget* ToolbarView::CreateViewsBubble(
388 views::BubbleDelegateView* bubble_delegate) {
389 return browser::CreateViewsBubble(bubble_delegate);
390 }
391
392 PageActionImageView* ToolbarView::CreatePageActionImageView(
393 LocationBarView* owner, ExtensionAction* action) {
394 return new PageActionImageView(owner, action, browser_);
395 }
396
369 void ToolbarView::OnInputInProgress(bool in_progress) { 397 void ToolbarView::OnInputInProgress(bool in_progress) {
370 // The edit should make sure we're only notified when something changes. 398 // The edit should make sure we're only notified when something changes.
371 DCHECK(model_->input_in_progress() != in_progress); 399 DCHECK(model_->input_in_progress() != in_progress);
372 400
373 model_->set_input_in_progress(in_progress); 401 model_->set_input_in_progress(in_progress);
374 location_bar_->Update(NULL); 402 location_bar_->Update(NULL);
375 } 403 }
376 404
377 //////////////////////////////////////////////////////////////////////////////// 405 ////////////////////////////////////////////////////////////////////////////////
378 // ToolbarView, CommandUpdater::CommandObserver implementation: 406 // ToolbarView, CommandUpdater::CommandObserver implementation:
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 accname_app = l10n_util::GetStringFUTF16( 775 accname_app = l10n_util::GetStringFUTF16(
748 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app); 776 IDS_ACCNAME_APP_UPGRADE_RECOMMENDED, accname_app);
749 } 777 }
750 app_menu_->SetAccessibleName(accname_app); 778 app_menu_->SetAccessibleName(accname_app);
751 779
752 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL)); 780 app_menu_->SetIcon(GetAppMenuIcon(views::CustomButton::BS_NORMAL));
753 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT)); 781 app_menu_->SetHoverIcon(GetAppMenuIcon(views::CustomButton::BS_HOT));
754 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED)); 782 app_menu_->SetPushedIcon(GetAppMenuIcon(views::CustomButton::BS_PUSHED));
755 SchedulePaint(); 783 SchedulePaint();
756 } 784 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/toolbar_view.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698