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

Side by Side Diff: chrome/browser/chromeos/status/network_menu_button.cc

Issue 8351021: Use Closure instead of ScopedRunnableMethodFactory in NetworkMenuButton. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: weak_ptr_factory_ Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/status/network_menu_button.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/chromeos/status/network_menu_button.h" 5 #include "chrome/browser/chromeos/status/network_menu_button.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <vector>
9 10
11 #include "base/bind.h"
10 #include "base/logging.h" 12 #include "base/logging.h"
11 #include "base/message_loop.h" 13 #include "base/message_loop.h"
12 #include "base/string_util.h" 14 #include "base/string_util.h"
13 #include "base/stringprintf.h" 15 #include "base/stringprintf.h"
14 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
15 #include "chrome/browser/browser_process.h" 17 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/chromeos/cros/cros_library.h" 18 #include "chrome/browser/chromeos/cros/cros_library.h"
17 #include "chrome/browser/chromeos/login/helper.h" 19 #include "chrome/browser/chromeos/login/helper.h"
18 #include "chrome/browser/chromeos/login/user_manager.h" 20 #include "chrome/browser/chromeos/login/user_manager.h"
19 #include "chrome/browser/chromeos/options/network_config_view.h" 21 #include "chrome/browser/chromeos/options/network_config_view.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 95
94 //////////////////////////////////////////////////////////////////////////////// 96 ////////////////////////////////////////////////////////////////////////////////
95 // NetworkMenuButton 97 // NetworkMenuButton
96 98
97 NetworkMenuButton::NetworkMenuButton(StatusAreaHost* host) 99 NetworkMenuButton::NetworkMenuButton(StatusAreaHost* host)
98 : StatusAreaButton(host, this), 100 : StatusAreaButton(host, this),
99 mobile_data_bubble_(NULL), 101 mobile_data_bubble_(NULL),
100 is_browser_mode_(false), 102 is_browser_mode_(false),
101 check_for_promo_(true), 103 check_for_promo_(true),
102 was_sim_locked_(false), 104 was_sim_locked_(false),
103 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) { 105 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
104 is_browser_mode_ = (host->GetScreenMode() == StatusAreaHost::kBrowserMode); 106 is_browser_mode_ = (host->GetScreenMode() == StatusAreaHost::kBrowserMode);
105 network_menu_.reset(new NetworkMenu(this, is_browser_mode_)); 107 network_menu_.reset(new NetworkMenu(this, is_browser_mode_));
106 network_icon_.reset( 108 network_icon_.reset(
107 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE)); 109 new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE));
108 110
109 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary(); 111 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary();
110 OnNetworkManagerChanged(network_library); 112 OnNetworkManagerChanged(network_library);
111 network_library->AddNetworkManagerObserver(this); 113 network_library->AddNetworkManagerObserver(this);
112 network_library->AddCellularDataPlanObserver(this); 114 network_library->AddCellularDataPlanObserver(this);
113 const NetworkDevice* cellular = network_library->FindCellularDevice(); 115 const NetworkDevice* cellular = network_library->FindCellularDevice();
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 // Contains() method for screen bounds works correctly. 380 // Contains() method for screen bounds works correctly.
379 button_bounds.set_y(button_bounds.y() + 1); 381 button_bounds.set_y(button_bounds.y() + 1);
380 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size())); 382 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(gfx::Size()));
381 383
382 // Chrome window is initialized in visible state off screen and then is 384 // Chrome window is initialized in visible state off screen and then is
383 // moved into visible screen area. Make sure that we're on screen 385 // moved into visible screen area. Make sure that we're on screen
384 // so that bubble is shown correctly. 386 // so that bubble is shown correctly.
385 if (!screen_bounds.Contains(button_bounds)) { 387 if (!screen_bounds.Contains(button_bounds)) {
386 // If we're not on screen yet, delay notification display. 388 // If we're not on screen yet, delay notification display.
387 // It may be shown earlier, on next NetworkLibrary callback processing. 389 // It may be shown earlier, on next NetworkLibrary callback processing.
388 if (method_factory_.empty()) { 390 if (!weak_ptr_factory_.HasWeakPtrs()) {
389 MessageLoop::current()->PostDelayedTask(FROM_HERE, 391 MessageLoop::current()->PostDelayedTask(FROM_HERE,
390 method_factory_.NewRunnableMethod( 392 base::Bind(
391 &NetworkMenuButton::ShowOptionalMobileDataPromoNotification, 393 &NetworkMenuButton::ShowOptionalMobileDataPromoNotification,
394 weak_ptr_factory_.GetWeakPtr(),
392 cros), 395 cros),
393 kPromoShowDelayMs); 396 kPromoShowDelayMs);
394 } 397 }
395 return; 398 return;
396 } 399 }
397 400
398 // Add deal text if it's defined. 401 // Add deal text if it's defined.
399 std::wstring notification_text; 402 std::wstring notification_text;
400 std::wstring default_text = 403 std::wstring default_text =
401 UTF16ToWide(l10n_util::GetStringUTF16(IDS_3G_NOTIFICATION_MESSAGE)); 404 UTF16ToWide(l10n_util::GetStringUTF16(IDS_3G_NOTIFICATION_MESSAGE));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1); 436 SetCarrierDealPromoShown(carrier_deal_promo_pref + 1);
434 } 437 }
435 } 438 }
436 439
437 void NetworkMenuButton::SetTooltipAndAccessibleName(const string16& label) { 440 void NetworkMenuButton::SetTooltipAndAccessibleName(const string16& label) {
438 SetTooltipText(label); 441 SetTooltipText(label);
439 SetAccessibleName(label); 442 SetAccessibleName(label);
440 } 443 }
441 444
442 } // namespace chromeos 445 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/network_menu_button.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698