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/stl_util.h" | 10 #include "base/stl_util.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 #include "ui/compositor/layer.h" | 88 #include "ui/compositor/layer.h" |
89 #include "ui/compositor/scoped_layer_animation_settings.h" | 89 #include "ui/compositor/scoped_layer_animation_settings.h" |
90 #endif | 90 #endif |
91 | 91 |
92 using content::WebContents; | 92 using content::WebContents; |
93 using views::View; | 93 using views::View; |
94 | 94 |
95 namespace { | 95 namespace { |
96 | 96 |
97 WebContents* GetWebContentsFromDelegate(LocationBarView::Delegate* delegate) { | 97 WebContents* GetWebContentsFromDelegate(LocationBarView::Delegate* delegate) { |
98 const TabContents* tab_contents = delegate->GetTabContents(); | 98 const TabContents* tab_contents = delegate->GetTabContents(); |
Peter Kasting
2012/07/18 03:26:30
Nit: While you're touching this file, can you mayb
Kyle Horimoto
2012/07/18 23:49:38
Done. But FYI, this specific case is not a member
| |
99 return tab_contents ? tab_contents->web_contents() : NULL; | 99 return tab_contents ? tab_contents->web_contents() : NULL; |
100 } | 100 } |
101 | 101 |
102 Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { | 102 Browser* GetBrowserFromDelegate(LocationBarView::Delegate* delegate) { |
103 WebContents* contents = GetWebContentsFromDelegate(delegate); | 103 WebContents* contents = GetWebContentsFromDelegate(delegate); |
104 return browser::FindBrowserWithWebContents(contents); | 104 return browser::FindBrowserWithWebContents(contents); |
105 } | 105 } |
106 | 106 |
107 // Height of the location bar's round corner region. | 107 // Height of the location bar's round corner region. |
108 const int kBorderRoundCornerHeight = 5; | 108 const int kBorderRoundCornerHeight = 5; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 keyword_hint_view_->SetFont(font_); | 263 keyword_hint_view_->SetFont(font_); |
264 | 264 |
265 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 265 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
266 ContentSettingImageView* content_blocked_view = | 266 ContentSettingImageView* content_blocked_view = |
267 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); | 267 new ContentSettingImageView(static_cast<ContentSettingsType>(i), this); |
268 content_setting_views_.push_back(content_blocked_view); | 268 content_setting_views_.push_back(content_blocked_view); |
269 AddChildView(content_blocked_view); | 269 AddChildView(content_blocked_view); |
270 content_blocked_view->SetVisible(false); | 270 content_blocked_view->SetVisible(false); |
271 } | 271 } |
272 | 272 |
273 zoom_view_ = new ZoomView(model_); | 273 // Create the zoom view. At this point, |delegate_| has not yet been assigned |
274 // a TabContents, so calling GetTabContents() will just return NULL. Thus, | |
275 // |delegate_| itself is passed here, where it can be queried at a later time | |
276 // for the appropriate TabContents. | |
Peter Kasting
2012/07/18 03:26:30
Nit: This seems a little sketchy since apparently
Kyle Horimoto
2012/07/18 23:49:38
Hmm, not exactly. ToolbarView creates a LocationBa
| |
277 zoom_view_ = new ZoomView(model_, delegate_); | |
274 AddChildView(zoom_view_); | 278 AddChildView(zoom_view_); |
275 | 279 |
276 if (extensions::switch_utils::IsActionBoxEnabled()) { | 280 if (extensions::switch_utils::IsActionBoxEnabled()) { |
277 action_box_button_view_ = new ActionBoxButtonView( | 281 action_box_button_view_ = new ActionBoxButtonView( |
278 extensions::ExtensionSystem::Get(profile_)->extension_service()); | 282 extensions::ExtensionSystem::Get(profile_)->extension_service()); |
279 AddChildView(action_box_button_view_); | 283 AddChildView(action_box_button_view_); |
280 } else if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { | 284 } else if (browser_defaults::bookmarks_enabled && (mode_ == NORMAL)) { |
281 // Note: condition above means that the star and ChromeToMobile icons are | 285 // Note: condition above means that the star and ChromeToMobile icons are |
282 // hidden in popups and in the app launcher. | 286 // hidden in popups and in the app launcher. |
283 star_view_ = new StarView(command_updater_); | 287 star_view_ = new StarView(command_updater_); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
507 } | 511 } |
508 | 512 |
509 void LocationBarView::SetZoomIconState( | 513 void LocationBarView::SetZoomIconState( |
510 ZoomController::ZoomIconState zoom_icon_state) { | 514 ZoomController::ZoomIconState zoom_icon_state) { |
511 zoom_view_->SetZoomIconState(zoom_icon_state); | 515 zoom_view_->SetZoomIconState(zoom_icon_state); |
512 | 516 |
513 Layout(); | 517 Layout(); |
514 SchedulePaint(); | 518 SchedulePaint(); |
515 } | 519 } |
516 | 520 |
517 void LocationBarView::ShowZoomBubble(int zoom_percent) { | 521 void LocationBarView::ShowZoomBubble(int zoom_percent) { |
Peter Kasting
2012/07/18 03:26:30
Nit: If this argument is no longer used, can we un
Kyle Horimoto
2012/07/18 23:49:38
This is already being done: http://codereview.chro
| |
518 ZoomBubbleView::ShowBubble(zoom_view_, zoom_percent, true); | 522 ZoomBubbleView::ShowBubble(zoom_view_, GetTabContents(), true); |
519 } | 523 } |
520 | 524 |
521 void LocationBarView::ShowChromeToMobileBubble() { | 525 void LocationBarView::ShowChromeToMobileBubble() { |
522 Browser* browser = GetBrowserFromDelegate(delegate_); | 526 Browser* browser = GetBrowserFromDelegate(delegate_); |
523 chrome::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, browser); | 527 chrome::ShowChromeToMobileBubbleView(chrome_to_mobile_view_, browser); |
524 } | 528 } |
525 | 529 |
526 gfx::Point LocationBarView::GetLocationEntryOrigin() const { | 530 gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
527 gfx::Point origin(location_entry_view_->bounds().origin()); | 531 gfx::Point origin(location_entry_view_->bounds().origin()); |
528 // If the UI layout is RTL, the coordinate system is not transformed and | 532 // If the UI layout is RTL, the coordinate system is not transformed and |
(...skipping 966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1495 } | 1499 } |
1496 | 1500 |
1497 void LocationBarView::CleanupFadeAnimation() { | 1501 void LocationBarView::CleanupFadeAnimation() { |
1498 // Since we're no longer animating we don't need our layer. | 1502 // Since we're no longer animating we don't need our layer. |
1499 SetPaintToLayer(false); | 1503 SetPaintToLayer(false); |
1500 // Bubble labels don't need a transparent background anymore. | 1504 // Bubble labels don't need a transparent background anymore. |
1501 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1505 ev_bubble_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
1502 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); | 1506 selected_keyword_view_->SetLabelBackgroundColor(SK_ColorWHITE); |
1503 } | 1507 } |
1504 #endif // USE_AURA | 1508 #endif // USE_AURA |
OLD | NEW |