OLD | NEW |
1 // Copyright (c) 2012 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_COCOA_WEB_INTENT_PICKER_COCOA_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_WEB_INTENT_PICKER_COCOA_H_ |
6 #define CHROME_BROWSER_UI_COCOA_WEB_INTENT_PICKER_COCOA_H_ | 6 #define CHROME_BROWSER_UI_COCOA_WEB_INTENT_PICKER_COCOA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "chrome/browser/ui/intents/web_intent_picker.h" | 13 #include "chrome/browser/ui/intents/web_intent_picker.h" |
14 #include "chrome/browser/ui/intents/web_intent_picker_model.h" | 14 #include "chrome/browser/ui/intents/web_intent_picker_model.h" |
15 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" | 15 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" |
16 | 16 |
| 17 class ConstrainedWindow; |
17 class TabContentsWrapper; | 18 class TabContentsWrapper; |
18 @class WebIntentBubbleController; | 19 @class WebIntentPickerSheetController; |
19 class WebIntentInlineDispositionDelegate; | 20 class WebIntentInlineDispositionDelegate; |
20 | 21 |
21 // A bridge class that enables communication between ObjectiveC and C++. | 22 // A bridge class that enables communication between ObjectiveC and C++. |
22 class WebIntentPickerCocoa : public WebIntentPicker, | 23 class WebIntentPickerCocoa : public WebIntentPicker, |
23 public WebIntentPickerModelObserver { | 24 public WebIntentPickerModelObserver { |
24 public: | 25 public: |
25 // |browser| and |delegate| cannot be NULL. | 26 // |wrapper|, and |delegate| must not be NULL. |
26 // |wrapper| is unused. | 27 // |browser| should only be NULL for testing purposes. |
27 WebIntentPickerCocoa(Browser* browser, | 28 WebIntentPickerCocoa(Browser* browser, |
28 TabContentsWrapper* wrapper, | 29 TabContentsWrapper* wrapper, |
29 WebIntentPickerDelegate* delegate, | 30 WebIntentPickerDelegate* delegate, |
30 WebIntentPickerModel* model); | 31 WebIntentPickerModel* model); |
31 virtual ~WebIntentPickerCocoa(); | 32 virtual ~WebIntentPickerCocoa(); |
32 | 33 |
| 34 void OnSheetDidEnd(NSWindow* sheet); |
| 35 |
33 // WebIntentPickerDelegate forwarding API. | 36 // WebIntentPickerDelegate forwarding API. |
34 void OnCancelled(); | 37 void OnCancelled(); |
35 void OnServiceChosen(size_t index); | 38 void OnServiceChosen(size_t index); |
36 | 39 |
37 void set_controller(WebIntentBubbleController* controller); | |
38 | |
39 // WebIntentPicker: | 40 // WebIntentPicker: |
40 virtual void Close() OVERRIDE; | 41 virtual void Close() OVERRIDE; |
41 | 42 |
42 // WebIntentPickerModelObserver implementation. | 43 // WebIntentPickerModelObserver implementation. |
43 virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE; | 44 virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE; |
44 virtual void OnFaviconChanged(WebIntentPickerModel* model, | 45 virtual void OnFaviconChanged(WebIntentPickerModel* model, |
45 size_t index) OVERRIDE; | 46 size_t index) OVERRIDE; |
46 virtual void OnExtensionIconChanged(WebIntentPickerModel* model, | 47 virtual void OnExtensionIconChanged(WebIntentPickerModel* model, |
47 const string16& extension_id) OVERRIDE; | 48 const string16& extension_id) OVERRIDE; |
48 virtual void OnInlineDisposition(WebIntentPickerModel* model) OVERRIDE; | 49 virtual void OnInlineDisposition(WebIntentPickerModel* model) OVERRIDE; |
49 | 50 |
50 private: | 51 private: |
| 52 ConstrainedWindow* window_; // Window for constrained sheet. Weak reference. |
| 53 |
51 // Weak pointer to the |delegate_| to notify about user choice/cancellation. | 54 // Weak pointer to the |delegate_| to notify about user choice/cancellation. |
52 WebIntentPickerDelegate* delegate_; | 55 WebIntentPickerDelegate* delegate_; |
53 | 56 |
54 // The picker model. Weak reference. | 57 // The picker model. Weak reference. |
55 WebIntentPickerModel* model_; | 58 WebIntentPickerModel* model_; |
56 | 59 |
57 Browser* browser_; // The browser we're in. Weak Reference. | 60 Browser* browser_; // The browser we're in. Weak Reference. |
58 | 61 |
59 WebIntentBubbleController* controller_; // Weak reference. | 62 WebIntentPickerSheetController* sheet_controller_; // Weak reference. |
60 | |
61 // Factory for weak ptrs, used for delayed callbacks. | |
62 base::WeakPtrFactory<WebIntentPickerCocoa> weak_ptr_factory_; | |
63 | 63 |
64 // Tab contents wrapper to hold intent page if inline disposition is used. | 64 // Tab contents wrapper to hold intent page if inline disposition is used. |
65 scoped_ptr<TabContentsWrapper> inline_disposition_tab_contents_; | 65 scoped_ptr<TabContentsWrapper> inline_disposition_tab_contents_; |
66 | 66 |
67 // Delegate for inline disposition tab contents. | 67 // Delegate for inline disposition tab contents. |
68 scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_; | 68 scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_; |
69 | 69 |
70 // Indicate that we invoked a service, instead of just closing/cancelling. | 70 // Indicate that we invoked a service, instead of just closing/cancelling. |
71 bool service_invoked; | 71 bool service_invoked; |
72 | 72 |
73 // Post a delayed task to do layout, if it isn't already pending. | |
74 void PerformDelayedLayout(); | |
75 | |
76 // Re-layout the intent picker. | 73 // Re-layout the intent picker. |
77 void PerformLayout(); | 74 void PerformLayout(); |
78 | 75 |
79 // Default constructor, for testing only. | 76 // Default constructor, for testing only. |
80 WebIntentPickerCocoa(); | 77 WebIntentPickerCocoa(); |
81 | 78 |
82 // For testing access. | 79 // For testing access. |
83 friend class WebIntentBubbleControllerTest; | 80 friend class WebIntentPickerSheetControllerTest; |
84 | 81 |
85 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerCocoa); | 82 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerCocoa); |
86 }; | 83 }; |
87 | 84 |
88 #endif // CHROME_BROWSER_UI_COCOA_WEB_INTENT_PICKER_COCOA_H_ | 85 #endif // CHROME_BROWSER_UI_COCOA_WEB_INTENT_PICKER_COCOA_H_ |
OLD | NEW |