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

Side by Side Diff: chrome/browser/ui/views/intent_picker_bubble_view.cc

Issue 2335313003: Refactor IntentPickerBubbleView::ShowBubble() (Closed)
Patch Set: Created 4 years, 3 months 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/ui/views/intent_picker_bubble_view.h" 5 #include "chrome/browser/ui/views/intent_picker_bubble_view.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 // Arbitrary negative values to use as tags on the |always_button_| and 44 // Arbitrary negative values to use as tags on the |always_button_| and
45 // |just_once_button_|. These are negative to differentiate from the app's tags 45 // |just_once_button_|. These are negative to differentiate from the app's tags
46 // which are always >= 0. 46 // which are always >= 0.
47 enum class Option : int { ALWAYS = -2, JUST_ONCE }; 47 enum class Option : int { ALWAYS = -2, JUST_ONCE };
48 48
49 } // namespace 49 } // namespace
50 50
51 // static 51 // static
52 void IntentPickerBubbleView::ShowBubble( 52 void IntentPickerBubbleView::ShowBubble(
53 content::NavigationHandle* handle, 53 content::WebContents* contents,
djacobo_ 2016/09/14 17:16:53 nit: other parts of the class refer to |web_conten
Yusuke Sato 2016/09/14 18:15:55 Done.
54 const std::vector<NameAndIcon>& app_info, 54 const std::vector<NameAndIcon>& app_info,
55 const ThrottleCallback& throttle_cb) { 55 const ThrottleCallback& throttle_cb) {
56 Browser* browser = 56 Browser* browser = chrome::FindBrowserWithWebContents(contents);
57 chrome::FindBrowserWithWebContents(handle->GetWebContents());
58 if (!browser) { 57 if (!browser) {
59 throttle_cb.Run(kAppTagNoneSelected, 58 throttle_cb.Run(kAppTagNoneSelected,
60 arc::ArcNavigationThrottle::CloseReason::ERROR); 59 arc::ArcNavigationThrottle::CloseReason::ERROR);
61 return; 60 return;
62 } 61 }
63 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser); 62 BrowserView* browser_view = BrowserView::GetBrowserViewForBrowser(browser);
64 if (!browser_view) { 63 if (!browser_view) {
65 throttle_cb.Run(kAppTagNoneSelected, 64 throttle_cb.Run(kAppTagNoneSelected,
66 arc::ArcNavigationThrottle::CloseReason::ERROR); 65 arc::ArcNavigationThrottle::CloseReason::ERROR);
67 return; 66 return;
68 } 67 }
69 68
70 IntentPickerBubbleView* delegate = new IntentPickerBubbleView( 69 IntentPickerBubbleView* delegate =
71 app_info, throttle_cb, handle->GetWebContents()); 70 new IntentPickerBubbleView(app_info, throttle_cb, contents);
72 delegate->set_margins(gfx::Insets()); 71 delegate->set_margins(gfx::Insets());
73 delegate->set_parent_window(browser_view->GetNativeWindow()); 72 delegate->set_parent_window(browser_view->GetNativeWindow());
74 views::Widget* widget = 73 views::Widget* widget =
75 views::BubbleDialogDelegateView::CreateBubble(delegate); 74 views::BubbleDialogDelegateView::CreateBubble(delegate);
76 75
77 delegate->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 76 delegate->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
78 delegate->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 77 delegate->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
79 78
80 // Using the TopContainerBoundsInScreen Rect to specify an anchor for the the 79 // Using the TopContainerBoundsInScreen Rect to specify an anchor for the the
81 // UI. Rect allow us to set the coordinates(x,y), the width and height for the 80 // UI. Rect allow us to set the coordinates(x,y), the width and height for the
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 views::View* temp_contents = scroll_view_->contents(); 308 views::View* temp_contents = scroll_view_->contents();
310 return static_cast<views::LabelButton*>(temp_contents->child_at(index)); 309 return static_cast<views::LabelButton*>(temp_contents->child_at(index));
311 } 310 }
312 311
313 void IntentPickerBubbleView::SetLabelButtonBackgroundColor(size_t index, 312 void IntentPickerBubbleView::SetLabelButtonBackgroundColor(size_t index,
314 SkColor color) { 313 SkColor color) {
315 views::LabelButton* temp_lb = GetLabelButtonAt(index); 314 views::LabelButton* temp_lb = GetLabelButtonAt(index);
316 temp_lb->set_background(views::Background::CreateSolidBackground(color)); 315 temp_lb->set_background(views::Background::CreateSolidBackground(color));
317 temp_lb->SchedulePaint(); 316 temp_lb->SchedulePaint();
318 } 317 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698