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

Side by Side Diff: chrome/browser/ui/gtk/web_intent_picker_gtk.h

Issue 9148032: [Web Intents] Refactor picker to use WebIntentPickerModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix copyright year in w_i_b_c_unittest.mm Created 8 years, 11 months 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) 2012 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_GTK_WEB_INTENT_PICKER_GTK_H_ 5 #ifndef CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_
6 #define CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_ 6 #define CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_
7 #pragma once 7 #pragma once
8 8
9 #include <gtk/gtk.h> 9 #include <gtk/gtk.h>
10 10
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 16 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
17 #include "chrome/browser/ui/intents/web_intent_picker.h" 17 #include "chrome/browser/ui/intents/web_intent_picker.h"
18 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
18 #include "content/public/browser/web_contents_delegate.h" 19 #include "content/public/browser/web_contents_delegate.h"
19 #include "ui/base/gtk/gtk_signal.h" 20 #include "ui/base/gtk/gtk_signal.h"
20 #include "ui/base/gtk/owned_widget_gtk.h" 21 #include "ui/base/gtk/owned_widget_gtk.h"
21 22
22 class Browser; 23 class Browser;
23 class CustomDrawButton; 24 class CustomDrawButton;
24 class GURL; 25 class GURL;
25 class TabContents; 26 class TabContents;
26 class TabContentsContainerGtk; 27 class TabContentsContainerGtk;
27 class TabContentsWrapper; 28 class TabContentsWrapper;
28 class WebIntentPickerDelegate; 29 class WebIntentPickerDelegate;
29 30
30 // Gtk implementation of WebIntentPicker. 31 // Gtk implementation of WebIntentPicker.
31 class WebIntentPickerGtk : public WebIntentPicker, 32 class WebIntentPickerGtk : public WebIntentPicker,
33 public WebIntentPickerModelObserver,
32 public BubbleDelegateGtk { 34 public BubbleDelegateGtk {
33 public: 35 public:
34 WebIntentPickerGtk(Browser* browser, 36 WebIntentPickerGtk(Browser* browser,
35 TabContentsWrapper* tab_contents, 37 TabContentsWrapper* tab_contents,
36 WebIntentPickerDelegate* delegate); 38 WebIntentPickerDelegate* delegate,
39 WebIntentPickerModel* model);
37 virtual ~WebIntentPickerGtk(); 40 virtual ~WebIntentPickerGtk();
38 41
39 // WebIntentPicker implementation. 42 // WebIntentPicker implementation.
40 virtual void SetServiceURLs(const std::vector<GURL>& urls) OVERRIDE;
41 virtual void SetServiceIcon(size_t index, const SkBitmap& icon) OVERRIDE;
42 virtual void SetDefaultServiceIcon(size_t index) OVERRIDE;
43 virtual void Close() OVERRIDE; 43 virtual void Close() OVERRIDE;
44 virtual content::WebContents* SetInlineDisposition(const GURL& url) OVERRIDE; 44
45 // WebIntentPickerModelObserver implementation.
46 virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE;
47 virtual void OnFaviconChanged(WebIntentPickerModel* model,
48 size_t index) OVERRIDE;
49 virtual void OnInlineDisposition(WebIntentPickerModel* model) OVERRIDE;
45 50
46 // BubbleDelegateGtk implementation. 51 // BubbleDelegateGtk implementation.
47 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; 52 virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
48 53
49 private: 54 private:
55 // Callback when picker is destroyed.
56 CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnDestroy);
50 // Callback when a service button is clicked. 57 // Callback when a service button is clicked.
51 CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnServiceButtonClick); 58 CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnServiceButtonClick);
52 // Callback when close button is clicked. 59 // Callback when close button is clicked.
53 CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnCloseButtonClick); 60 CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnCloseButtonClick);
54 61
55 // This class is the policy delegate for the rendered page in the intents 62 // This class is the policy delegate for the rendered page in the intents
56 // inline disposition bubble. 63 // inline disposition bubble.
57 // TODO(gbillock): Move up to WebIntentPicker? 64 // TODO(gbillock): Move up to WebIntentPicker?
58 class InlineDispositionDelegate : public content::WebContentsDelegate { 65 class InlineDispositionDelegate : public content::WebContentsDelegate {
59 public: 66 public:
60 InlineDispositionDelegate(); 67 InlineDispositionDelegate();
61 virtual ~InlineDispositionDelegate(); 68 virtual ~InlineDispositionDelegate();
62 virtual bool IsPopupOrPanel( 69 virtual bool IsPopupOrPanel(
63 const content::WebContents* source) const OVERRIDE; 70 const content::WebContents* source) const OVERRIDE;
64 virtual bool ShouldAddNavigationToHistory( 71 virtual bool ShouldAddNavigationToHistory(
65 const history::HistoryAddPageArgs& add_page_args, 72 const history::HistoryAddPageArgs& add_page_args,
66 content::NavigationType navigation_type) OVERRIDE; 73 content::NavigationType navigation_type) OVERRIDE;
67 }; 74 };
68 75
69 // Initialize the contents of the bubble. After this call, contents_ will be 76 // Initialize the contents of the bubble. After this call, contents_ will be
70 // non-NULL. 77 // non-NULL.
71 void InitContents(); 78 void InitContents();
72 79
80 // Remove and destroy all children from |container|.
81 void RemoveAllFrom(GtkWidget* container);
82
73 // Get the button widget at |index|. 83 // Get the button widget at |index|.
74 GtkWidget* GetServiceButton(size_t index); 84 GtkWidget* GetServiceButton(size_t index);
75 85
76 // A weak pointer to the tab contents on which to display the picker UI. 86 // A weak pointer to the tab contents on which to display the picker UI.
77 TabContentsWrapper* wrapper_; 87 TabContentsWrapper* wrapper_;
78 88
79 // A weak pointer to the WebIntentPickerDelegate to notify when the user 89 // A weak pointer to the WebIntentPickerDelegate to notify when the user
80 // chooses a service or cancels. 90 // chooses a service or cancels.
81 WebIntentPickerDelegate* delegate_; 91 WebIntentPickerDelegate* delegate_;
82 92
93 // A weak pointer to the picker model.
94 WebIntentPickerModel* model_;
95
83 // A weak pointer to the widget that contains all other widgets in 96 // A weak pointer to the widget that contains all other widgets in
84 // the bubble. 97 // the bubble.
85 GtkWidget* contents_; 98 GtkWidget* contents_;
86 99
87 // A weak pointer to the hbox that contains the buttons used to choose the 100 // A weak pointer to the vbox that contains the buttons used to choose the
88 // service. 101 // service.
89 GtkWidget* button_hbox_; 102 GtkWidget* button_vbox_;
90 103
91 // A button to close the bubble. 104 // A button to close the bubble.
92 scoped_ptr<CustomDrawButton> close_button_; 105 scoped_ptr<CustomDrawButton> close_button_;
93 106
94 // A weak pointer to the bubble widget. 107 // A weak pointer to the bubble widget.
95 BubbleGtk* bubble_; 108 BubbleGtk* bubble_;
96 109
97 // The browser we're in. 110 // The browser we're in.
98 Browser* browser_; 111 Browser* browser_;
99 112
100 // Container for the HTML in the inline disposition case. 113 // Container for the HTML in the inline disposition case.
101 scoped_ptr<TabContentsWrapper> inline_disposition_tab_contents_; 114 scoped_ptr<TabContentsWrapper> inline_disposition_tab_contents_;
102 115
103 // Widget for displaying the HTML in the inline disposition case. 116 // Widget for displaying the HTML in the inline disposition case.
104 scoped_ptr<TabContentsContainerGtk> tab_contents_container_; 117 scoped_ptr<TabContentsContainerGtk> tab_contents_container_;
105 118
106 // content::WebContentsDelegate for the inline disposition dialog. 119 // content::WebContentsDelegate for the inline disposition dialog.
107 scoped_ptr<InlineDispositionDelegate> inline_disposition_delegate_; 120 scoped_ptr<InlineDispositionDelegate> inline_disposition_delegate_;
108 121
109 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerGtk); 122 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerGtk);
110 }; 123 };
111 124
112 #endif // CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_ 125 #endif // CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698