OLD | NEW |
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 11 matching lines...) Expand all Loading... |
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/browser_finder.h" | 28 #include "chrome/browser/ui/browser_finder.h" |
29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 29 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
30 #include "chrome/browser/ui/view_ids.h" | 30 #include "chrome/browser/ui/view_ids.h" |
31 #include "chrome/browser/ui/views/browser_dialogs.h" | 31 #include "chrome/browser/ui/views/browser_dialogs.h" |
| 32 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h" |
32 #include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h" | 33 #include "chrome/browser/ui/views/location_bar/chrome_to_mobile_view.h" |
33 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" | 34 #include "chrome/browser/ui/views/location_bar/content_setting_image_view.h" |
34 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" | 35 #include "chrome/browser/ui/views/location_bar/ev_bubble_view.h" |
35 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" | 36 #include "chrome/browser/ui/views/location_bar/keyword_hint_view.h" |
36 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" | 37 #include "chrome/browser/ui/views/location_bar/location_icon_view.h" |
37 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" | 38 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" |
38 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" | 39 #include "chrome/browser/ui/views/location_bar/page_action_with_badge_view.h" |
39 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" | 40 #include "chrome/browser/ui/views/location_bar/selected_keyword_view.h" |
40 #include "chrome/browser/ui/views/location_bar/star_view.h" | 41 #include "chrome/browser/ui/views/location_bar/star_view.h" |
41 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" | 42 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
42 #include "chrome/common/chrome_notification_types.h" | 43 #include "chrome/common/chrome_notification_types.h" |
43 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 45 #include "chrome/common/extensions/extension_switch_utils.h" |
44 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
45 #include "content/public/browser/notification_service.h" | 47 #include "content/public/browser/notification_service.h" |
46 #include "content/public/browser/render_widget_host_view.h" | 48 #include "content/public/browser/render_widget_host_view.h" |
47 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
48 #include "grit/generated_resources.h" | 50 #include "grit/generated_resources.h" |
49 #include "grit/theme_resources.h" | 51 #include "grit/theme_resources.h" |
50 #include "grit/theme_resources_standard.h" | 52 #include "grit/theme_resources_standard.h" |
51 #include "ui/base/accessibility/accessible_view_state.h" | 53 #include "ui/base/accessibility/accessible_view_state.h" |
52 #include "ui/base/dragdrop/drag_drop_types.h" | 54 #include "ui/base/dragdrop/drag_drop_types.h" |
53 #include "ui/base/l10n/l10n_util.h" | 55 #include "ui/base/l10n/l10n_util.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), | 138 content::PAGE_TRANSITION_FROM_ADDRESS_BAR)), |
137 location_icon_view_(NULL), | 139 location_icon_view_(NULL), |
138 ev_bubble_view_(NULL), | 140 ev_bubble_view_(NULL), |
139 location_entry_view_(NULL), | 141 location_entry_view_(NULL), |
140 selected_keyword_view_(NULL), | 142 selected_keyword_view_(NULL), |
141 #if defined(OS_WIN) || defined(USE_AURA) | 143 #if defined(OS_WIN) || defined(USE_AURA) |
142 suggested_text_view_(NULL), | 144 suggested_text_view_(NULL), |
143 #endif | 145 #endif |
144 keyword_hint_view_(NULL), | 146 keyword_hint_view_(NULL), |
145 star_view_(NULL), | 147 star_view_(NULL), |
| 148 action_box_button_view_(NULL), |
146 chrome_to_mobile_view_(NULL), | 149 chrome_to_mobile_view_(NULL), |
147 mode_(mode), | 150 mode_(mode), |
148 show_focus_rect_(false), | 151 show_focus_rect_(false), |
149 template_url_service_(NULL), | 152 template_url_service_(NULL), |
150 animation_offset_(0) { | 153 animation_offset_(0) { |
151 set_id(VIEW_ID_LOCATION_BAR); | 154 set_id(VIEW_ID_LOCATION_BAR); |
152 | 155 |
153 if (mode_ == NORMAL) { | 156 if (mode_ == NORMAL) { |
154 painter_.reset( | 157 painter_.reset( |
155 views::Painter::CreateImagePainter( | 158 views::Painter::CreateImagePainter( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
232 // Hide the star and Chrome To Mobile icons in popups and in the app launcher. | 235 if (extensions::switch_utils::IsActionBoxEnabled()) { |
233 if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 236 action_box_button_view_ = new ActionBoxButtonView(); |
| 237 AddChildView(action_box_button_view_); |
| 238 } else if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
| 239 // Hide the star and ChromeToMobile icons in popups and in the app launcher. |
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_); |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 location_icon_width = location_icon_view_->GetPreferredSize().width(); | 566 location_icon_width = location_icon_view_->GetPreferredSize().width(); |
561 entry_width -= (kEdgeThickness + GetEdgeItemPadding() + | 567 entry_width -= (kEdgeThickness + GetEdgeItemPadding() + |
562 location_icon_width + kItemEditPadding); | 568 location_icon_width + kItemEditPadding); |
563 } | 569 } |
564 | 570 |
565 if (star_view_ && star_view_->visible()) | 571 if (star_view_ && star_view_->visible()) |
566 entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding(); | 572 entry_width -= star_view_->GetPreferredSize().width() + GetItemPadding(); |
567 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) | 573 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) |
568 entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() + | 574 entry_width -= chrome_to_mobile_view_->GetPreferredSize().width() + |
569 GetItemPadding(); | 575 GetItemPadding(); |
| 576 if (action_box_button_view_) |
| 577 entry_width -= action_box_button_view_->GetPreferredSize().width() + |
| 578 GetItemPadding(); |
570 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 579 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
571 i != page_action_views_.end(); ++i) { | 580 i != page_action_views_.end(); ++i) { |
572 if ((*i)->visible()) | 581 if ((*i)->visible()) |
573 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); | 582 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); |
574 } | 583 } |
575 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); | 584 for (ContentSettingViews::const_iterator i(content_setting_views_.begin()); |
576 i != content_setting_views_.end(); ++i) { | 585 i != content_setting_views_.end(); ++i) { |
577 if ((*i)->visible()) | 586 if ((*i)->visible()) |
578 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); | 587 entry_width -= ((*i)->GetPreferredSize().width() + GetItemPadding()); |
579 } | 588 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 } | 645 } |
637 | 646 |
638 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { | 647 if (chrome_to_mobile_view_ && chrome_to_mobile_view_->visible()) { |
639 int icon_width = chrome_to_mobile_view_->GetPreferredSize().width(); | 648 int icon_width = chrome_to_mobile_view_->GetPreferredSize().width(); |
640 offset -= icon_width; | 649 offset -= icon_width; |
641 chrome_to_mobile_view_->SetBounds(offset, location_y, | 650 chrome_to_mobile_view_->SetBounds(offset, location_y, |
642 icon_width, location_height); | 651 icon_width, location_height); |
643 offset -= GetItemPadding(); | 652 offset -= GetItemPadding(); |
644 } | 653 } |
645 | 654 |
| 655 if (action_box_button_view_) { |
| 656 int button_width = action_box_button_view_->GetPreferredSize().width(); |
| 657 offset -= button_width; |
| 658 action_box_button_view_->SetBounds(offset, location_y, button_width, |
| 659 location_height); |
| 660 offset -= GetItemPadding(); |
| 661 } |
| 662 |
646 for (PageActionViews::const_iterator i(page_action_views_.begin()); | 663 for (PageActionViews::const_iterator i(page_action_views_.begin()); |
647 i != page_action_views_.end(); ++i) { | 664 i != page_action_views_.end(); ++i) { |
648 if ((*i)->visible()) { | 665 if ((*i)->visible()) { |
649 int page_action_width = (*i)->GetPreferredSize().width(); | 666 int page_action_width = (*i)->GetPreferredSize().width(); |
650 offset -= page_action_width; | 667 offset -= page_action_width; |
651 (*i)->SetBounds(offset, location_y, page_action_width, location_height); | 668 (*i)->SetBounds(offset, location_y, page_action_width, location_height); |
652 offset -= GetItemPadding(); | 669 offset -= GetItemPadding(); |
653 } | 670 } |
654 } | 671 } |
655 // We use a reverse_iterator here because we're laying out the views from | 672 // We use a reverse_iterator here because we're laying out the views from |
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && | 1303 return suggested_text_view_ && !suggested_text_view_->size().IsEmpty() && |
1287 !suggested_text_view_->text().empty(); | 1304 !suggested_text_view_->text().empty(); |
1288 } | 1305 } |
1289 | 1306 |
1290 #if !defined(USE_AURA) | 1307 #if !defined(USE_AURA) |
1291 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1308 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1292 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1309 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1293 } | 1310 } |
1294 #endif | 1311 #endif |
1295 #endif | 1312 #endif |
OLD | NEW |