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/content_setting_bubble_contents.h" | 5 #include "chrome/browser/ui/views/content_setting_bubble_contents.h" |
6 | 6 |
7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
8 #include <gdk/gdk.h> | 8 #include <gdk/gdk.h> |
9 #endif | 9 #endif |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
42 // narrow bubbles with lots of line-wrapping. | 42 // narrow bubbles with lots of line-wrapping. |
43 const int kMinMultiLineContentsWidth = 250; | 43 const int kMinMultiLineContentsWidth = 250; |
44 | 44 |
45 class ContentSettingBubbleContents::Favicon : public views::ImageView { | 45 class ContentSettingBubbleContents::Favicon : public views::ImageView { |
46 public: | 46 public: |
47 Favicon(const SkBitmap& image, | 47 Favicon(const SkBitmap& image, |
48 ContentSettingBubbleContents* parent, | 48 ContentSettingBubbleContents* parent, |
49 views::Link* link); | 49 views::Link* link); |
50 virtual ~Favicon(); | 50 virtual ~Favicon(); |
51 | 51 |
52 // views::View overrides: | |
53 virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type, | |
54 const gfx::Point& p) OVERRIDE; | |
55 virtual bool OnMousePressed(const views::MouseEvent& event) OVERRIDE; | |
56 virtual void OnMouseReleased(const views::MouseEvent& event) OVERRIDE; | |
sadrul
2011/03/19 09:15:30
Why are these moved from private to public?
msw
2011/03/26 00:09:50
Done.
| |
57 | |
52 private: | 58 private: |
53 #if defined(OS_WIN) | 59 #if defined(OS_WIN) |
54 static HCURSOR g_hand_cursor; | 60 static HCURSOR g_hand_cursor; |
55 #endif | 61 #endif |
56 | 62 |
57 // views::View overrides: | |
58 virtual bool OnMousePressed(const views::MouseEvent& event); | |
59 virtual void OnMouseReleased(const views::MouseEvent& event, bool canceled); | |
60 virtual gfx::NativeCursor GetCursorForPoint(ui::EventType event_type, | |
61 const gfx::Point& p); | |
62 | |
63 ContentSettingBubbleContents* parent_; | 63 ContentSettingBubbleContents* parent_; |
64 views::Link* link_; | 64 views::Link* link_; |
65 }; | 65 }; |
66 | 66 |
67 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
68 HCURSOR ContentSettingBubbleContents::Favicon::g_hand_cursor = NULL; | 68 HCURSOR ContentSettingBubbleContents::Favicon::g_hand_cursor = NULL; |
69 #endif | 69 #endif |
70 | 70 |
71 ContentSettingBubbleContents::Favicon::Favicon( | 71 ContentSettingBubbleContents::Favicon::Favicon( |
72 const SkBitmap& image, | 72 const SkBitmap& image, |
73 ContentSettingBubbleContents* parent, | 73 ContentSettingBubbleContents* parent, |
74 views::Link* link) | 74 views::Link* link) |
75 : parent_(parent), | 75 : parent_(parent), |
76 link_(link) { | 76 link_(link) { |
77 SetImage(image); | 77 SetImage(image); |
78 } | 78 } |
79 | 79 |
80 ContentSettingBubbleContents::Favicon::~Favicon() { | 80 ContentSettingBubbleContents::Favicon::~Favicon() { |
81 } | 81 } |
82 | 82 |
83 bool ContentSettingBubbleContents::Favicon::OnMousePressed( | |
84 const views::MouseEvent& event) { | |
85 return event.IsLeftMouseButton() || event.IsMiddleMouseButton(); | |
86 } | |
87 | |
88 void ContentSettingBubbleContents::Favicon::OnMouseReleased( | |
89 const views::MouseEvent& event, | |
90 bool canceled) { | |
91 if (!canceled && | |
92 (event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && | |
93 HitTest(event.location())) | |
94 parent_->LinkActivated(link_, event.flags()); | |
95 } | |
96 | |
97 gfx::NativeCursor ContentSettingBubbleContents::Favicon::GetCursorForPoint( | 83 gfx::NativeCursor ContentSettingBubbleContents::Favicon::GetCursorForPoint( |
98 ui::EventType event_type, | 84 ui::EventType event_type, |
99 const gfx::Point& p) { | 85 const gfx::Point& p) { |
100 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
101 if (!g_hand_cursor) | 87 if (!g_hand_cursor) |
102 g_hand_cursor = LoadCursor(NULL, IDC_HAND); | 88 g_hand_cursor = LoadCursor(NULL, IDC_HAND); |
103 return g_hand_cursor; | 89 return g_hand_cursor; |
104 #elif defined(OS_LINUX) | 90 #elif defined(OS_LINUX) |
105 return gfx::GetCursor(GDK_HAND2); | 91 return gfx::GetCursor(GDK_HAND2); |
106 #endif | 92 #endif |
107 } | 93 } |
108 | 94 |
95 bool ContentSettingBubbleContents::Favicon::OnMousePressed( | |
96 const views::MouseEvent& event) { | |
97 return event.IsLeftMouseButton() || event.IsMiddleMouseButton(); | |
98 } | |
99 | |
100 void ContentSettingBubbleContents::Favicon::OnMouseReleased( | |
101 const views::MouseEvent& event) { | |
102 if ((event.IsLeftMouseButton() || event.IsMiddleMouseButton()) && | |
103 HitTest(event.location())) | |
Ben Goodger (Google)
2011/03/19 15:32:55
braces around this block
msw
2011/03/26 00:09:50
Done.
| |
104 parent_->LinkActivated(link_, event.flags()); | |
105 } | |
106 | |
109 ContentSettingBubbleContents::ContentSettingBubbleContents( | 107 ContentSettingBubbleContents::ContentSettingBubbleContents( |
110 ContentSettingBubbleModel* content_setting_bubble_model, | 108 ContentSettingBubbleModel* content_setting_bubble_model, |
111 Profile* profile, | 109 Profile* profile, |
112 TabContents* tab_contents) | 110 TabContents* tab_contents) |
113 : content_setting_bubble_model_(content_setting_bubble_model), | 111 : content_setting_bubble_model_(content_setting_bubble_model), |
114 profile_(profile), | 112 profile_(profile), |
115 tab_contents_(tab_contents), | 113 tab_contents_(tab_contents), |
116 info_bubble_(NULL), | 114 info_bubble_(NULL), |
117 custom_link_(NULL), | 115 custom_link_(NULL), |
118 manage_link_(NULL), | 116 manage_link_(NULL), |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 layout->StartRow(0, double_column_set_id); | 333 layout->StartRow(0, double_column_set_id); |
336 manage_link_ = new views::Link(UTF8ToWide(bubble_content.manage_link)); | 334 manage_link_ = new views::Link(UTF8ToWide(bubble_content.manage_link)); |
337 manage_link_->SetController(this); | 335 manage_link_->SetController(this); |
338 layout->AddView(manage_link_); | 336 layout->AddView(manage_link_); |
339 | 337 |
340 close_button_ = | 338 close_button_ = |
341 new views::NativeButton(this, | 339 new views::NativeButton(this, |
342 UTF16ToWide(l10n_util::GetStringUTF16(IDS_DONE))); | 340 UTF16ToWide(l10n_util::GetStringUTF16(IDS_DONE))); |
343 layout->AddView(close_button_); | 341 layout->AddView(close_button_); |
344 } | 342 } |
OLD | NEW |