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

Side by Side Diff: chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa.mm

Issue 11414153: Remove legacy constrained window dialogs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
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 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa2.h" 5 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa.h"
6 6
7 #include <Cocoa/Cocoa.h> 7 #include <Cocoa/Cocoa.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/mac/foundation_util.h" 10 #include "base/mac/foundation_util.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" 12 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" 13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h"
14 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.h" 14 #import "chrome/browser/ui/cocoa/intents/web_intent_picker_view_controller.h"
15 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h" 15 #include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents.h"
17 #include "content/public/browser/native_web_keyboard_event.h" 17 #include "content/public/browser/native_web_keyboard_event.h"
18 18
19 WebIntentPickerCocoa2::WebIntentPickerCocoa2(content::WebContents* web_contents, 19 // static
20 WebIntentPickerDelegate* delegate, 20 WebIntentPicker* WebIntentPicker::Create(content::WebContents* web_contents,
21 WebIntentPickerModel* model) 21 WebIntentPickerDelegate* delegate,
22 WebIntentPickerModel* model) {
23 return new WebIntentPickerCocoa(web_contents, delegate, model);
24 }
25
26 WebIntentPickerCocoa::WebIntentPickerCocoa(content::WebContents* web_contents,
27 WebIntentPickerDelegate* delegate,
28 WebIntentPickerModel* model)
22 : web_contents_(web_contents), 29 : web_contents_(web_contents),
23 delegate_(delegate), 30 delegate_(delegate),
24 model_(model), 31 model_(model),
25 update_pending_(false), 32 update_pending_(false),
26 weak_ptr_factory_(this) { 33 weak_ptr_factory_(this) {
27 model_->set_observer(this); 34 model_->set_observer(this);
28 35
29 view_controller_.reset( 36 view_controller_.reset(
30 [[WebIntentPickerViewController alloc] initWithPicker:this]); 37 [[WebIntentPickerViewController alloc] initWithPicker:this]);
31 38
32 scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc] 39 scoped_nsobject<NSWindow> window([[ConstrainedWindowCustomWindow alloc]
33 initWithContentRect:[[view_controller_ view] bounds]]); 40 initWithContentRect:[[view_controller_ view] bounds]]);
34 [[window contentView] addSubview:[view_controller_ view]]; 41 [[window contentView] addSubview:[view_controller_ view]];
35 [view_controller_ update]; 42 [view_controller_ update];
36 43
37 constrained_window_.reset(new ConstrainedWindowMac2( 44 constrained_window_.reset(new ConstrainedWindowMac2(
38 this, web_contents, window)); 45 this, web_contents, window));
39 } 46 }
40 47
41 WebIntentPickerCocoa2::~WebIntentPickerCocoa2() { 48 WebIntentPickerCocoa::~WebIntentPickerCocoa() {
42 } 49 }
43 50
44 void WebIntentPickerCocoa2::Close() { 51 void WebIntentPickerCocoa::Close() {
45 constrained_window_->CloseConstrainedWindow(); 52 constrained_window_->CloseConstrainedWindow();
46 } 53 }
47 54
48 void WebIntentPickerCocoa2::SetActionString(const string16& action) { 55 void WebIntentPickerCocoa::SetActionString(const string16& action) {
49 // Ignored. Action string is retrieved from the model. 56 // Ignored. Action string is retrieved from the model.
50 } 57 }
51 58
52 void WebIntentPickerCocoa2::OnExtensionInstallSuccess(const std::string& id) { 59 void WebIntentPickerCocoa::OnExtensionInstallSuccess(const std::string& id) {
53 ScheduleUpdate(); 60 ScheduleUpdate();
54 } 61 }
55 62
56 void WebIntentPickerCocoa2::OnExtensionInstallFailure(const std::string& id) { 63 void WebIntentPickerCocoa::OnExtensionInstallFailure(const std::string& id) {
57 ScheduleUpdate(); 64 ScheduleUpdate();
58 } 65 }
59 66
60 void WebIntentPickerCocoa2::OnShowExtensionInstallDialog( 67 void WebIntentPickerCocoa::OnShowExtensionInstallDialog(
61 content::WebContents* parent_web_contents, 68 content::WebContents* parent_web_contents,
62 ExtensionInstallPrompt::Delegate* delegate, 69 ExtensionInstallPrompt::Delegate* delegate,
63 const ExtensionInstallPrompt::Prompt& prompt) { 70 const ExtensionInstallPrompt::Prompt& prompt) {
64 ScheduleUpdate(); 71 ScheduleUpdate();
65 } 72 }
66 73
67 void WebIntentPickerCocoa2::OnInlineDispositionAutoResize( 74 void WebIntentPickerCocoa::OnInlineDispositionAutoResize(
68 const gfx::Size& size) { 75 const gfx::Size& size) {
69 ScheduleUpdate(); 76 ScheduleUpdate();
70 } 77 }
71 78
72 void WebIntentPickerCocoa2::OnInlineDispositionHandleKeyboardEvent( 79 void WebIntentPickerCocoa::OnInlineDispositionHandleKeyboardEvent(
73 const content::NativeWebKeyboardEvent& event) { 80 const content::NativeWebKeyboardEvent& event) {
74 if (event.skip_in_browser || 81 if (event.skip_in_browser ||
75 event.type == content::NativeWebKeyboardEvent::Char) { 82 event.type == content::NativeWebKeyboardEvent::Char) {
76 return; 83 return;
77 } 84 }
78 ChromeEventProcessingWindow* window = 85 ChromeEventProcessingWindow* window =
79 base::mac::ObjCCastStrict<ChromeEventProcessingWindow>( 86 base::mac::ObjCCastStrict<ChromeEventProcessingWindow>(
80 constrained_window_->GetNativeWindow()); 87 constrained_window_->GetNativeWindow());
81 [window redispatchKeyEvent:event.os_event]; 88 [window redispatchKeyEvent:event.os_event];
82 } 89 }
83 90
84 void WebIntentPickerCocoa2::OnPendingAsyncCompleted() { 91 void WebIntentPickerCocoa::OnPendingAsyncCompleted() {
85 ScheduleUpdate(); 92 ScheduleUpdate();
86 } 93 }
87 94
88 void WebIntentPickerCocoa2::InvalidateDelegate() { 95 void WebIntentPickerCocoa::InvalidateDelegate() {
89 delegate_ = NULL; 96 delegate_ = NULL;
90 } 97 }
91 98
92 void WebIntentPickerCocoa2::OnInlineDispositionWebContentsLoaded( 99 void WebIntentPickerCocoa::OnInlineDispositionWebContentsLoaded(
93 content::WebContents* web_contents) { 100 content::WebContents* web_contents) {
94 ScheduleUpdate(); 101 ScheduleUpdate();
95 } 102 }
96 103
97 gfx::Size WebIntentPickerCocoa2::GetMinInlineDispositionSize() { 104 gfx::Size WebIntentPickerCocoa::GetMinInlineDispositionSize() {
98 return [view_controller_ minimumInlineWebViewSize]; 105 return [view_controller_ minimumInlineWebViewSize];
99 } 106 }
100 107
101 void WebIntentPickerCocoa2::OnModelChanged(WebIntentPickerModel* model) { 108 void WebIntentPickerCocoa::OnModelChanged(WebIntentPickerModel* model) {
102 ScheduleUpdate(); 109 ScheduleUpdate();
103 } 110 }
104 111
105 void WebIntentPickerCocoa2::OnFaviconChanged(WebIntentPickerModel* model, 112 void WebIntentPickerCocoa::OnFaviconChanged(WebIntentPickerModel* model,
106 size_t index) { 113 size_t index) {
107 ScheduleUpdate(); 114 ScheduleUpdate();
108 } 115 }
109 116
110 void WebIntentPickerCocoa2::OnExtensionIconChanged( 117 void WebIntentPickerCocoa::OnExtensionIconChanged(
111 WebIntentPickerModel* model, 118 WebIntentPickerModel* model,
112 const std::string& extension_id) { 119 const std::string& extension_id) {
113 ScheduleUpdate(); 120 ScheduleUpdate();
114 } 121 }
115 122
116 void WebIntentPickerCocoa2::OnInlineDisposition(const string16& title, 123 void WebIntentPickerCocoa::OnInlineDisposition(const string16& title,
117 const GURL& url) { 124 const GURL& url) {
118 ScheduleUpdate(); 125 ScheduleUpdate();
119 } 126 }
120 127
121 void WebIntentPickerCocoa2::OnConstrainedWindowClosed( 128 void WebIntentPickerCocoa::OnConstrainedWindowClosed(
122 ConstrainedWindowMac2* window) { 129 ConstrainedWindowMac2* window) {
123 // After the OnClosing call the model may be deleted so unset this reference. 130 // After the OnClosing call the model may be deleted so unset this reference.
124 model_->set_observer(NULL); 131 model_->set_observer(NULL);
125 model_ = NULL; 132 model_ = NULL;
126 weak_ptr_factory_.InvalidateWeakPtrs(); 133 weak_ptr_factory_.InvalidateWeakPtrs();
127 134
128 if (delegate_) 135 if (delegate_)
129 delegate_->OnClosing(); 136 delegate_->OnClosing();
130 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 137 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
131 } 138 }
132 139
133 void WebIntentPickerCocoa2::ScheduleUpdate() { 140 void WebIntentPickerCocoa::ScheduleUpdate() {
134 if (update_pending_) 141 if (update_pending_)
135 return; 142 return;
136 update_pending_ = true; 143 update_pending_ = true;
137 MessageLoop::current()->PostTask( 144 MessageLoop::current()->PostTask(
138 FROM_HERE, 145 FROM_HERE,
139 base::Bind(&WebIntentPickerCocoa2::PerformUpdate, 146 base::Bind(&WebIntentPickerCocoa::PerformUpdate,
140 weak_ptr_factory_.GetWeakPtr())); 147 weak_ptr_factory_.GetWeakPtr()));
141 } 148 }
142 149
143 void WebIntentPickerCocoa2::PerformUpdate() { 150 void WebIntentPickerCocoa::PerformUpdate() {
144 update_pending_ = false; 151 update_pending_ = false;
145 [view_controller_ update]; 152 [view_controller_ update];
146 } 153 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa.h ('k') | chrome/browser/ui/cocoa/intents/web_intent_picker_cocoa2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698