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

Side by Side Diff: chrome/browser/ui/intents/web_intent_picker_model.h

Issue 9148032: [Web Intents] Refactor picker to use WebIntentPickerModel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: groby's fix Created 8 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_
6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_
7 #pragma once
8
9 #include <vector>
10
11 #include "base/string16.h"
12 #include "googleurl/src/gurl.h"
13 #include "ui/gfx/image/image.h"
14
15 class WebIntentPickerModelObserver;
16
17 namespace gfx {
18 class Image;
19 }
20
21 // Model for the WebIntentPicker.
22 class WebIntentPickerModel {
23 public:
24 // The intent service disposition.
25 enum Disposition {
26 DISPOSITION_WINDOW, // Display the intent service in a new window.
27 DISPOSITION_INLINE, // Display the intent service in the picker.
28 };
29
30 // An intent service to display in the picker.
31 struct Item {
32 Item(const string16& title, const GURL& url, Disposition disposition);
33 ~Item();
34
35 // The title of this service.
36 string16 title;
37
38 // The URL of this service.
39 GURL url;
40
41 // A favicon of this service.
42 gfx::Image favicon;
43
44 // The disposition to use when displaying this service.
45 Disposition disposition;
46
47 private:
48 DISALLOW_COPY_AND_ASSIGN(Item);
49 };
50
51 WebIntentPickerModel();
52 ~WebIntentPickerModel();
53
54 void set_observer(WebIntentPickerModelObserver* observer) {
55 observer_ = observer;
56 }
57
58 // Add a new item with |title|, |url| and |disposition| to the picker.
59 void AddItem(const string16& title, const GURL& url, Disposition disposition);
60
61 // Remove an item from the picker at |index|.
62 void RemoveItemAt(size_t index);
63
64 // Remove all items from the picker, and resets to not displaying inline
65 // disposition. Note that this does not clear the observer.
66 void Clear();
67
68 // Return the intent service item at |index|.
69 const Item& GetItemAt(size_t index) const;
70
71 // Return the number of intent services in the picker.
72 size_t GetItemCount() const;
73
74 // Update the favicon for the intent service at |index| to |image|.
75 void UpdateFaviconAt(size_t index, const gfx::Image& image);
76
77 // Set the picker to display the intent service at |index| inline.
78 void SetInlineDisposition(size_t index);
79
80 // Returns true if the picker is currently displaying an inline service.
81 bool IsInlineDisposition() const;
82
83 // Returns the index of the intent service that is being displayed inline, or
84 // std::string::npos if none.
85 size_t inline_disposition_index() const { return inline_disposition_index_; }
86
87 private:
88 // Delete all of |items_| and clear it.
89 void DestroyItems();
90
91 // A vector of all items in the picker. Each item is owned by this model.
92 std::vector<Item*> items_;
93
94 // The observer to send notifications to, or NULL if none.
95 WebIntentPickerModelObserver* observer_;
96
97 // The index of the intent service that is being displayed inline, or
98 // std::string::npos if none.
99 size_t inline_disposition_index_;
100
101 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerModel);
102 };
103
104 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_MODEL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/intents/web_intent_picker_factory_impl.cc ('k') | chrome/browser/ui/intents/web_intent_picker_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698