| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "base/mac/mac_util.h" | 5 #include "base/mac/mac_util.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 8 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 9 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 9 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 10 #import "chrome/browser/ui/cocoa/validation_message_bubble_controller.h" | 10 #import "chrome/browser/ui/cocoa/validation_message_bubble_controller.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 const gfx::Rect& anchor_in_root_view, | 155 const gfx::Rect& anchor_in_root_view, |
| 156 const base::string16& main_text, | 156 const base::string16& main_text, |
| 157 const base::string16& sub_text) { | 157 const base::string16& sub_text) { |
| 158 controller_.reset([[[ValidationMessageBubbleController alloc] | 158 controller_.reset([[[ValidationMessageBubbleController alloc] |
| 159 init:[widget_host->GetView()->GetNativeView() window] | 159 init:[widget_host->GetView()->GetNativeView() window] |
| 160 anchoredAt:GetAnchorPoint(widget_host, anchor_in_root_view) | 160 anchoredAt:GetAnchorPoint(widget_host, anchor_in_root_view) |
| 161 mainText:main_text | 161 mainText:main_text |
| 162 subText:sub_text] retain]); | 162 subText:sub_text] retain]); |
| 163 } | 163 } |
| 164 | 164 |
| 165 virtual ~ValidationMessageBubbleCocoa() { | 165 ~ValidationMessageBubbleCocoa() override { [controller_.get() close]; } |
| 166 [controller_.get() close]; | |
| 167 } | |
| 168 | 166 |
| 169 virtual void SetPositionRelativeToAnchor( | 167 void SetPositionRelativeToAnchor( |
| 170 content::RenderWidgetHost* widget_host, | 168 content::RenderWidgetHost* widget_host, |
| 171 const gfx::Rect& anchor_in_root_view) override { | 169 const gfx::Rect& anchor_in_root_view) override { |
| 172 [controller_.get() | 170 [controller_.get() |
| 173 setAnchorPoint:GetAnchorPoint(widget_host, anchor_in_root_view)]; | 171 setAnchorPoint:GetAnchorPoint(widget_host, anchor_in_root_view)]; |
| 174 } | 172 } |
| 175 | 173 |
| 176 private: | 174 private: |
| 177 base::scoped_nsobject<ValidationMessageBubbleController> controller_; | 175 base::scoped_nsobject<ValidationMessageBubbleController> controller_; |
| 178 }; | 176 }; |
| 179 | 177 |
| 180 } | 178 } |
| 181 | 179 |
| 182 // ---------------------------------------------------------------- | 180 // ---------------------------------------------------------------- |
| 183 | 181 |
| 184 namespace chrome { | 182 namespace chrome { |
| 185 | 183 |
| 186 scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( | 184 scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( |
| 187 content::RenderWidgetHost* widget_host, | 185 content::RenderWidgetHost* widget_host, |
| 188 const gfx::Rect& anchor_in_root_view, | 186 const gfx::Rect& anchor_in_root_view, |
| 189 const base::string16& main_text, | 187 const base::string16& main_text, |
| 190 const base::string16& sub_text) { | 188 const base::string16& sub_text) { |
| 191 return scoped_ptr<ValidationMessageBubble>(new ValidationMessageBubbleCocoa( | 189 return scoped_ptr<ValidationMessageBubble>(new ValidationMessageBubbleCocoa( |
| 192 widget_host, anchor_in_root_view, main_text, sub_text)).Pass(); | 190 widget_host, anchor_in_root_view, main_text, sub_text)).Pass(); |
| 193 } | 191 } |
| 194 | 192 |
| 195 } | 193 } |
| OLD | NEW |