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

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)
Miranda Callahan 2011/11/11 15:26:24 This shouldn't be included for OS_MAC, either.
msw 2011/11/11 19:05:25 I don't think we typically need to explicitly excl
Miranda Callahan 2011/11/11 20:04:46 Oh, good point -- we're already in /views, so we d
alicet1 2011/11/12 00:03:51 I think the mac branch is under http://src.chromiu
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 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 ConvertPointToScreen(this, &screen_point); 987 ConvertPointToScreen(this, &screen_point);
985 if (views::Widget::IsPureViews()) 988 if (views::Widget::IsPureViews())
986 NOTIMPLEMENTED(); 989 NOTIMPLEMENTED();
987 else 990 else
988 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT()); 991 GetOmniboxViewWin()->HandleExternalMsg(msg, flags, screen_point.ToPOINT());
989 } 992 }
990 #endif 993 #endif
991 994
992 void LocationBarView::ShowFirstRunBubbleInternal( 995 void LocationBarView::ShowFirstRunBubbleInternal(
993 FirstRun::BubbleType bubble_type) { 996 FirstRun::BubbleType bubble_type) {
994 #if defined(OS_WIN) // First run bubble doesn't make sense for Chrome OS. 997 #if !defined(OS_CHROMEOS)
995 // Point at the start of the edit control; adjust to look as good as possible. 998 // First run bubble doesn't make sense for Chrome OS.
996 const int kXOffset = kNormalHorizontalEdgeThickness + kEdgeItemPadding + 999 // Point at the base of the omnibox icon. location_icon_view_ height
997 ResourceBundle::GetSharedInstance().GetBitmapNamed( 1000 // already includes padding, we want the tip of the bubble to be closer
998 IDR_OMNIBOX_HTTP)->width() + kItemPadding; 1001 // to the height the bitmap instead.
Miranda Callahan 2011/11/11 15:26:24 s/height the/height of the/
alicet1 2011/11/12 00:03:51 Done.
999 const int kYOffset = -(kVerticalEdgeThickness + 2); 1002 const int kXOffset = ResourceBundle::GetSharedInstance().GetBitmapNamed(
1000 gfx::Point origin(location_entry_view_->bounds().x() + kXOffset, 1003 IDR_OMNIBOX_HTTP)->width() / 2;
1001 y() + height() + kYOffset); 1004 const int icon_height = ResourceBundle::GetSharedInstance().GetBitmapNamed(
1005 IDR_OMNIBOX_HTTP)->height();
1006 const int kYOffset = (location_icon_view_->height() + icon_height) / 2;
1007 gfx::Point origin(location_icon_view_->bounds().x() + kXOffset,
1008 location_icon_view_->bounds().y() + kYOffset);
1002 // If the UI layout is RTL, the coordinate system is not transformed and 1009 // If the UI layout is RTL, the coordinate system is not transformed and
1003 // therefore we need to adjust the X coordinate so that bubble appears on the 1010 // therefore we need to adjust the X coordinate so that bubble appears on the
1004 // right hand side of the location bar. 1011 // right hand side of the location bar.
1005 if (base::i18n::IsRTL()) 1012 if (base::i18n::IsRTL())
1006 origin.set_x(width() - origin.x()); 1013 origin.set_x(width() - origin.x());
1007 views::View::ConvertPointToScreen(this, &origin); 1014 views::View::ConvertPointToScreen(this, &origin);
1008 FirstRunBubble::Show(browser_->profile(), GetWidget(), 1015 FirstRunBubble::Show(browser_->profile(), GetWidget(),
Miranda Callahan 2011/11/11 15:26:24 if you're going to have the args each on one line
alicet1 2011/11/12 00:03:51 Done.
1009 gfx::Rect(origin, gfx::Size()), 1016 gfx::Rect(origin, gfx::Size()),
1010 views::BubbleBorder::TOP_LEFT, bubble_type); 1017 views::BubbleBorder::TOP_LEFT,
1018 bubble_type);
1011 #endif 1019 #endif
1012 } 1020 }
1013 1021
1014 std::string LocationBarView::GetClassName() const { 1022 std::string LocationBarView::GetClassName() const {
1015 return kViewClassName; 1023 return kViewClassName;
1016 } 1024 }
1017 1025
1018 bool LocationBarView::SkipDefaultKeyEventProcessing( 1026 bool LocationBarView::SkipDefaultKeyEventProcessing(
1019 const views::KeyEvent& event) { 1027 const views::KeyEvent& event) {
1020 #if defined(OS_WIN) 1028 #if defined(OS_WIN)
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 !suggested_text_view_->GetText().empty(); 1252 !suggested_text_view_->GetText().empty();
1245 } 1253 }
1246 1254
1247 #if !defined(USE_AURA) 1255 #if !defined(USE_AURA)
1248 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() { 1256 OmniboxViewWin* LocationBarView::GetOmniboxViewWin() {
1249 CHECK(!views::Widget::IsPureViews()); 1257 CHECK(!views::Widget::IsPureViews());
1250 return static_cast<OmniboxViewWin*>(location_entry_.get()); 1258 return static_cast<OmniboxViewWin*>(location_entry_.get());
1251 } 1259 }
1252 #endif 1260 #endif
1253 #endif 1261 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698