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

Side by Side Diff: chrome/browser/ui/views/location_bar/location_bar_view.cc

Issue 10406016: Implement Action Box button (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 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/views/location_bar/location_bar_view.h" 5 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/favicon/favicon_tab_helper.h" 21 #include "chrome/browser/favicon/favicon_tab_helper.h"
22 #include "chrome/browser/instant/instant_controller.h" 22 #include "chrome/browser/instant/instant_controller.h"
23 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/search_engines/template_url.h" 24 #include "chrome/browser/search_engines/template_url.h"
25 #include "chrome/browser/search_engines/template_url_service.h" 25 #include "chrome/browser/search_engines/template_url_service.h"
26 #include "chrome/browser/search_engines/template_url_service_factory.h" 26 #include "chrome/browser/search_engines/template_url_service_factory.h"
27 #include "chrome/browser/ui/browser.h" 27 #include "chrome/browser/ui/browser.h"
28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
29 #include "chrome/browser/ui/view_ids.h" 29 #include "chrome/browser/ui/view_ids.h"
30 #include "chrome/browser/ui/views/browser_dialogs.h" 30 #include "chrome/browser/ui/views/browser_dialogs.h"
31 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h"
31 #include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h" 32 #include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h"
32 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" 33 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h"
33 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" 34 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h"
34 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" 35 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h"
35 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" 36 #include "chrome/browser/ui/views/location_bar/location_icon_view.h"
36 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 37 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
37 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" 38 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h"
38 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" 39 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h"
39 #include "chrome/browser/ui/views/location_bar/star_view.h" 40 #include "chrome/browser/ui/views/location_bar/star_view.h"
40 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" 41 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h"
41 #include "chrome/common/chrome_notification_types.h" 42 #include "chrome/common/chrome_notification_types.h"
42 #include "chrome/common/chrome_switches.h" 43 #include "chrome/common/chrome_switches.h"
44 #include "chrome/common/extensions/extension_switch_utils.h"
43 #include "chrome/common/pref_names.h" 45 #include "chrome/common/pref_names.h"
44 #include "content/public/browser/notification_service.h" 46 #include "content/public/browser/notification_service.h"
45 #include "content/public/browser/render_widget_host_view.h" 47 #include "content/public/browser/render_widget_host_view.h"
46 #include "content/public/browser/web_contents.h" 48 #include "content/public/browser/web_contents.h"
47 #include "grit/generated_resources.h" 49 #include "grit/generated_resources.h"
48 #include "grit/theme_resources.h" 50 #include "grit/theme_resources.h"
49 #include "grit/theme_resources_standard.h" 51 #include "grit/theme_resources_standard.h"
50 #include "ui/base/accessibility/accessible_view_state.h" 52 #include "ui/base/accessibility/accessible_view_state.h"
51 #include "ui/base/dragdrop/drag_drop_types.h" 53 #include "ui/base/dragdrop/drag_drop_types.h"
52 #include "ui/base/l10n/l10n_util.h" 54 #include "ui/base/l10n/l10n_util.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), 137 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)),
136 location_icon_view_(NULL), 138 location_icon_view_(NULL),
137 ev_bubble_view_(NULL), 139 ev_bubble_view_(NULL),
138 location_entry_view_(NULL), 140 location_entry_view_(NULL),
139 selected_keyword_view_(NULL), 141 selected_keyword_view_(NULL),
140 #if defined(OS_WIN) || defined(USE_AURA) 142 #if defined(OS_WIN) || defined(USE_AURA)
141 suggested_text_view_(NULL), 143 suggested_text_view_(NULL),
142 #endif 144 #endif
143 keyword_hint_view_(NULL), 145 keyword_hint_view_(NULL),
144 star_view_(NULL), 146 star_view_(NULL),
147 action_box_button_view_(NULL),
145 chrome_to_mobile_view_(NULL), 148 chrome_to_mobile_view_(NULL),
146 mode_(mode), 149 mode_(mode),
147 show_focus_rect_(false), 150 show_focus_rect_(false),
148 template_url_service_(NULL), 151 template_url_service_(NULL),
149 animation_offset_(0) { 152 animation_offset_(0) {
150 set_id(VIEW_ID_LOCATION_BAR); 153 set_id(VIEW_ID_LOCATION_BAR);
151 154
152 if (mode_ == NORMAL) { 155 if (mode_ == NORMAL) {
153 painter_.reset( 156 painter_.reset(
154 views::Painter::CreateImagePainter( 157 views::Painter::CreateImagePainter(
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 keyword_hint_view_->SetFont(font_); 225 keyword_hint_view_->SetFont(font_);
223 226
224 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { 227 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) {
225 ContentSettingImageView* content_blocked_view = 228 ContentSettingImageView* content_blocked_view =
226 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); 229 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this);
227 content_setting_views_.push_back(content_blocked_view); 230 content_setting_views_.push_back(content_blocked_view);
228 AddChildView(content_blocked_view); 231 AddChildView(content_blocked_view);
229 content_blocked_view->SetVisible(false); 232 content_blocked_view->SetVisible(false);
230 } 233 }
231 234
235 bool action_box_enabled = extensions::switch_utils::IsActionBoxEnabled();
236
232 // Hide the star and Chrome To Mobile icons in popups and in the app launcher. 237 // Hide the star and Chrome To Mobile icons in popups and in the app launcher.
233 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { 238 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL) &&
239 !action_box_enabled) {
234 star_view_ = new StarView(command_updater_); 240 star_view_ = new StarView(command_updater_);
235 AddChildView(star_view_); 241 AddChildView(star_view_);
236 star_view_->SetVisible(true); 242 star_view_->SetVisible(true);
237 243
238 // Also disable Chrome To Mobile for off-the-record and non-synced profiles, 244 // Also disable Chrome To Mobile for off-the-record and non-synced profiles,
239 // or if the feature is disabled by a command line flag or chrome://flags. 245 // or if the feature is disabled by a command line flag or chrome://flags.
240 if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible() && 246 if (!profile_->IsOffTheRecord() && profile_->IsSyncAccessible() &&
241 ChromeToMobileService::IsChromeToMobileEnabled()) { 247 ChromeToMobileService::IsChromeToMobileEnabled()) {
242 chrome_to_mobile_view_ = new ChromeToMobileView(this, command_updater_); 248 chrome_to_mobile_view_ = new ChromeToMobileView(this, command_updater_);
243 AddChildView(chrome_to_mobile_view_); 249 AddChildView(chrome_to_mobile_view_);
244 ChromeToMobileService* service = 250 ChromeToMobileService* service =
245 ChromeToMobileServiceFactory::GetForProfile(profile_); 251 ChromeToMobileServiceFactory::GetForProfile(profile_);
246 service->RequestMobileListUpdate(); 252 service->RequestMobileListUpdate();
247 chrome_to_mobile_view_->SetVisible(service->HasDevices()); 253 chrome_to_mobile_view_->SetVisible(service->HasDevices());
248 } 254 }
249 } 255 }
250 256
257 if (action_box_enabled) {
258 action_box_button_view_ = new ActionBoxButtonView(command_updater_);
259 AddChildView(action_box_button_view_);
260 action_box_button_view_->SetVisible(true);
sky 2012/05/17 21:21:07 visible is the default.
yefimt 2012/05/17 22:42:52 Done.
261 }
262
251 // Initialize the location entry. We do this to avoid a black flash which is 263 // Initialize the location entry. We do this to avoid a black flash which is
252 // visible when the location entry has just been initialized. 264 // visible when the location entry has just been initialized.
253 Update(NULL); 265 Update(NULL);
254 266
255 OnChanged(); 267 OnChanged();
256 } 268 }
257 269
258 bool LocationBarView::IsInitialized() const { 270 bool LocationBarView::IsInitialized() const {
259 return location_entry_view_ != NULL; 271 return location_entry_view_ != NULL;
260 } 272 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
560 location_icon_width = location_icon_view_->GetPreferredSize().width(); 572 location_icon_width = location_icon_view_->GetPreferredSize().width();
561 entry_width -= (kEdgeThickness + GetEdgeItemPadding() + 573 entry_width -= (kEdgeThickness + GetEdgeItemPadding() +
562 location_icon_width + kItemEditPadding); 574 location_icon_width + kItemEditPadding);
563 } 575 }
564 576
565 if (star_view_ && star_view_->visible()) 577 if (star_view_ && star_view_->visible())
566 entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding(); 578 entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding();
567 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) 579 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible())
568 entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() + 580 entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() +
569 GetItemPadding(); 581 GetItemPadding();
582 if (action_box_button_view_ && action_box_button_view_->visible())
583 entry_width -= action_box_button_view_->GetPreferredSize().width() +
584 GetItemPadding();
570 for (PageActionViews::const_iterator i(page_action_views_.begin()); 585 for (PageActionViews::const_iterator i(page_action_views_.begin());
571 i != page_action_views_.end(); ++i) { 586 i != page_action_views_.end(); ++i) {
572 if ((*i)->visible()) 587 if ((*i)->visible())
573 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); 588 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding());
574 } 589 }
575 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); 590 for (ContentSettingViews::const_iterator i(content_setting_views_.begin());
576 i != content_setting_views_.end(); ++i) { 591 i != content_setting_views_.end(); ++i) {
577 if ((*i)->visible()) 592 if ((*i)->visible())
578 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); 593 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding());
579 } 594 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 651 }
637 652
638 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { 653 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) {
639 int icon_width = chrome_to_mobile_view_->GetPreferredSize().width(); 654 int icon_width = chrome_to_mobile_view_->GetPreferredSize().width();
640 offset -= icon_width; 655 offset -= icon_width;
641 chrome_to_mobile_view_->SetBounds(offset, location_y, 656 chrome_to_mobile_view_->SetBounds(offset, location_y,
642 icon_width, location_height); 657 icon_width, location_height);
643 offset -= GetItemPadding(); 658 offset -= GetItemPadding();
644 } 659 }
645 660
661 if (action_box_button_view_ && action_box_button_view_->visible()) {
sky 2012/05/17 21:21:07 You always make it visible, so no need for the vis
yefimt 2012/05/17 22:42:52 Done.
662 int button_width = action_box_button_view_->GetPreferredSize().width();
663 offset -= button_width;
664 action_box_button_view_->SetBounds(offset, location_y, button_width,
665 location_height);
666 offset -= GetItemPadding();
667 }
668
646 for (PageActionViews::const_iterator i(page_action_views_.begin()); 669 for (PageActionViews::const_iterator i(page_action_views_.begin());
647 i != page_action_views_.end(); ++i) { 670 i != page_action_views_.end(); ++i) {
648 if ((*i)->visible()) { 671 if ((*i)->visible()) {
649 int page_action_width = (*i)->GetPreferredSize().width(); 672 int page_action_width = (*i)->GetPreferredSize().width();
650 offset -= page_action_width; 673 offset -= page_action_width;
651 (*i)->SetBounds(offset, location_y, page_action_width, location_height); 674 (*i)->SetBounds(offset, location_y, page_action_width, location_height);
652 offset -= GetItemPadding(); 675 offset -= GetItemPadding();
653 } 676 }
654 } 677 }
655 // We use a reverse_iterator here because we're laying out the views from 678 // We use a reverse_iterator here because we're laying out the views from
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && 1304 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() &&
1282 !suggested_text_view_->text().empty(); 1305 !suggested_text_view_->text().empty();
1283 } 1306 }
1284 1307
1285 #if !defined(USE_AURA) 1308 #if !defined(USE_AURA)
1286 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { 1309 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() {
1287 return static_cast<OmniboxViewWin*>(location_entry_.get()); 1310 return static_cast<OmniboxViewWin*>(location_entry_.get());
1288 } 1311 }
1289 #endif 1312 #endif
1290 #endif 1313 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698