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

Side by Side Diff: chrome/browser/ui/views/bookmarks/bookmark_bubble_view.h

Issue 8368016: Rebase BookmarkBubble on the new views bubble. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix widget sizing issue. 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 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/bookmarks/recently_used_folders_combo_model.h" 10 #include "chrome/browser/bookmarks/recently_used_folders_combo_model.h"
11 #include "chrome/browser/ui/views/bubble/bubble.h"
12 #include "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
13 #include "ui/gfx/rect.h" 12 #include "views/bubble/bubble_delegate.h"
14 #include "views/controls/button/button.h" 13 #include "views/controls/button/button.h"
15 #include "views/controls/combobox/combobox.h" 14 #include "views/controls/combobox/combobox.h"
16 #include "views/controls/link_listener.h" 15 #include "views/controls/link_listener.h"
17 #include "views/view.h"
18 16
19 class Profile; 17 class Profile;
20 18
21 class BookmarkModel;
22 class BookmarkNode;
23
24 namespace views { 19 namespace views {
25 class TextButton; 20 class TextButton;
26 class Textfield; 21 class Textfield;
27 } 22 }
28 23
29 // BookmarkBubbleView is a view intended to be used as the content of an 24 // BookmarkBubbleView is a view intended to be used as the content of an
30 // Bubble. BookmarkBubbleView provides views for unstarring and editing the 25 // Bubble. BookmarkBubbleView provides views for unstarring and editing the
31 // bookmark it is created with. Don't create a BookmarkBubbleView directly, 26 // bookmark it is created with. Don't create a BookmarkBubbleView directly,
32 // instead use the static Show method. 27 // instead use the static Show method.
33 class BookmarkBubbleView : public views::View, 28 class BookmarkBubbleView : public views::BubbleDelegateView,
34 public views::LinkListener, 29 public views::LinkListener,
35 public views::ButtonListener, 30 public views::ButtonListener,
36 public views::Combobox::Listener, 31 public views::Combobox::Listener {
37 public BubbleDelegate {
38 public: 32 public:
39 static void Show(views::Widget* widget, 33 static void ShowBubble(views::Widget* parent,
40 const gfx::Rect& bounds, 34 const gfx::Point& anchor,
41 BubbleDelegate* delegate, 35 Profile* profile,
42 Profile* profile, 36 const GURL& url,
43 const GURL& url, 37 bool newly_bookmarked);
44 bool newly_bookmarked);
45 38
46 static bool IsShowing(); 39 static bool IsShowing();
47 40
48 static void Hide(); 41 static void Hide();
49 42
50 virtual ~BookmarkBubbleView(); 43 virtual ~BookmarkBubbleView();
51 44
52 void set_bubble(Bubble* bubble) { bubble_ = bubble; } 45 // views::BubbleDelegateView method.
46 virtual void WindowClosing() OVERRIDE;
53 47
54 // Override to close on return. 48 // views::View method.
55 virtual bool AcceleratorPressed( 49 virtual bool AcceleratorPressed(
56 const views::Accelerator& accelerator) OVERRIDE; 50 const views::Accelerator& accelerator) OVERRIDE;
57 51
58 virtual void ViewHierarchyChanged( 52 protected:
59 bool is_add, View* parent, View* child) OVERRIDE; 53 // views::BubbleDelegateView method.
54 virtual void Init() OVERRIDE;
60 55
61 private: 56 private:
62 // Creates a BookmarkBubbleView. 57 // Creates a BookmarkBubbleView.
63 // |title| is the title of the page. If newly_bookmarked is false, title is 58 BookmarkBubbleView(views::Widget* parent,
64 // ignored and the title of the bookmark is fetched from the database. 59 const gfx::Point& anchor,
65 BookmarkBubbleView(BubbleDelegate* delegate,
66 Profile* profile, 60 Profile* profile,
67 const GURL& url, 61 const GURL& url,
68 bool newly_bookmarked); 62 bool newly_bookmarked);
69 // Creates the child views.
70 void Init();
71 63
72 // Returns the title to display. 64 // Returns the title to display.
73 string16 GetTitle(); 65 string16 GetTitle();
74 66
75 // views::LinkListener method, either unstars the item or shows the bookmark 67 // views::LinkListener method, either unstars the item or shows the bookmark
76 // editor (depending upon which link was clicked). 68 // editor (depending upon which link was clicked).
77 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 69 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
78 70
79 // ButtonListener method, closes the bubble or opens the edit dialog. 71 // ButtonListener method, closes the bubble or opens the edit dialog.
80 virtual void ButtonPressed(views::Button* sender, 72 virtual void ButtonPressed(views::Button* sender,
81 const views::Event& event) OVERRIDE; 73 const views::Event& event) OVERRIDE;
82 74
83 // Combobox::Listener method. Changes the parent of the bookmark. 75 // Combobox::Listener method. Changes the parent of the bookmark.
84 virtual void ItemChanged(views::Combobox* combobox, 76 virtual void ItemChanged(views::Combobox* combobox,
85 int prev_index, 77 int prev_index,
86 int new_index) OVERRIDE; 78 int new_index) OVERRIDE;
87 79
88 // BubbleDelegate methods. These forward to the BubbleDelegate supplied in the
89 // constructor as well as sending out the necessary notification.
90 virtual void BubbleShown() OVERRIDE;
91 virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE;
92 virtual bool CloseOnEscape() OVERRIDE;
93 virtual bool FadeInOnShow() OVERRIDE;
94 virtual string16 GetAccessibleName() OVERRIDE;
95
96 // Closes the bubble.
97 void Close();
98
99 // Handle the message when the user presses a button. 80 // Handle the message when the user presses a button.
100 void HandleButtonPressed(views::Button* sender); 81 void HandleButtonPressed(views::Button* sender);
101 82
102 // Shows the BookmarkEditor. 83 // Shows the BookmarkEditor.
103 void ShowEditor(); 84 void ShowEditor();
104 85
105 // Sets the title and parent of the node. 86 // Sets the title and parent of the node.
106 void ApplyEdits(); 87 void ApplyEdits();
107 88
108 // The bookmark bubble, if we're showing one. 89 // The bookmark bubble, if we're showing one.
109 static BookmarkBubbleView* bookmark_bubble_; 90 static BookmarkBubbleView* bookmark_bubble_;
110 91
111 // The Bubble showing us. 92 // The parent widget of this bubble's widget, used for ShowEditor.
112 Bubble* bubble_; 93 views::Widget* parent_;
113
114 // Delegate for the bubble, may be null.
115 BubbleDelegate* delegate_;
116 94
117 // The profile. 95 // The profile.
118 Profile* profile_; 96 Profile* profile_;
119 97
120 // The bookmark URL. 98 // The bookmark URL.
121 const GURL url_; 99 const GURL url_;
122 100
123 // Title of the bookmark. This is initially the title supplied to the 101 // Title of the bookmark. This is initially the title supplied to the
124 // constructor, which is typically the title of the page. 102 // constructor, which is typically the title of the page.
125 std::wstring title_; 103 std::wstring title_;
(...skipping 22 matching lines...) Expand all
148 // When the destructor is invoked should the bookmark be removed? 126 // When the destructor is invoked should the bookmark be removed?
149 bool remove_bookmark_; 127 bool remove_bookmark_;
150 128
151 // When the destructor is invoked should edits be applied? 129 // When the destructor is invoked should edits be applied?
152 bool apply_edits_; 130 bool apply_edits_;
153 131
154 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView); 132 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView);
155 }; 133 };
156 134
157 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ 135 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698