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_INTENTS_WEB_INTENT_PICKER_COCOA2_H_ | |
6 #define CHROME_BROWSER_UI_COCOA_INTENTS_WEB_INTENT_PICKER_COCOA2_H_ | |
7 | |
8 #import <Cocoa/Cocoa.h> | |
9 | |
10 #include "base/memory/scoped_nsobject.h" | |
11 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac2.h" | |
12 #include "chrome/browser/ui/intents/web_intent_picker.h" | |
13 #include "chrome/browser/ui/intents/web_intent_picker_model_observer.h" | |
14 | |
15 @class WebIntentPickerViewController; | |
16 | |
17 // An implementation of WebIntentPicker for Cocoa. Bridges between the C++ and | |
18 // the Cocoa WebIntentPickerViewController object. Note, this will eventually | |
19 // replace WebIntentPickerCocoa, see http://crbug.com/152010. | |
20 class WebIntentPickerCocoa2 : public WebIntentPicker, | |
21 public WebIntentPickerModelObserver, | |
22 public ConstrainedWindowMacDelegate2 { | |
23 public: | |
24 WebIntentPickerCocoa2(content::WebContents* web_contents, | |
25 WebIntentPickerDelegate* delegate, | |
26 WebIntentPickerModel* model); | |
27 virtual ~WebIntentPickerCocoa2(); | |
28 | |
29 WebIntentPickerDelegate* delegate() const { | |
30 DCHECK(delegate_); | |
31 return delegate_; | |
32 } | |
33 | |
34 WebIntentPickerModel* model() const { return model_; } | |
35 content::WebContents* web_contents() const { return web_contents_; } | |
36 ConstrainedWindowMac2* constrained_window() const { | |
37 return constrained_window_.get(); | |
38 } | |
39 WebIntentPickerViewController* view_controller() const { | |
40 return view_controller_; | |
41 } | |
42 | |
43 // WebIntentPicker implementation. | |
44 virtual void Close() OVERRIDE; | |
45 virtual void SetActionString(const string16& action) OVERRIDE; | |
46 virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE; | |
47 virtual void OnExtensionInstallFailure(const std::string& id) OVERRIDE; | |
48 virtual void OnShowExtensionInstallDialog( | |
49 content::WebContents* parent_web_contents, | |
50 ExtensionInstallPrompt::Delegate* delegate, | |
51 const ExtensionInstallPrompt::Prompt& prompt) OVERRIDE; | |
52 virtual void OnInlineDispositionAutoResize(const gfx::Size& size) OVERRIDE; | |
53 virtual void OnInlineDispositionHandleKeyboardEvent( | |
54 const content::NativeWebKeyboardEvent& event) OVERRIDE; | |
55 virtual void OnPendingAsyncCompleted() OVERRIDE; | |
56 virtual void InvalidateDelegate() OVERRIDE; | |
57 virtual void OnInlineDispositionWebContentsLoaded( | |
58 content::WebContents* web_contents) OVERRIDE; | |
59 virtual gfx::Size GetMinInlineDispositionSize() OVERRIDE; | |
60 | |
61 // WebIntentPickerModelObserver implementation. | |
62 virtual void OnModelChanged(WebIntentPickerModel* model) OVERRIDE; | |
63 virtual void OnFaviconChanged(WebIntentPickerModel* model, | |
64 size_t index) OVERRIDE; | |
65 virtual void OnExtensionIconChanged(WebIntentPickerModel* model, | |
66 const std::string& extension_id) OVERRIDE; | |
67 virtual void OnInlineDisposition(const string16& title, | |
68 const GURL& url) OVERRIDE; | |
69 | |
70 // ConstrainedWindowMacDelegate2 implementation. | |
71 virtual void OnConstrainedWindowClosed( | |
72 ConstrainedWindowMac2* window) OVERRIDE; | |
73 | |
74 private: | |
75 void ScheduleUpdate(); | |
76 void PerformUpdate(); | |
77 | |
78 content::WebContents* const web_contents_; | |
79 WebIntentPickerDelegate* delegate_; | |
80 WebIntentPickerModel* model_; | |
81 scoped_nsobject<WebIntentPickerViewController> view_controller_; | |
82 scoped_ptr<ConstrainedWindowMac2> constrained_window_; | |
83 bool update_pending_; | |
84 base::WeakPtrFactory<WebIntentPickerCocoa2> weak_ptr_factory_; | |
85 }; | |
86 | |
87 #endif // CHROME_BROWSER_UI_COCOA_INTENTS_WEB_INTENT_PICKER_COCOA2_H_ | |
OLD | NEW |