OLD | NEW |
| (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_H_ | |
6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_H_ | |
7 | |
8 #include <stddef.h> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "base/string16.h" | |
13 #include "chrome/browser/extensions/extension_install_prompt.h" | |
14 #include "ui/gfx/size.h" | |
15 | |
16 class WebIntentPickerDelegate; | |
17 class WebIntentPickerModel; | |
18 | |
19 namespace content { | |
20 struct NativeWebKeyboardEvent; | |
21 class WebContents; | |
22 } | |
23 | |
24 // Base class for the web intent picker dialog. | |
25 class WebIntentPicker { | |
26 public: | |
27 // The minimum width of the window. | |
28 static const int kWindowMinWidth = 400; | |
29 | |
30 // The maximum width the window. | |
31 static const int kWindowMaxWidth = 900; | |
32 | |
33 // The minimum height of the window. | |
34 static const int kWindowMinHeight = 145; | |
35 | |
36 // The maximum width in view units of a suggested extension's title link. | |
37 static const int kTitleLinkMaxWidth = 130; | |
38 | |
39 // The space in pixels between the top-level groups and the dialog border. | |
40 static const int kContentAreaBorder = 20; | |
41 | |
42 // Vertical space above the separator. | |
43 static const int kHeaderSeparatorPaddingTop = 16; | |
44 | |
45 // Vertical space below the separator. | |
46 static const int kHeaderSeparatorPaddingBottom = 7; | |
47 | |
48 // Width of the service icon. | |
49 static const int kServiceIconWidth = 16; | |
50 | |
51 // Height of the service icon. | |
52 static const int kServiceIconHeight = 16; | |
53 | |
54 // Space between icon and text. | |
55 static const int kIconTextPadding = 10; | |
56 | |
57 // Space between star rating and select button. | |
58 static const int kStarButtonPadding = 20; | |
59 | |
60 // The height of the suggested and installed service row. | |
61 static const int kServiceRowHeight = 32; | |
62 | |
63 // The maximum number of installed services + suggested servcies to show. Note | |
64 // that all installed services are always shown so the actual number of | |
65 // services shown maybe greater than this. | |
66 static const int kMaxServicesToShow = 4; | |
67 | |
68 // Platform specific factory function. This function will automatically show | |
69 // the picker. | |
70 static WebIntentPicker* Create(content::WebContents* web_contents, | |
71 WebIntentPickerDelegate* delegate, | |
72 WebIntentPickerModel* model); | |
73 | |
74 // Hides the UI for this picker, and destroys its UI. | |
75 virtual void Close() = 0; | |
76 | |
77 // Sets the action string of the picker, e.g., | |
78 // "Which service should be used for sharing?". | |
79 virtual void SetActionString(const string16& action) = 0; | |
80 | |
81 // Called when an extension is successfully installed via the picker. | |
82 virtual void OnExtensionInstallSuccess(const std::string& id) = 0; | |
83 | |
84 // Called when an extension installation started via the picker has failed. | |
85 virtual void OnExtensionInstallFailure(const std::string& id) = 0; | |
86 | |
87 // Shows the default extension install dialog. Override this to show a custom | |
88 // dialog. We *MUST* eventually call either Proceed() or Abort() on | |
89 // |delegate|. | |
90 virtual void OnShowExtensionInstallDialog( | |
91 const ExtensionInstallPrompt::ShowParams& show_params, | |
92 ExtensionInstallPrompt::Delegate* delegate, | |
93 const ExtensionInstallPrompt::Prompt& prompt); | |
94 | |
95 // Called when the inline disposition experiences an auto-resize. | |
96 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) = 0; | |
97 | |
98 virtual void OnInlineDispositionHandleKeyboardEvent( | |
99 const content::NativeWebKeyboardEvent& event) {} | |
100 | |
101 // Called when the controller has finished all pending asynchronous | |
102 // activities. | |
103 virtual void OnPendingAsyncCompleted() = 0; | |
104 | |
105 // Called once the delegate gets destroyed/invalid. This should only be | |
106 // called during a shut down sequence that will tear down the picker, too. | |
107 virtual void InvalidateDelegate() = 0; | |
108 | |
109 // Called when the inline disposition's web contents have been loaded. | |
110 virtual void OnInlineDispositionWebContentsLoaded( | |
111 content::WebContents* web_contents) {} | |
112 | |
113 // Get the minimum size of the inline disposition content container. | |
114 virtual gfx::Size GetMinInlineDispositionSize(); | |
115 | |
116 // Get the maximum size of the inline disposition content container. | |
117 virtual gfx::Size GetMaxInlineDispositionSize(); | |
118 | |
119 // Get the star image IDs to use for the nth star (out of 5), given a | |
120 // |rating| in the range [0, 5]. | |
121 static int GetNthStarImageIdFromCWSRating(double rating, int index); | |
122 | |
123 // Returns the action-specific string to display for |action|. | |
124 static string16 GetDisplayStringForIntentAction(const string16& action16); | |
125 | |
126 protected: | |
127 virtual ~WebIntentPicker() {} | |
128 }; | |
129 | |
130 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_PICKER_H_ | |
OLD | NEW |