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_COCOA_WEB_INTENT_PICKER_COCOA_H_ | |
6 #define CHROME_BROWSER_UI_COCOA_WEB_INTENT_PICKER_COCOA_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/compiler_specific.h" | |
10 #include "base/memory/scoped_ptr.h" | |
11 #include "base/string16.h" | |
12 #include "base/memory/weak_ptr.h" | |
13 #include "chrome/browser/ui/intents/web_intent_picker.h" | |
14 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" | |
15 #include "chrome/browser/ui/intents/web_intent_picker_model.h" | |
16 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" | |
17 | |
18 class ConstrainedWindow; | |
19 class WebIntentInlineDispositionDelegate; | |
20 @class WebIntentPickerSheetController; | |
21 | |
22 namespace content { | |
23 class WebContents; | |
24 } | |
25 | |
26 // A bridge class that enables communication between ObjectiveC and C++. | |
27 class WebIntentPickerCocoa : public WebIntentPicker, | |
28 public WebIntentPickerModelObserver { | |
29 public: | |
30 // |web_contents| and |delegate| must not be NULL. | |
31 WebIntentPickerCocoa(content::WebContents* web_contents, | |
32 WebIntentPickerDelegate* delegate, | |
33 WebIntentPickerModel* model); | |
34 virtual ~WebIntentPickerCocoa(); | |
35 | |
36 void OnSheetDidEnd(NSWindow* sheet); | |
37 | |
38 WebIntentPickerModel* model() { return model_; } | |
39 | |
40 // WebIntentPickerDelegate forwarding API. | |
41 void OnCancelled(); | |
42 void OnServiceChosen(size_t index); | |
43 void OnExtensionInstallRequested(const std::string& extension_id); | |
44 void OnExtensionLinkClicked( | |
45 const std::string& extension_id, | |
46 WindowOpenDisposition disposition); | |
47 void OnSuggestionsLinkClicked(WindowOpenDisposition disposition); | |
48 void OnChooseAnotherService(); | |
49 | |
50 // WebIntentPicker implementation. | |
51 virtual void Close() OVERRIDE; | |
52 virtual void SetActionString(const string16& action) OVERRIDE; | |
53 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; | |
54 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE; | |
55 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE; | |
56 virtual void OnPendingAsyncCompleted() OVERRIDE; | |
57 virtual void InvalidateDelegate() OVERRIDE; | |
58 | |
59 // WebIntentPickerModelObserver implementation. | |
60 virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE; | |
61 virtual void OnFaviconChanged(WebIntentPickerModel* model, | |
62 size_t index) OVERRIDE; | |
63 virtual void OnExtensionIconChanged(WebIntentPickerModel* model, | |
64 const std::string& extension_id) OVERRIDE; | |
65 virtual void OnInlineDisposition(const string16& title, | |
66 const GURL& url) OVERRIDE; | |
67 | |
68 private: | |
69 ConstrainedWindow* window_; // Window for constrained sheet. Weak reference. | |
70 | |
71 // Weak pointer to the |delegate_| to notify about user choice/cancellation. | |
72 WebIntentPickerDelegate* delegate_; | |
73 | |
74 // The picker model. Weak reference. | |
75 WebIntentPickerModel* model_; | |
76 | |
77 // WebContents we're in. Weak Reference. | |
78 content::WebContents* web_contents_; | |
79 | |
80 WebIntentPickerSheetController* sheet_controller_; // Weak reference. | |
81 | |
82 // WebContents to hold intent page if inline disposition is used. | |
83 scoped_ptr<content::WebContents> inline_disposition_web_contents_; | |
84 | |
85 // Delegate for inline disposition tab contents. | |
86 scoped_ptr<WebIntentInlineDispositionDelegate> inline_disposition_delegate_; | |
87 | |
88 // Indicate that we invoked a service, instead of just closing/cancelling. | |
89 bool service_invoked; | |
90 | |
91 // Re-layout the intent picker. | |
92 void PerformLayout(); | |
93 | |
94 // Default constructor, for testing only. | |
95 WebIntentPickerCocoa(); | |
96 | |
97 // For testing access. | |
98 friend class WebIntentSheetControllerBrowserTest; | |
99 | |
100 DISALLOW_COPY_AND_ASSIGN(WebIntentPickerCocoa); | |
101 }; | |
102 | |
103 #endif // CHROME_BROWSER_UI_COCOA_WEB_INTENT_PICKER_COCOA_H_ | |
OLD | NEW |