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

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

Issue 8265005: first run bubble using the views/bubble api. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: update Created 9 years, 1 month 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) 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
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 938 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 ConvertPointToScreen(this, &screen_point); 1017 ConvertPointToScreen(this, &screen_point);
1015 if (views::Widget::IsPureViews()) 1018 if (views::Widget::IsPureViews())
1016 NOTIMPLEMENTED(); 1019 NOTIMPLEMENTED();
1017 else 1020 else
1018 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); 1021 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT());
1019 } 1022 }
1020 #endif 1023 #endif
1021 1024
1022 void LocationBarView::ShowFirstRunBubbleInternal( 1025 void LocationBarView::ShowFirstRunBubbleInternal(
1023 FirstRun::BubbleType bubble_type) { 1026 FirstRun::BubbleType bubble_type) {
1024 #if defined(OS_WIN) // First run bubble doesn't make sense for Chrome OS. 1027 // TODO(alicet): clean up all |bubble_type| reference in the codebase.
1025 // Point at the start of the edit control; adjust to look as good as possible. 1028 #if !defined(OS_CHROMEOS)
1026 const int kXOffset = kNormalHorizontalEdgeThickness + kEdgeItemPadding + 1029 // First run bubble doesn't make sense for Chrome OS.
1027 ResourceBundle::GetSharedInstance().GetBitmapNamed( 1030 // Point at the omnibox icon.
1028 IDR_OMNIBOX_HTTP)->width() + kItemPadding; 1031 int location_height = std::max(height() - (kVerticalEdgeThickness * 2), 0);
msw 2011/11/03 20:25:38 Shouldn't the vertical position be in terms of the
alicet1 2011/11/04 22:37:36 I remembered trying that and the bubble was positi
1029 const int kYOffset = -(kVerticalEdgeThickness + 2); 1032 const int kXOffset = ResourceBundle::GetSharedInstance().GetBitmapNamed(
msw 2011/11/03 20:25:38 Shouldn't this be simply getting the middle of the
1030 gfx::Point origin(location_entry_view_->bounds().x() + kXOffset, 1033 IDR_OMNIBOX_HTTP)->width() / 2;
1031 y() + height() + kYOffset); 1034 gfx::Point origin(location_icon_view_->bounds().x() + kXOffset,
msw 2011/11/03 20:25:38 you can just call x() on the view.
1035 location_height - 1);
msw 2011/11/03 20:25:38 Why '- 1'?
1032 // If the UI layout is RTL, the coordinate system is not transformed and 1036 // If the UI layout is RTL, the coordinate system is not transformed and
1033 // therefore we need to adjust the X coordinate so that bubble appears on the 1037 // therefore we need to adjust the X coordinate so that bubble appears on the
1034 // right hand side of the location bar. 1038 // right hand side of the location bar.
1035 if (base::i18n::IsRTL()) 1039 if (base::i18n::IsRTL())
1036 origin.set_x(width() - origin.x()); 1040 origin.set_x(width() - origin.x());
1037 views::View::ConvertPointToScreen(this, &origin); 1041 views::View::ConvertPointToScreen(this, &origin);
1038 FirstRunBubble::Show(browser_->profile(), GetWidget(), 1042 FirstRunBubble::Show(browser_->profile(), GetWidget(),
1039 gfx::Rect(origin, gfx::Size()), 1043 gfx::Rect(origin, gfx::Size()),
1040 views::BubbleBorder::TOP_LEFT, bubble_type); 1044 views::BubbleBorder::TOP_LEFT);
1041 #endif 1045 #endif
1042 } 1046 }
1043 1047
1044 std::string LocationBarView::GetClassName() const { 1048 std::string LocationBarView::GetClassName() const {
1045 return kViewClassName; 1049 return kViewClassName;
1046 } 1050 }
1047 1051
1048 bool LocationBarView::SkipDefaultKeyEventProcessing( 1052 bool LocationBarView::SkipDefaultKeyEventProcessing(
1049 const views::KeyEvent& event) { 1053 const views::KeyEvent& event) {
1050 #if defined(OS_WIN) 1054 #if defined(OS_WIN)
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1275 !suggested_text_view_->GetText().empty(); 1279 !suggested_text_view_->GetText().empty();
1276 } 1280 }
1277 1281
1278 #if !defined(USE_AURA) 1282 #if !defined(USE_AURA)
1279 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { 1283 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() {
1280 CHECK(!views::Widget::IsPureViews()); 1284 CHECK(!views::Widget::IsPureViews());
1281 return static_cast<OmniboxViewWin*>(location_entry_.get()); 1285 return static_cast<OmniboxViewWin*>(location_entry_.get());
1282 } 1286 }
1283 #endif 1287 #endif
1284 #endif 1288 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698