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

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: Add Textfield::[set_]select_all_on_focus, use GetInitiallyFocusedView. 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 methods.
46 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
47 virtual void WindowClosing() OVERRIDE;
53 48
54 // Override to close on return. 49 // views::View method.
55 virtual bool AcceleratorPressed( 50 virtual bool AcceleratorPressed(
56 const views::Accelerator& accelerator) OVERRIDE; 51 const views::Accelerator& accelerator) OVERRIDE;
57 52
58 virtual void ViewHierarchyChanged( 53 protected:
59 bool is_add, View* parent, View* child) OVERRIDE; 54 // views::BubbleDelegateView method.
55 virtual void Init() OVERRIDE;
60 56
61 private: 57 private:
62 // Creates a BookmarkBubbleView. 58 // Creates a BookmarkBubbleView.
63 // |title| is the title of the page. If newly_bookmarked is false, title is 59 BookmarkBubbleView(views::Widget* parent,
64 // ignored and the title of the bookmark is fetched from the database. 60 const gfx::Point& anchor,
65 BookmarkBubbleView(BubbleDelegate* delegate,
66 Profile* profile, 61 Profile* profile,
67 const GURL& url, 62 const GURL& url,
68 bool newly_bookmarked); 63 bool newly_bookmarked);
69 // Creates the child views.
70 void Init();
71 64
72 // Returns the title to display. 65 // Returns the title to display.
73 string16 GetTitle(); 66 string16 GetTitle();
74 67
75 // views::LinkListener method, either unstars the item or shows the bookmark 68 // views::LinkListener method, either unstars the item or shows the bookmark
76 // editor (depending upon which link was clicked). 69 // editor (depending upon which link was clicked).
77 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; 70 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
78 71
79 // ButtonListener method, closes the bubble or opens the edit dialog. 72 // ButtonListener method, closes the bubble or opens the edit dialog.
80 virtual void ButtonPressed(views::Button* sender, 73 virtual void ButtonPressed(views::Button* sender,
81 const views::Event& event) OVERRIDE; 74 const views::Event& event) OVERRIDE;
82 75
83 // Combobox::Listener method. Changes the parent of the bookmark. 76 // Combobox::Listener method. Changes the parent of the bookmark.
84 virtual void ItemChanged(views::Combobox* combobox, 77 virtual void ItemChanged(views::Combobox* combobox,
85 int prev_index, 78 int prev_index,
86 int new_index) OVERRIDE; 79 int new_index) OVERRIDE;
87 80
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. 81 // Handle the message when the user presses a button.
100 void HandleButtonPressed(views::Button* sender); 82 void HandleButtonPressed(views::Button* sender);
101 83
102 // Shows the BookmarkEditor. 84 // Shows the BookmarkEditor.
103 void ShowEditor(); 85 void ShowEditor();
104 86
105 // Sets the title and parent of the node. 87 // Sets the title and parent of the node.
106 void ApplyEdits(); 88 void ApplyEdits();
107 89
108 // The bookmark bubble, if we're showing one. 90 // The bookmark bubble, if we're showing one.
109 static BookmarkBubbleView* bookmark_bubble_; 91 static BookmarkBubbleView* bookmark_bubble_;
110 92
111 // The Bubble showing us. 93 // The parent widget of this bubble's widget, used for ShowEditor.
112 Bubble* bubble_; 94 views::Widget* parent_;
113
114 // Delegate for the bubble, may be null.
115 BubbleDelegate* delegate_;
116 95
117 // The profile. 96 // The profile.
118 Profile* profile_; 97 Profile* profile_;
119 98
120 // The bookmark URL. 99 // The bookmark URL.
121 const GURL url_; 100 const GURL url_;
122 101
123 // Title of the bookmark. This is initially the title supplied to the 102 // Title of the bookmark. This is initially the title supplied to the
124 // constructor, which is typically the title of the page. 103 // constructor, which is typically the title of the page.
125 std::wstring title_; 104 std::wstring title_;
(...skipping 22 matching lines...) Expand all
148 // When the destructor is invoked should the bookmark be removed? 127 // When the destructor is invoked should the bookmark be removed?
149 bool remove_bookmark_; 128 bool remove_bookmark_;
150 129
151 // When the destructor is invoked should edits be applied? 130 // When the destructor is invoked should edits be applied?
152 bool apply_edits_; 131 bool apply_edits_;
153 132
154 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView); 133 DISALLOW_COPY_AND_ASSIGN(BookmarkBubbleView);
155 }; 134 };
156 135
157 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_ 136 #endif // CHROME_BROWSER_UI_VIEWS_BOOKMARKS_BOOKMARK_BUBBLE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698