OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #if defined(TOOLKIT_USES_GTK) | 7 #if defined(TOOLKIT_USES_GTK) |
8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
54 #include "ui/base/theme_provider.h" | 54 #include "ui/base/theme_provider.h" |
55 #include "ui/gfx/canvas_skia.h" | 55 #include "ui/gfx/canvas_skia.h" |
56 #include "ui/gfx/color_utils.h" | 56 #include "ui/gfx/color_utils.h" |
57 #include "ui/gfx/image/image.h" | 57 #include "ui/gfx/image/image.h" |
58 #include "ui/gfx/skia_util.h" | 58 #include "ui/gfx/skia_util.h" |
59 #include "views/bubble/bubble_border.h" | 59 #include "views/bubble/bubble_border.h" |
60 #include "views/controls/label.h" | 60 #include "views/controls/label.h" |
61 #include "views/controls/textfield/native_textfield_views.h" | 61 #include "views/controls/textfield/native_textfield_views.h" |
62 #include "views/drag_utils.h" | 62 #include "views/drag_utils.h" |
63 | 63 |
64 #if !defined(OS_CHROMEOS) | |
65 #include "chrome/browser/ui/views/first_run_bubble.h" | |
66 #endif | |
67 | |
64 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
65 #include "chrome/browser/ui/views/first_run_bubble.h" | |
66 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" | 69 #include "chrome/browser/ui/views/location_bar/suggested_text_view.h" |
67 #endif | 70 #endif |
68 | 71 |
69 using views::View; | 72 using views::View; |
70 | 73 |
71 namespace { | 74 namespace { |
72 | 75 |
73 TabContents* GetTabContentsFromDelegate(LocationBarView::Delegate* delegate) { | 76 TabContents* GetTabContentsFromDelegate(LocationBarView::Delegate* delegate) { |
74 const TabContentsWrapper* wrapper = delegate->GetTabContentsWrapper(); | 77 const TabContentsWrapper* wrapper = delegate->GetTabContentsWrapper(); |
75 return wrapper ? wrapper->tab_contents() : NULL; | 78 return wrapper ? wrapper->tab_contents() : NULL; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
398 } | 401 } |
399 return NULL; | 402 return NULL; |
400 } | 403 } |
401 | 404 |
402 void LocationBarView::SetStarToggled(bool on) { | 405 void LocationBarView::SetStarToggled(bool on) { |
403 if (star_view_) | 406 if (star_view_) |
404 star_view_->SetToggled(on); | 407 star_view_->SetToggled(on); |
405 } | 408 } |
406 | 409 |
407 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { | 410 void LocationBarView::ShowStarBubble(const GURL& url, bool newly_bookmarked) { |
411 ShowFirstRunBubble(FirstRun::OEM_BUBBLE); | |
412 #ifdef NEVER | |
408 gfx::Rect screen_bounds(star_view_->GetImageBounds()); | 413 gfx::Rect screen_bounds(star_view_->GetImageBounds()); |
409 // Compensate for some built-in padding in the Star image. | 414 // Compensate for some built-in padding in the Star image. |
410 screen_bounds.Inset(1, 1, 1, 2); | 415 screen_bounds.Inset(1, 1, 1, 2); |
411 gfx::Point origin(screen_bounds.origin()); | 416 gfx::Point origin(screen_bounds.origin()); |
412 views::View::ConvertPointToScreen(star_view_, &origin); | 417 views::View::ConvertPointToScreen(star_view_, &origin); |
413 screen_bounds.set_origin(origin); | 418 screen_bounds.set_origin(origin); |
414 browser::ShowBookmarkBubbleView(GetWidget(), screen_bounds, star_view_, | 419 browser::ShowBookmarkBubbleView(GetWidget(), screen_bounds, star_view_, |
415 browser_->profile(), url, newly_bookmarked); | 420 browser_->profile(), url, newly_bookmarked); |
421 #endif | |
416 } | 422 } |
417 | 423 |
418 gfx::Point LocationBarView::GetLocationEntryOrigin() const { | 424 gfx::Point LocationBarView::GetLocationEntryOrigin() const { |
419 gfx::Point origin(location_entry_view_->bounds().origin()); | 425 gfx::Point origin(location_entry_view_->bounds().origin()); |
420 // If the UI layout is RTL, the coordinate system is not transformed and | 426 // If the UI layout is RTL, the coordinate system is not transformed and |
421 // therefore we need to adjust the X coordinate so that bubble appears on the | 427 // therefore we need to adjust the X coordinate so that bubble appears on the |
422 // right hand side of the location bar. | 428 // right hand side of the location bar. |
423 if (base::i18n::IsRTL()) | 429 if (base::i18n::IsRTL()) |
424 origin.set_x(width() - origin.x()); | 430 origin.set_x(width() - origin.x()); |
425 views::View::ConvertPointToScreen(this, &origin); | 431 views::View::ConvertPointToScreen(this, &origin); |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1015 ConvertPointToScreen(this, &screen_point); | 1021 ConvertPointToScreen(this, &screen_point); |
1016 if (views::Widget::IsPureViews()) | 1022 if (views::Widget::IsPureViews()) |
1017 NOTIMPLEMENTED(); | 1023 NOTIMPLEMENTED(); |
1018 else | 1024 else |
1019 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); | 1025 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); |
1020 } | 1026 } |
1021 #endif | 1027 #endif |
1022 | 1028 |
1023 void LocationBarView::ShowFirstRunBubbleInternal( | 1029 void LocationBarView::ShowFirstRunBubbleInternal( |
1024 FirstRun::BubbleType bubble_type) { | 1030 FirstRun::BubbleType bubble_type) { |
1025 #if defined(OS_WIN) // First run bubble doesn't make sense for Chrome OS. | 1031 // TODO(alicet): clean up all |bubble_type| reference in the codebase. |
1026 // Point at the start of the edit control; adjust to look as good as possible. | 1032 #if !defined(OS_CHROMEOS) |
1027 const int kXOffset = kNormalHorizontalEdgeThickness + kEdgeItemPadding + | 1033 // First run bubble doesn't make sense for Chrome OS. |
1028 ResourceBundle::GetSharedInstance().GetBitmapNamed( | 1034 // Point at the omnibox icon. |
1029 IDR_OMNIBOX_HTTP)->width() + kItemPadding; | 1035 // int location_y = kVerticalEdgeThickness; |
Miranda Callahan
2011/11/02 15:36:14
remove commented-out code.
alicet1
2011/11/03 18:21:51
Done.
| |
1030 const int kYOffset = -(kVerticalEdgeThickness + 2); | 1036 int location_height = std::max(height() - (kVerticalEdgeThickness * 2), 0); |
1031 gfx::Point origin(location_entry_view_->bounds().x() + kXOffset, | 1037 // const int kYOffset = -(kVerticalEdgeThickness * 2); |
Miranda Callahan
2011/11/02 15:36:14
same as above.
alicet1
2011/11/03 18:21:51
Done.
| |
1032 y() + height() + kYOffset); | 1038 const int kXOffset = ResourceBundle::GetSharedInstance().GetBitmapNamed( |
1039 IDR_OMNIBOX_HTTP)->width() / 2; | |
1040 gfx::Point origin(location_icon_view_->bounds().x() + kXOffset, | |
1041 location_height - 1); | |
1033 // If the UI layout is RTL, the coordinate system is not transformed and | 1042 // If the UI layout is RTL, the coordinate system is not transformed and |
1034 // therefore we need to adjust the X coordinate so that bubble appears on the | 1043 // therefore we need to adjust the X coordinate so that bubble appears on the |
1035 // right hand side of the location bar. | 1044 // right hand side of the location bar. |
1036 if (base::i18n::IsRTL()) | 1045 if (base::i18n::IsRTL()) |
1037 origin.set_x(width() - origin.x()); | 1046 origin.set_x(width() - origin.x()); |
1038 views::View::ConvertPointToScreen(this, &origin); | 1047 views::View::ConvertPointToScreen(this, &origin); |
1039 FirstRunBubble::Show(browser_->profile(), GetWidget(), | 1048 FirstRunBubble::Show(browser_->profile(), GetWidget(), |
1040 gfx::Rect(origin, gfx::Size()), | 1049 gfx::Rect(origin, gfx::Size()), |
1041 views::BubbleBorder::TOP_LEFT, bubble_type); | 1050 views::BubbleBorder::TOP_LEFT); |
1042 #endif | 1051 #endif |
1043 } | 1052 } |
1044 | 1053 |
1045 std::string LocationBarView::GetClassName() const { | 1054 std::string LocationBarView::GetClassName() const { |
1046 return kViewClassName; | 1055 return kViewClassName; |
1047 } | 1056 } |
1048 | 1057 |
1049 bool LocationBarView::SkipDefaultKeyEventProcessing( | 1058 bool LocationBarView::SkipDefaultKeyEventProcessing( |
1050 const views::KeyEvent& event) { | 1059 const views::KeyEvent& event) { |
1051 #if defined(OS_WIN) | 1060 #if defined(OS_WIN) |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1276 !suggested_text_view_->GetText().empty(); | 1285 !suggested_text_view_->GetText().empty(); |
1277 } | 1286 } |
1278 | 1287 |
1279 #if !defined(USE_AURA) | 1288 #if !defined(USE_AURA) |
1280 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { | 1289 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { |
1281 CHECK(!views::Widget::IsPureViews()); | 1290 CHECK(!views::Widget::IsPureViews()); |
1282 return static_cast<OmniboxViewWin*>(location_entry_.get()); | 1291 return static_cast<OmniboxViewWin*>(location_entry_.get()); |
1283 } | 1292 } |
1284 #endif | 1293 #endif |
1285 #endif | 1294 #endif |
OLD | NEW |